Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bigjs-adapter

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bigjs-adapter - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

2

package.json
{
"name": "bigjs-adapter",
"version": "2.0.0",
"version": "2.0.1",
"description": "big.js adapter for linear-arbitrary-precision",

@@ -5,0 +5,0 @@ "main": "src/bigjs-adapter.js",

@@ -16,57 +16,4 @@ # bigjs-adapter

### Factory and configuration
See [linear-arbitrary-precision docs](https://github.com/javiercejudo/linear-arbitrary-precision/blob/master/README.md#usage).
```js
var decimalFactory = require('linear-arbitrary-precision');
var adapter = require('bigjs-adapter');
var Decimal = decimalFactory(adapter);
Decimal.getPrecision(); // => 20
new Decimal(1).div(3).valueOf(); // => '0.33333333333333333333'
Decimal.setPrecision(5);
new Decimal(1).div(3).valueOf(); // => '0.33333'
```
### Operations
```js
new Decimal(0.1).plus(0.2).valueOf(); // => '0.3'
new Decimal(0.3).minus(0.1).valueOf(); // => '0.2'
new Decimal(0.6).times(3).valueOf(); // => '1.8'
new Decimal(0.3).div(0.2).valueOf(); // => '1.5'
```
### toString, valueOf and toJSON
```js
var decimalThird = new Decimal(1).div(new Decimal(3));
decimalThird.toString() === decimalThird.valueOf() === decimalThird.toJSON(); // => true
Number(decimalThird); // => 1/3
```
### JSON.stringify and JSON.parse with reviver
```js
var Decimal40 = decimalFactory(adapter);
Decimal40.setPrecision(40);
var decimalThird = new Decimal40(1).div(3);
var stringified = JSON.stringify([decimalThird]);
// => '["0.3333333333333333333333333333333333333333"]'
JSON.parse(stringified, Decimal40.JSONReviver)[0];
// => new Decimal40('0.3333333333333333333333333333333333333333')
```
See [spec](test/spec.js).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc