Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

smath

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smath

Small math function library

  • 1.1.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
168
increased by281.82%
Maintainers
1
Weekly downloads
 
Created
Source

Docs | GitHub | npm | Changelog | Small math function library

NPM Downloads NPM Version Relative date GitHub watchers GitHub forks GitHub Repo stars

Installation

smath can be installed from the official npm package repository. It is highly recommended to install the latest version, which is installed by default with the following command.

npm i smath@1.1.5

Bugs and Requests

Is there a way we can make smath better? Please report all bugs, issues, and new feature requests to the issues page in the official repository. For critical security issues, please send an email to smath@nicolasventura.com.

Contribute

Thank you for your interest in contributing to smath! smath is an open source software package maintained by Nicolas Ventura (@nicfv) and built by users like you! You are allowed to fork the repository as permitted by the MIT License terms. Contributions are welcome by submitting a pull request. Please follow the existing code styling if submitting a pull request. Thank you for your consideration!

Getting Started

Similar to JavaScript's builtin Math object, SMath exports one global object with several math-related helper functions. There is no need to instantiate the class, just call functions directly. See the examples below to get started using SMath!

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.');
}

Keywords

FAQs

Package last updated on 19 Mar 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc