bigjs-adapter
Advanced tools
Comparing version 2.0.0 to 2.0.1
{ | ||
"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). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7516
19