New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@cdjs/js-math

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cdjs/js-math

A simple math calculation library for JavaScript and Node.js

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

js-math

A lightweight Javascript math library.

Installing

npm install @cdjs/js-math
// or
yarn add @cdjs/js-math

Usage

// es6 module
import jsMath, { multiply, add, subtract, devide, round } from '@cdjs/js-math'
// commonjs
const { multiply, add, subtract, devide, round, default: jsMath } = require('@cdjs/js-math')

Documentation

MethodDescArgs
multiply...Array
add...Array
subtract...Array
devide...Array
round四舍五入ratio: Number 精度
number?: Number 需要处理的数字
value获取最终值/
setPrecision设置浮点数最大保留精度,默认 12 位number: Number
enableCheck是否开启对运算结果是否超出 js 安全数值的提醒,默认 falsecheck: Boolean

How to use

#####Simple use

// 乘
multiply(3, 2) // 6
add(0,1, 0.2)  // 0.3
// 四舍五入
round(0.345, 2) // 0.35

#####Chained use

jsMath
  .multiply(0.2, 10, 100)
  .add(1, 2, 3, 5, 10, 1000)
  .subtract(0.1, 0.3, 0.4)
  .devide(2, 5, 5, 20)
  .round(2)
  .value() // 1.22

Keywords

Javascipt

FAQs

Package last updated on 25 Jul 2020

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