0
bigdash - npm
source link: https://www.npmjs.com/package/bigdash
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Bigdash
Re-implement lodash math functions with big.js.
Lodash:
sum([0.1, 0.2]); // 0.30000000000000004
Bigdash:
sum([0.1, 0.2]); // 0.3
Install
npm install --save bigdash
Usage
add()
import { add } from 'bigdash';
add(0.1, 0.2); // 0.3
divide()
import { divide } from 'bigdash';
divide(0.1, 0.2); // 0.5
mean()
import { mean } from 'bigdash';
mean([0.1, 0.2]); // 0.15
meanBy()
import { meanBy } from 'bigdash';
meanBy([{ foo: { bar: 0.1 } }, { foo: { bar: 0.2 } }], 'foo.bar'); // 0.15
meanBy([{ foo: { bar: 0.1 } }, { foo: { bar: 0.2 } }], ['foo', 'bar']); // 0.15
meanBy([{ foo: { bar: 0.1 } }, { foo: { bar: 0.2 } }], (item) => item.foo.bar); // 0.15
multiply()
import { multiply } from 'bigdash';
multiply(0.1, 0.2); // 0.02
subtract()
import { subtract } from 'bigdash';
subtract(0.3, 0.2); // 0.1
sum()
import { sum } from 'bigdash';
sum([0.1, 0.2]); // 0.3
sumBy()
import { sumBy } from 'bigdash';
sumBy([{ foo: { bar: 0.1 } }, { foo: { bar: 0.2 } }], 'foo.bar'); // 0.3
sumBy([{ foo: { bar: 0.1 } }, { foo: { bar: 0.2 } }], ['foo', 'bar']); // 0.3
sumBy([{ foo: { bar: 0.1 } }, { foo: { bar: 0.2 } }], (item) => item.foo.bar); // 0.3
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK