bigdash
v1.3.0
Published
re-implement lodash math functions with big.js
Downloads
2
Maintainers
Readme
Bigdash
Re-implement lodash math functions with big.js.
Why?
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