npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

point3d

v0.0.4

Published

Cartesian 3D data type, with basic vector math methods

Downloads

2

Readme

point3d

Cartesian 3D data type, with basic vector math methods

How to use point3d in your project

point3d is published as an NPM module. To install it in your project, simply execute the following:

npm install --save point3d

point3d exports a single class. The class constructor can be used to construct Cartesian points at specified coordinates, as follows:

import { Point3d } from "point3d";

const point = new Point3d({ x: 1.0, y: 1.0, z: 1.0 });

The constructed Point has attached methods to perform basic vector math, such as equality checks, addition, subtraction, and scalar and vector products. The methods are written in a pseudo-functional style, always returning the result rather than modifying an existing object. This allows for a concise, chainable syntax. For example, to compute the linear sum a * x + b = c, you can simply chain as follows:

const c = x.scale(a).plus(b);

See the class documentation for more details.

About point3d development

point3d was written in a single 3-hour sprint. Development began with a 30-minute strategizing session, during which the following key decisions were made:

  • Code would be written as an ES6 class. This means it is not supported in Internet Explorer. But all other major browsers support classes, and classes are a good fit for defining a data type
  • Methods would be written in a pseudo-functional style, returning a new instance of the class where necessary. While potentially not as memory-efficient as modify-in-place libraries like glMatrix, it allows for more concise syntax
  • The constructor would input an object with x, y, and z properties, rather than separate parameters for each coordinate. This decision is perhaps of debatable value, but it allows the constructor to input another Point3d
  • The coordinates themselves (x, y, z) would be private to the class. This means they cannot be modified without calling the class methods

Actual coding took about 1.5 hours. Another half hour was needed to learn jasmine, and another half hour to learn JSDoc and write the README.

Contributing

Feedback and pull requests are welcome! If you want to try modifying the code, fork the repository on GitHub.

To make sure we don't break anything as we change the code, point3d has a test suite (implemented in jasmine), which you can run as follows:

npm run test

Please be sure to update the comments in the code. Comments should follow the JSDoc syntax. When you are done, rebuild the docs before committing your code. This can be done via one of the NPM scripts, as follows:

npm run build-docs