npm.io
0.4.6 • Published 6 months ago

@plato/pmath

Licence
UNLICENSED
Version
0.4.6
Deps
3
Size
333 kB
Vulns
0
Weekly
0
Install scriptsThis package runs scripts during installation (preinstall/install/postinstall)

@plato/pmath

Plato math functions, based on FDLIBM.

This package is a Node.js Addon and is compiled from source during package install for the target platform and current version of Node.js.

NOTE: Consider using node-pre-gyp to build/host prebuilt binaries instead.

Usage

Install via Yarn:

yarn add @plato/pmath

Import the package and invoke exported math functions:

import { atan2, cos, sin } from "@plato/pmath";

const n = cos(10);

console.log(`cos(10) = ${n}`);

Development

Install & Update

When pulling updates or initially cloning this repo, make sure to update the submodules by running:

git submodule update --init

Afterwards, simply installing Yarn dependencies will build the native addon (the build scripts are triggered during package install). Run:

yarn
Build

The build steps can be invoked manually as well:

To manually build FDLIBM, run:

yarn build-fdlibm

To manually build the native Node.js addon (requires FDLIBM to have been built previously), run:

yarn build
Test

Execute unit tests (after the native addon is built) by running:

yarn test