https://github.com/guoyunhe/bigdash
re-implement lodash number functions with big.js
https://github.com/guoyunhe/bigdash
Last synced: 3 months ago
JSON representation
re-implement lodash number functions with big.js
- Host: GitHub
- URL: https://github.com/guoyunhe/bigdash
- Owner: guoyunhe
- License: gpl-3.0
- Created: 2022-09-14T05:51:28.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-15T05:42:56.000Z (over 2 years ago)
- Last Synced: 2025-02-11T02:04:25.681Z (4 months ago)
- Language: TypeScript
- Size: 31.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Bigdash
Re-implement lodash math functions with big.js.
## Why?
Lodash:
```js
sum([0.1, 0.2]); // 0.30000000000000004
```Bigdash:
```js
sum([0.1, 0.2]); // 0.3
```[Learn more...](https://0.30000000000000004.com/)
## Install
```bash
npm install --save bigdash
```## Usage
### add()
```js
import { add } from 'bigdash';add(0.1, 0.2); // 0.3
```### divide()
```js
import { divide } from 'bigdash';divide(0.1, 0.2); // 0.5
```### mean()
```js
import { mean } from 'bigdash';mean([0.1, 0.2]); // 0.15
```### meanBy()
```js
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()
```js
import { multiply } from 'bigdash';multiply(0.1, 0.2); // 0.02
```### subtract()
```js
import { subtract } from 'bigdash';subtract(0.3, 0.2); // 0.1
```### sum()
```js
import { sum } from 'bigdash';sum([0.1, 0.2]); // 0.3
```### sumBy()
```js
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
```