
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
fast-morton
Advanced tools
Fast morton encoding/decoding for 2D and 3D coordinates
Both are described in this blog post.
The Lookup Table method is a little faster, at the cost of some additional code size and runtime memory (a few KB) for the tables.
These methods are exported separately (see below) so that your bundler can strip out the LUTs if you decide not to use them.
npm install --save fast-morton
Top-level:
import {
morton2DEncodeMB,
morton2DDecodeMB,
morton2DEncodeLUT,
morton2DDecodeLUT,
morton3DEncodeMB,
morton3DDecodeMB,
morton3DEncodeLUT,
morton3DDecodeLUT
} from "fast-morton";
Deep import:
// 2D using magic bits
import {
morton2DEncode,
morton2DDecode
} from "fast-morton/2d/mb";
// 2D using LUT
import {
morton2DEncode,
morton2DDecode
} from "fast-morton/2d/lut";
// 3D using magic bits
import {
morton2DEncode,
morton2DDecode
} from "fast-morton/3d/mb";
// 3D using LUT
import {
morton2DEncode,
morton2DDecode
} from "fast-morton/3d/lut";
2D:
import {
morton2DEncode,
morton2DDecode
} from "fast-morton/2d/lut";
const mortonCode = morton2DEncode(1, 2); // 9
const coords = morton2Decode(mortonCode); // [1, 2]
3D:
import {
morton3DEncode,
morton3DDecode
} from "fast-morton/3d/lut";
const mortonCode = morton3DEncode(1, 2, 3); // 53
const coords = morton3Decode(mortonCode); // [1, 2, 3]
node:test
usage)npm install
installs all required dependencies.npm run build
to build from TypeScript to common JavaScript distribution formats.npm test
to run all tests.npm run test
run tests against built output with Node.js' native node:test
module. Important: runs against build output so run npm run build
beforehand.npm run build
run build from TypeScript to UMD, CJS, ESM with microbundlenpm run watch
runs build in watch mode with microbundlenpm run lint
will ensure all of the files are prettier-formattednpm run format
will run prettier formatting option on all the examples files (and tests).npm run release
, run clean, production build and release with np
.Code is licensed under the MIT License.
FAQs
Fast morton encoding and decoding for 2D and 3D coordinates
The npm package fast-morton receives a total of 131 weekly downloads. As such, fast-morton popularity was classified as not popular.
We found that fast-morton demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.