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

1.3.0 • Public • Published

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

Learn more...

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

Package Sidebar

Install

npm i bigdash

Weekly Downloads

1

Version

1.3.0

License

GPL-3.0

Unpacked Size

42.3 kB

Total Files

7

Last publish

Collaborators

  • guoyunhe