[go: up one dir, main page]

smath
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

Small math function library

NPM Version NPM Downloads

Installation

smath can be installed from the official npm package repository. It is highly recommended to install the latest version.

npm i smath@latest

Getting Started

Example: A temperature conversion tool using SMath.translate to convert units and SMath.approx to validate the result. The translation uses freezing and boiling points for 2 unit systems to linearly interpolate between them.

import { SMath } from 'smath';

// Define some constants to
// define the number ranges
const C_Freeze = 0,
    C_Boil = 100,
    F_Freeze = 32,
    F_Boil = 212;

// Use the `SMath` class to
// translate the temperature in the
// C number range to a temperature
// in the F number range
const C = 20,
    F_expected = 68,
    F_actual = SMath.translate(C, C_Freeze, C_Boil, F_Freeze, F_Boil);

// Determine whether the
// temperature conversion
// is valid using `approx`
const valid = SMath.approx(F_expected, F_actual);
if (!valid) {
    throw new Error('Invalid result.');
}

Visit the official documentation to learn more!

Contribute

smath is an open source software package hosted on a GitHub repository. Bug reports and feature requests can be submitted in issues. Contributions are also accepted by submitting a pull request. Please follow the code styling if submitting a pull request.

Package Sidebar

Install

npm i smath@1.1.2

Version

1.1.2

License

MIT

Unpacked Size

6.72 kB

Total Files

4

Last publish

Collaborators

  • nicfv