choi

fix dependencies

Showing 152 changed files with 26477 additions and 3 deletions
#### 9.0.0
* 27/05/2019
* For compatibility with legacy browsers, remove `Symbol` references.
#### 8.1.1
* 24/02/2019
* [BUGFIX] #222 Restore missing `var` to `export BigNumber`.
* Allow any key in BigNumber.Instance in *bignumber.d.ts*.
#### 8.1.0
* 23/02/2019
* [NEW FEATURE] #220 Create a BigNumber using `{s, e, c}`.
* [NEW FEATURE] `isBigNumber`: if `BigNumber.DEBUG` is `true`, also check that the BigNumber instance is well-formed.
* Remove `instanceof` checks; just use `_isBigNumber` to identify a BigNumber instance.
* Add `_isBigNumber` to prototype in *bignumber.mjs*.
* Add tests for BigNumber creation from object.
* Update *API.html*.
#### 8.0.2
* 13/01/2019
* #209 `toPrecision` without argument should follow `toString`.
* Improve *Use* section of *README*.
* Optimise `toString(10)`.
* Add verson number to API doc.
#### 8.0.1
* 01/11/2018
* Rest parameter must be array type in *bignumber.d.ts*.
#### 8.0.0
* 01/11/2018
* [NEW FEATURE] Add `BigNumber.sum` method.
* [NEW FEATURE]`toFormat`: add `prefix` and `suffix` options.
* [NEW FEATURE] #178 Pass custom formatting to `toFormat`.
* [BREAKING CHANGE] #184 `toFraction`: return array of BigNumbers not strings.
* [NEW FEATURE] #185 Enable overwrite of `valueOf` to prevent accidental addition to string.
* #183 Add Node.js `crypto` requirement to documentation.
* [BREAKING CHANGE] #198 Disallow signs and whitespace in custom alphabet.
* [NEW FEATURE] #188 Implement `util.inspect.custom` for Node.js REPL.
* #170 Make `isBigNumber` a type guard in *bignumber.d.ts*.
* [BREAKING CHANGE] `BigNumber.min` and `BigNumber.max`: don't accept an array.
* Update *.travis.yml*.
* Remove *bower.json*.
#### 7.2.1
* 24/05/2018
* Add `browser` field to *package.json*.
#### 7.2.0
* 22/05/2018
* #166 Correct *.mjs* file. Remove extension from `main` field in *package.json*.
#### 7.1.0
* 18/05/2018
* Add `module` field to *package.json* for *bignumber.mjs*.
#### 7.0.2
* 17/05/2018
* #165 Bugfix: upper-case letters for bases 11-36 in a custom alphabet.
* Add note to *README* regarding creating BigNumbers from Number values.
#### 7.0.1
* 26/04/2018
* #158 Fix global object variable name typo.
#### 7.0.0
* 26/04/2018
* #143 Remove global BigNumber from typings.
* #144 Enable compatibility with `Object.freeze(Object.prototype)`.
* #148 #123 #11 Only throw on a number primitive with more than 15 significant digits if `BigNumber.DEBUG` is `true`.
* Only throw on an invalid BigNumber value if `BigNumber.DEBUG` is `true`. Return BigNumber `NaN` instead.
* #154 `exponentiatedBy`: allow BigNumber exponent.
* #156 Prevent Content Security Policy *unsafe-eval* issue.
* `toFraction`: allow `Infinity` maximum denominator.
* Comment-out some excess tests to reduce test time.
* Amend indentation and other spacing.
#### 6.0.0
* 26/01/2018
* #137 Implement `APLHABET` configuration option.
* Remove `ERRORS` configuration option.
* Remove `toDigits` method; extend `precision` method accordingly.
* Remove s`round` method; extend `decimalPlaces` method accordingly.
* Remove methods: `ceil`, `floor`, and `truncated`.
* Remove method aliases: `add`, `cmp`, `isInt`, `isNeg`, `trunc`, `mul`, `neg` and `sub`.
* Rename methods: `shift` to `shiftedBy`, `another` to `clone`, `toPower` to `exponentiatedBy`, and `equals` to `isEqualTo`.
* Rename methods: add `is` prefix to `greaterThan`, `greaterThanOrEqualTo`, `lessThan` and `lessThanOrEqualTo`.
* Add methods: `multipliedBy`, `isBigNumber`, `isPositive`, `integerValue`, `maximum` and `minimum`.
* Refactor test suite.
* Add *CHANGELOG.md*.
* Rewrite *bignumber.d.ts*.
* Redo API image.
#### 5.0.0
* 27/11/2017
* #81 Don't throw on constructor call without `new`.
#### 4.1.0
* 26/09/2017
* Remove node 0.6 from *.travis.yml*.
* Add *bignumber.mjs*.
#### 4.0.4
* 03/09/2017
* Add missing aliases to *bignumber.d.ts*.
#### 4.0.3
* 30/08/2017
* Add types: *bignumber.d.ts*.
#### 4.0.2
* 03/05/2017
* #120 Workaround Safari/Webkit bug.
#### 4.0.1
* 05/04/2017
* #121 BigNumber.default to BigNumber['default'].
#### 4.0.0
* 09/01/2017
* Replace BigNumber.isBigNumber method with isBigNumber prototype property.
#### 3.1.2
* 08/01/2017
* Minor documentation edit.
#### 3.1.1
* 08/01/2017
* Uncomment `isBigNumber` tests.
* Ignore dot files.
#### 3.1.0
* 08/01/2017
* Add `isBigNumber` method.
#### 3.0.2
* 08/01/2017
* Bugfix: Possible incorrect value of `ERRORS` after a `BigNumber.another` call (due to `parseNumeric` declaration in outer scope).
#### 3.0.1
* 23/11/2016
* Apply fix for old ipads with `%` issue, see #57 and #102.
* Correct error message.
#### 3.0.0
* 09/11/2016
* Remove `require('crypto')` - leave it to the user.
* Add `BigNumber.set` as `BigNumber.config` alias.
* Default `POW_PRECISION` to `0`.
#### 2.4.0
* 14/07/2016
* #97 Add exports to support ES6 imports.
#### 2.3.0
* 07/03/2016
* #86 Add modulus parameter to `toPower`.
#### 2.2.0
* 03/03/2016
* #91 Permit larger JS integers.
#### 2.1.4
* 15/12/2015
* Correct UMD.
#### 2.1.3
* 13/12/2015
* Refactor re global object and crypto availability when bundling.
#### 2.1.2
* 10/12/2015
* Bugfix: `window.crypto` not assigned to `crypto`.
#### 2.1.1
* 09/12/2015
* Prevent code bundler from adding `crypto` shim.
#### 2.1.0
* 26/10/2015
* For `valueOf` and `toJSON`, include the minus sign with negative zero.
#### 2.0.8
* 2/10/2015
* Internal round function bugfix.
#### 2.0.6
* 31/03/2015
* Add bower.json. Tweak division after in-depth review.
#### 2.0.5
* 25/03/2015
* Amend README. Remove bitcoin address.
#### 2.0.4
* 25/03/2015
* Critical bugfix #58: division.
#### 2.0.3
* 18/02/2015
* Amend README. Add source map.
#### 2.0.2
* 18/02/2015
* Correct links.
#### 2.0.1
* 18/02/2015
* Add `max`, `min`, `precision`, `random`, `shiftedBy`, `toDigits` and `truncated` methods.
* Add the short-forms: `add`, `mul`, `sd`, `sub` and `trunc`.
* Add an `another` method to enable multiple independent constructors to be created.
* Add support for the base 2, 8 and 16 prefixes `0b`, `0o` and `0x`.
* Enable a rounding mode to be specified as a second parameter to `toExponential`, `toFixed`, `toFormat` and `toPrecision`.
* Add a `CRYPTO` configuration property so cryptographically-secure pseudo-random number generation can be specified.
* Add a `MODULO_MODE` configuration property to enable the rounding mode used by the `modulo` operation to be specified.
* Add a `POW_PRECISION` configuration property to enable the number of significant digits calculated by the power operation to be limited.
* Improve code quality.
* Improve documentation.
#### 2.0.0
* 29/12/2014
* Add `dividedToIntegerBy`, `isInteger` and `toFormat` methods.
* Remove the following short-forms: `isF`, `isZ`, `toE`, `toF`, `toFr`, `toN`, `toP`, `toS`.
* Store a BigNumber's coefficient in base 1e14, rather than base 10.
* Add fast path for integers to BigNumber constructor.
* Incorporate the library into the online documentation.
#### 1.5.0
* 13/11/2014
* Add `toJSON` and `decimalPlaces` methods.
#### 1.4.1
* 08/06/2014
* Amend README.
#### 1.4.0
* 08/05/2014
* Add `toNumber`.
#### 1.3.0
* 08/11/2013
* Ensure correct rounding of `sqrt` in all, rather than almost all, cases.
* Maximum radix to 64.
#### 1.2.1
* 17/10/2013
* Sign of zero when x < 0 and x + (-x) = 0.
#### 1.2.0
* 19/9/2013
* Throw Error objects for stack.
#### 1.1.1
* 22/8/2013
* Show original value in constructor error message.
#### 1.1.0
* 1/8/2013
* Allow numbers with trailing radix point.
#### 1.0.1
* Bugfix: error messages with incorrect method name
#### 1.0.0
* 8/11/2012
* Initial release
The MIT Licence.
Copyright (c) 2019 Michael Mclaughlin
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
![bignumber.js](https://raw.githubusercontent.com/MikeMcl/bignumber.js/gh-pages/bignumberjs.png)
A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic.
[![Build Status](https://travis-ci.org/MikeMcl/bignumber.js.svg)](https://travis-ci.org/MikeMcl/bignumber.js)
<br />
## Features
- Integers and decimals
- Simple API but full-featured
- Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal
- 8 KB minified and gzipped
- Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of JavaScript's Number type
- Includes a `toFraction` and a correctly-rounded `squareRoot` method
- Supports cryptographically-secure pseudo-random number generation
- No dependencies
- Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only
- Comprehensive [documentation](http://mikemcl.github.io/bignumber.js/) and test set
![API](https://raw.githubusercontent.com/MikeMcl/bignumber.js/gh-pages/API.png)
If a smaller and simpler library is required see [big.js](https://github.com/MikeMcl/big.js/).
It's less than half the size but only works with decimal numbers and only has half the methods.
It also does not allow `NaN` or `Infinity`, or have the configuration options of this library.
See also [decimal.js](https://github.com/MikeMcl/decimal.js/), which among other things adds support for non-integer powers, and performs all operations to a specified number of significant digits.
## Load
The library is the single JavaScript file *bignumber.js* (or minified, *bignumber.min.js*).
Browser:
```html
<script src='path/to/bignumber.js'></script>
```
[Node.js](http://nodejs.org):
```bash
$ npm install bignumber.js
```
```javascript
const BigNumber = require('bignumber.js');
```
ES6 module:
```javascript
import BigNumber from "./bignumber.mjs"
```
AMD loader libraries such as [requireJS](http://requirejs.org/):
```javascript
require(['bignumber'], function(BigNumber) {
// Use BigNumber here in local scope. No global BigNumber.
});
```
## Use
The library exports a single constructor function, [`BigNumber`](http://mikemcl.github.io/bignumber.js/#bignumber), which accepts a value of type Number, String or BigNumber,
```javascript
let x = new BigNumber(123.4567);
let y = BigNumber('123456.7e-3');
let z = new BigNumber(x);
x.isEqualTo(y) && y.isEqualTo(z) && x.isEqualTo(z); // true
```
To get the string value of a BigNumber use [`toString()`](http://mikemcl.github.io/bignumber.js/#toS) or [`toFixed()`](http://mikemcl.github.io/bignumber.js/#toFix). Using `toFixed()` prevents exponential notation being returned, no matter how large or small the value.
```javascript
let x = new BigNumber('1111222233334444555566');
x.toString(); // "1.111222233334444555566e+21"
x.toFixed(); // "1111222233334444555566"
```
If the limited precision of Number values is not well understood, it is recommended to create BigNumbers from String values rather than Number values to avoid a potential loss of precision.
*In all further examples below, `let`, semicolons and `toString` calls are not shown. If a commented-out value is in quotes it means `toString` has been called on the preceding expression.*
```javascript
// Precision loss from using numeric literals with more than 15 significant digits.
new BigNumber(1.0000000000000001) // '1'
new BigNumber(88259496234518.57) // '88259496234518.56'
new BigNumber(99999999999999999999) // '100000000000000000000'
// Precision loss from using numeric literals outside the range of Number values.
new BigNumber(2e+308) // 'Infinity'
new BigNumber(1e-324) // '0'
// Precision loss from the unexpected result of arithmetic with Number values.
new BigNumber(0.7 + 0.1) // '0.7999999999999999'
```
When creating a BigNumber from a Number, note that a BigNumber is created from a Number's decimal `toString()` value not from its underlying binary value. If the latter is required, then pass the Number's `toString(2)` value and specify base 2.
```javascript
new BigNumber(Number.MAX_VALUE.toString(2), 2)
```
BigNumbers can be created from values in bases from 2 to 36. See [`ALPHABET`](http://mikemcl.github.io/bignumber.js/#alphabet) to extend this range.
```javascript
a = new BigNumber(1011, 2) // "11"
b = new BigNumber('zz.9', 36) // "1295.25"
c = a.plus(b) // "1306.25"
```
Performance is better if base 10 is NOT specified for decimal values. Only specify base 10 when it is desired that the number of decimal places of the input value be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting.
A BigNumber is immutable in the sense that it is not changed by its methods.
```javascript
0.3 - 0.1 // 0.19999999999999998
x = new BigNumber(0.3)
x.minus(0.1) // "0.2"
x // "0.3"
```
The methods that return a BigNumber can be chained.
```javascript
x.dividedBy(y).plus(z).times(9)
x.times('1.23456780123456789e+9').plus(9876.5432321).dividedBy('4444562598.111772').integerValue()
```
Some of the longer method names have a shorter alias.
```javascript
x.squareRoot().dividedBy(y).exponentiatedBy(3).isEqualTo(x.sqrt().div(y).pow(3)) // true
x.modulo(y).multipliedBy(z).eq(x.mod(y).times(z)) // true
```
As with JavaScript's Number type, there are [`toExponential`](http://mikemcl.github.io/bignumber.js/#toE), [`toFixed`](http://mikemcl.github.io/bignumber.js/#toFix) and [`toPrecision`](http://mikemcl.github.io/bignumber.js/#toP) methods.
```javascript
x = new BigNumber(255.5)
x.toExponential(5) // "2.55500e+2"
x.toFixed(5) // "255.50000"
x.toPrecision(5) // "255.50"
x.toNumber() // 255.5
```
A base can be specified for [`toString`](http://mikemcl.github.io/bignumber.js/#toS). Performance is better if base 10 is NOT specified, i.e. use `toString()` not `toString(10)`. Only specify base 10 when it is desired that the number of decimal places be limited to the current [`DECIMAL_PLACES`](http://mikemcl.github.io/bignumber.js/#decimal-places) setting.
```javascript
x.toString(16) // "ff.8"
```
There is a [`toFormat`](http://mikemcl.github.io/bignumber.js/#toFor) method which may be useful for internationalisation.
```javascript
y = new BigNumber('1234567.898765')
y.toFormat(2) // "1,234,567.90"
```
The maximum number of decimal places of the result of an operation involving division (i.e. a division, square root, base conversion or negative power operation) is set using the `set` or `config` method of the `BigNumber` constructor.
The other arithmetic operations always give the exact result.
```javascript
BigNumber.set({ DECIMAL_PLACES: 10, ROUNDING_MODE: 4 })
x = new BigNumber(2)
y = new BigNumber(3)
z = x.dividedBy(y) // "0.6666666667"
z.squareRoot() // "0.8164965809"
z.exponentiatedBy(-3) // "3.3749999995"
z.toString(2) // "0.1010101011"
z.multipliedBy(z) // "0.44444444448888888889"
z.multipliedBy(z).decimalPlaces(10) // "0.4444444445"
```
There is a [`toFraction`](http://mikemcl.github.io/bignumber.js/#toFr) method with an optional *maximum denominator* argument
```javascript
y = new BigNumber(355)
pi = y.dividedBy(113) // "3.1415929204"
pi.toFraction() // [ "7853982301", "2500000000" ]
pi.toFraction(1000) // [ "355", "113" ]
```
and [`isNaN`](http://mikemcl.github.io/bignumber.js/#isNaN) and [`isFinite`](http://mikemcl.github.io/bignumber.js/#isF) methods, as `NaN` and `Infinity` are valid `BigNumber` values.
```javascript
x = new BigNumber(NaN) // "NaN"
y = new BigNumber(Infinity) // "Infinity"
x.isNaN() && !y.isNaN() && !x.isFinite() && !y.isFinite() // true
```
The value of a BigNumber is stored in a decimal floating point format in terms of a coefficient, exponent and sign.
```javascript
x = new BigNumber(-123.456);
x.c // [ 123, 45600000000000 ] coefficient (i.e. significand)
x.e // 2 exponent
x.s // -1 sign
```
For advanced usage, multiple BigNumber constructors can be created, each with their own independent configuration.
```javascript
// Set DECIMAL_PLACES for the original BigNumber constructor
BigNumber.set({ DECIMAL_PLACES: 10 })
// Create another BigNumber constructor, optionally passing in a configuration object
BN = BigNumber.clone({ DECIMAL_PLACES: 5 })
x = new BigNumber(1)
y = new BN(1)
x.div(3) // '0.3333333333'
y.div(3) // '0.33333'
```
For further information see the [API](http://mikemcl.github.io/bignumber.js/) reference in the *doc* directory.
## Test
The *test/modules* directory contains the test scripts for each method.
The tests can be run with Node.js or a browser. For Node.js use
$ npm test
or
$ node test/test
To test a single method, use, for example
$ node test/methods/toFraction
For the browser, open *test/test.html*.
## Build
For Node, if [uglify-js](https://github.com/mishoo/UglifyJS2) is installed
npm install uglify-js -g
then
npm run build
will create *bignumber.min.js*.
A source map will also be created in the root directory.
## Feedback
Open an issue, or email
Michael
<a href="mailto:M8ch88l@gmail.com">M8ch88l@gmail.com</a>
## Licence
The MIT Licence.
See [LICENCE](https://github.com/MikeMcl/bignumber.js/blob/master/LICENCE).
// Type definitions for bignumber.js >=8.1.0
// Project: https://github.com/MikeMcl/bignumber.js
// Definitions by: Michael Mclaughlin <https://github.com/MikeMcl>
// Definitions: https://github.com/MikeMcl/bignumber.js
// Documentation: http://mikemcl.github.io/bignumber.js/
//
// Exports:
//
// class BigNumber (default export)
// type BigNumber.Constructor
// type BigNumber.ModuloMode
// type BigNumber.RoundingMOde
// type BigNumber.Value
// interface BigNumber.Config
// interface BigNumber.Format
// interface BigNumber.Instance
//
// Example:
//
// import {BigNumber} from "bignumber.js"
// //import BigNumber from "bignumber.js"
//
// let rm: BigNumber.RoundingMode = BigNumber.ROUND_UP;
// let f: BigNumber.Format = { decimalSeparator: ',' };
// let c: BigNumber.Config = { DECIMAL_PLACES: 4, ROUNDING_MODE: rm, FORMAT: f };
// BigNumber.config(c);
//
// let v: BigNumber.Value = '12345.6789';
// let b: BigNumber = new BigNumber(v);
//
// The use of compiler option `--strictNullChecks` is recommended.
export default BigNumber;
export namespace BigNumber {
/** See `BigNumber.config` (alias `BigNumber.set`) and `BigNumber.clone`. */
interface Config {
/**
* An integer, 0 to 1e+9. Default value: 20.
*
* The maximum number of decimal places of the result of operations involving division, i.e.
* division, square root and base conversion operations, and exponentiation when the exponent is
* negative.
*
* ```ts
* BigNumber.config({ DECIMAL_PLACES: 5 })
* BigNumber.set({ DECIMAL_PLACES: 5 })
* ```
*/
DECIMAL_PLACES?: number;
/**
* An integer, 0 to 8. Default value: `BigNumber.ROUND_HALF_UP` (4).
*
* The rounding mode used in operations that involve division (see `DECIMAL_PLACES`) and the
* default rounding mode of the `decimalPlaces`, `precision`, `toExponential`, `toFixed`,
* `toFormat` and `toPrecision` methods.
*
* The modes are available as enumerated properties of the BigNumber constructor.
*
* ```ts
* BigNumber.config({ ROUNDING_MODE: 0 })
* BigNumber.set({ ROUNDING_MODE: BigNumber.ROUND_UP })
* ```
*/
ROUNDING_MODE?: BigNumber.RoundingMode;
/**
* An integer, 0 to 1e+9, or an array, [-1e+9 to 0, 0 to 1e+9].
* Default value: `[-7, 20]`.
*
* The exponent value(s) at which `toString` returns exponential notation.
*
* If a single number is assigned, the value is the exponent magnitude.
*
* If an array of two numbers is assigned then the first number is the negative exponent value at
* and beneath which exponential notation is used, and the second number is the positive exponent
* value at and above which exponential notation is used.
*
* For example, to emulate JavaScript numbers in terms of the exponent values at which they begin
* to use exponential notation, use `[-7, 20]`.
*
* ```ts
* BigNumber.config({ EXPONENTIAL_AT: 2 })
* new BigNumber(12.3) // '12.3' e is only 1
* new BigNumber(123) // '1.23e+2'
* new BigNumber(0.123) // '0.123' e is only -1
* new BigNumber(0.0123) // '1.23e-2'
*
* BigNumber.config({ EXPONENTIAL_AT: [-7, 20] })
* new BigNumber(123456789) // '123456789' e is only 8
* new BigNumber(0.000000123) // '1.23e-7'
*
* // Almost never return exponential notation:
* BigNumber.config({ EXPONENTIAL_AT: 1e+9 })
*
* // Always return exponential notation:
* BigNumber.config({ EXPONENTIAL_AT: 0 })
* ```
*
* Regardless of the value of `EXPONENTIAL_AT`, the `toFixed` method will always return a value in
* normal notation and the `toExponential` method will always return a value in exponential form.
* Calling `toString` with a base argument, e.g. `toString(10)`, will also always return normal
* notation.
*/
EXPONENTIAL_AT?: number | [number, number];
/**
* An integer, magnitude 1 to 1e+9, or an array, [-1e+9 to -1, 1 to 1e+9].
* Default value: `[-1e+9, 1e+9]`.
*
* The exponent value(s) beyond which overflow to Infinity and underflow to zero occurs.
*
* If a single number is assigned, it is the maximum exponent magnitude: values wth a positive
* exponent of greater magnitude become Infinity and those with a negative exponent of greater
* magnitude become zero.
*
* If an array of two numbers is assigned then the first number is the negative exponent limit and
* the second number is the positive exponent limit.
*
* For example, to emulate JavaScript numbers in terms of the exponent values at which they
* become zero and Infinity, use [-324, 308].
*
* ```ts
* BigNumber.config({ RANGE: 500 })
* BigNumber.config().RANGE // [ -500, 500 ]
* new BigNumber('9.999e499') // '9.999e+499'
* new BigNumber('1e500') // 'Infinity'
* new BigNumber('1e-499') // '1e-499'
* new BigNumber('1e-500') // '0'
*
* BigNumber.config({ RANGE: [-3, 4] })
* new BigNumber(99999) // '99999' e is only 4
* new BigNumber(100000) // 'Infinity' e is 5
* new BigNumber(0.001) // '0.01' e is only -3
* new BigNumber(0.0001) // '0' e is -4
* ```
* The largest possible magnitude of a finite BigNumber is 9.999...e+1000000000.
* The smallest possible magnitude of a non-zero BigNumber is 1e-1000000000.
*/
RANGE?: number | [number, number];
/**
* A boolean: `true` or `false`. Default value: `false`.
*
* The value that determines whether cryptographically-secure pseudo-random number generation is
* used. If `CRYPTO` is set to true then the random method will generate random digits using
* `crypto.getRandomValues` in browsers that support it, or `crypto.randomBytes` if using a
* version of Node.js that supports it.
*
* If neither function is supported by the host environment then attempting to set `CRYPTO` to
* `true` will fail and an exception will be thrown.
*
* If `CRYPTO` is `false` then the source of randomness used will be `Math.random` (which is
* assumed to generate at least 30 bits of randomness).
*
* See `BigNumber.random`.
*
* ```ts
* // Node.js
* global.crypto = require('crypto')
*
* BigNumber.config({ CRYPTO: true })
* BigNumber.config().CRYPTO // true
* BigNumber.random() // 0.54340758610486147524
* ```
*/
CRYPTO?: boolean;
/**
* An integer, 0, 1, 3, 6 or 9. Default value: `BigNumber.ROUND_DOWN` (1).
*
* The modulo mode used when calculating the modulus: `a mod n`.
* The quotient, `q = a / n`, is calculated according to the `ROUNDING_MODE` that corresponds to
* the chosen `MODULO_MODE`.
* The remainder, `r`, is calculated as: `r = a - n * q`.
*
* The modes that are most commonly used for the modulus/remainder operation are shown in the
* following table. Although the other rounding modes can be used, they may not give useful
* results.
*
* Property | Value | Description
* :------------------|:------|:------------------------------------------------------------------
* `ROUND_UP` | 0 | The remainder is positive if the dividend is negative.
* `ROUND_DOWN` | 1 | The remainder has the same sign as the dividend.
* | | Uses 'truncating division' and matches JavaScript's `%` operator .
* `ROUND_FLOOR` | 3 | The remainder has the same sign as the divisor.
* | | This matches Python's `%` operator.
* `ROUND_HALF_EVEN` | 6 | The IEEE 754 remainder function.
* `EUCLID` | 9 | The remainder is always positive.
* | | Euclidian division: `q = sign(n) * floor(a / abs(n))`
*
* The rounding/modulo modes are available as enumerated properties of the BigNumber constructor.
*
* See `modulo`.
*
* ```ts
* BigNumber.config({ MODULO_MODE: BigNumber.EUCLID })
* BigNumber.set({ MODULO_MODE: 9 }) // equivalent
* ```
*/
MODULO_MODE?: BigNumber.ModuloMode;
/**
* An integer, 0 to 1e+9. Default value: 0.
*
* The maximum precision, i.e. number of significant digits, of the result of the power operation
* - unless a modulus is specified.
*
* If set to 0, the number of significant digits will not be limited.
*
* See `exponentiatedBy`.
*
* ```ts
* BigNumber.config({ POW_PRECISION: 100 })
* ```
*/
POW_PRECISION?: number;
/**
* An object including any number of the properties shown below.
*
* The object configures the format of the string returned by the `toFormat` method.
* The example below shows the properties of the object that are recognised, and
* their default values.
*
* Unlike the other configuration properties, the values of the properties of the `FORMAT` object
* will not be checked for validity - the existing object will simply be replaced by the object
* that is passed in.
*
* See `toFormat`.
*
* ```ts
* BigNumber.config({
* FORMAT: {
* // string to prepend
* prefix: '',
* // the decimal separator
* decimalSeparator: '.',
* // the grouping separator of the integer part
* groupSeparator: ',',
* // the primary grouping size of the integer part
* groupSize: 3,
* // the secondary grouping size of the integer part
* secondaryGroupSize: 0,
* // the grouping separator of the fraction part
* fractionGroupSeparator: ' ',
* // the grouping size of the fraction part
* fractionGroupSize: 0,
* // string to append
* suffix: ''
* }
* })
* ```
*/
FORMAT?: BigNumber.Format;
/**
* The alphabet used for base conversion. The length of the alphabet corresponds to the maximum
* value of the base argument that can be passed to the BigNumber constructor or `toString`.
*
* Default value: `'0123456789abcdefghijklmnopqrstuvwxyz'`.
*
* There is no maximum length for the alphabet, but it must be at least 2 characters long,
* and it must not contain whitespace or a repeated character, or the sign indicators '+' and
* '-', or the decimal separator '.'.
*
* ```ts
* // duodecimal (base 12)
* BigNumber.config({ ALPHABET: '0123456789TE' })
* x = new BigNumber('T', 12)
* x.toString() // '10'
* x.toString(12) // 'T'
* ```
*/
ALPHABET?: string;
}
/** See `FORMAT` and `toFormat`. */
interface Format {
/** The string to prepend. */
prefix?: string;
/** The decimal separator. */
decimalSeparator?: string;
/** The grouping separator of the integer part. */
groupSeparator?: string;
/** The primary grouping size of the integer part. */
groupSize?: number;
/** The secondary grouping size of the integer part. */
secondaryGroupSize?: number;
/** The grouping separator of the fraction part. */
fractionGroupSeparator?: string;
/** The grouping size of the fraction part. */
fractionGroupSize?: number;
/** The string to append. */
suffix?: string;
}
interface Instance {
/** The coefficient of the value of this BigNumber, an array of base 1e14 integer numbers, or null. */
readonly c: number[] | null;
/** The exponent of the value of this BigNumber, an integer number, -1000000000 to 1000000000, or null. */
readonly e: number | null;
/** The sign of the value of this BigNumber, -1, 1, or null. */
readonly s: number | null;
[key: string]: any;
}
type Constructor = typeof BigNumber;
type ModuloMode = 0 | 1 | 3 | 6 | 9;
type RoundingMode = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
type Value = string | number | Instance;
}
export declare class BigNumber implements BigNumber.Instance {
/** Used internally to identify a BigNumber instance. */
private readonly _isBigNumber: true;
/** The coefficient of the value of this BigNumber, an array of base 1e14 integer numbers, or null. */
readonly c: number[] | null;
/** The exponent of the value of this BigNumber, an integer number, -1000000000 to 1000000000, or null. */
readonly e: number | null;
/** The sign of the value of this BigNumber, -1, 1, or null. */
readonly s: number | null;
/**
* Returns a new instance of a BigNumber object with value `n`, where `n` is a numeric value in
* the specified `base`, or base 10 if `base` is omitted or is `null` or `undefined`.
*
* ```ts
* x = new BigNumber(123.4567) // '123.4567'
* // 'new' is optional
* y = BigNumber(x) // '123.4567'
* ```
*
* If `n` is a base 10 value it can be in normal (fixed-point) or exponential notation.
* Values in other bases must be in normal notation. Values in any base can have fraction digits,
* i.e. digits after the decimal point.
*
* ```ts
* new BigNumber(43210) // '43210'
* new BigNumber('4.321e+4') // '43210'
* new BigNumber('-735.0918e-430') // '-7.350918e-428'
* new BigNumber('123412421.234324', 5) // '607236.557696'
* ```
*
* Signed `0`, signed `Infinity` and `NaN` are supported.
*
* ```ts
* new BigNumber('-Infinity') // '-Infinity'
* new BigNumber(NaN) // 'NaN'
* new BigNumber(-0) // '0'
* new BigNumber('.5') // '0.5'
* new BigNumber('+2') // '2'
* ```
*
* String values in hexadecimal literal form, e.g. `'0xff'`, are valid, as are string values with
* the octal and binary prefixs `'0o'` and `'0b'`. String values in octal literal form without the
* prefix will be interpreted as decimals, e.g. `'011'` is interpreted as 11, not 9.
*
* ```ts
* new BigNumber(-10110100.1, 2) // '-180.5'
* new BigNumber('-0b10110100.1') // '-180.5'
* new BigNumber('ff.8', 16) // '255.5'
* new BigNumber('0xff.8') // '255.5'
* ```
*
* If a base is specified, `n` is rounded according to the current `DECIMAL_PLACES` and
* `ROUNDING_MODE` settings. This includes base 10, so don't include a `base` parameter for decimal
* values unless this behaviour is desired.
*
* ```ts
* BigNumber.config({ DECIMAL_PLACES: 5 })
* new BigNumber(1.23456789) // '1.23456789'
* new BigNumber(1.23456789, 10) // '1.23457'
* ```
*
* An error is thrown if `base` is invalid.
*
* There is no limit to the number of digits of a value of type string (other than that of
* JavaScript's maximum array size). See `RANGE` to set the maximum and minimum possible exponent
* value of a BigNumber.
*
* ```ts
* new BigNumber('5032485723458348569331745.33434346346912144534543')
* new BigNumber('4.321e10000000')
* ```
*
* BigNumber `NaN` is returned if `n` is invalid (unless `BigNumber.DEBUG` is `true`, see below).
*
* ```ts
* new BigNumber('.1*') // 'NaN'
* new BigNumber('blurgh') // 'NaN'
* new BigNumber(9, 2) // 'NaN'
* ```
*
* To aid in debugging, if `BigNumber.DEBUG` is `true` then an error will be thrown on an
* invalid `n`. An error will also be thrown if `n` is of type number with more than 15
* significant digits, as calling `toString` or `valueOf` on these numbers may not result in the
* intended value.
*
* ```ts
* console.log(823456789123456.3) // 823456789123456.2
* new BigNumber(823456789123456.3) // '823456789123456.2'
* BigNumber.DEBUG = true
* // 'Error: Number has more than 15 significant digits'
* new BigNumber(823456789123456.3)
* // 'Error: Not a base 2 number'
* new BigNumber(9, 2)
* ```
*
* A BigNumber can also be created from an object literal.
* Use `isBigNumber` to check that it is well-formed.
*
* ```ts
* new BigNumber({ s: 1, e: 2, c: [ 777, 12300000000000 ], _isBigNumber: true }) // '777.123'
* ```
*
* @param n A numeric value.
* @param base The base of `n`, integer, 2 to 36 (or `ALPHABET.length`, see `ALPHABET`).
*/
constructor(n: BigNumber.Value, base?: number);
/**
* Returns a BigNumber whose value is the absolute value, i.e. the magnitude, of the value of this
* BigNumber.
*
* The return value is always exact and unrounded.
*
* ```ts
* x = new BigNumber(-0.8)
* x.absoluteValue() // '0.8'
* ```
*/
absoluteValue(): BigNumber;
/**
* Returns a BigNumber whose value is the absolute value, i.e. the magnitude, of the value of this
* BigNumber.
*
* The return value is always exact and unrounded.
*
* ```ts
* x = new BigNumber(-0.8)
* x.abs() // '0.8'
* ```
*/
abs(): BigNumber;
/**
* Returns | |
* :-------:|:--------------------------------------------------------------|
* 1 | If the value of this BigNumber is greater than the value of `n`
* -1 | If the value of this BigNumber is less than the value of `n`
* 0 | If this BigNumber and `n` have the same value
* `null` | If the value of either this BigNumber or `n` is `NaN`
*
* ```ts
*
* x = new BigNumber(Infinity)
* y = new BigNumber(5)
* x.comparedTo(y) // 1
* x.comparedTo(x.minus(1)) // 0
* y.comparedTo(NaN) // null
* y.comparedTo('110', 2) // -1
* ```
* @param n A numeric value.
* @param [base] The base of n.
*/
comparedTo(n: BigNumber.Value, base?: number): number;
/**
* Returns a BigNumber whose value is the value of this BigNumber rounded by rounding mode
* `roundingMode` to a maximum of `decimalPlaces` decimal places.
*
* If `decimalPlaces` is omitted, or is `null` or `undefined`, the return value is the number of
* decimal places of the value of this BigNumber, or `null` if the value of this BigNumber is
* ±`Infinity` or `NaN`.
*
* If `roundingMode` is omitted, or is `null` or `undefined`, `ROUNDING_MODE` is used.
*
* Throws if `decimalPlaces` or `roundingMode` is invalid.
*
* ```ts
* x = new BigNumber(1234.56)
* x.decimalPlaces() // 2
* x.decimalPlaces(1) // '1234.6'
* x.decimalPlaces(2) // '1234.56'
* x.decimalPlaces(10) // '1234.56'
* x.decimalPlaces(0, 1) // '1234'
* x.decimalPlaces(0, 6) // '1235'
* x.decimalPlaces(1, 1) // '1234.5'
* x.decimalPlaces(1, BigNumber.ROUND_HALF_EVEN) // '1234.6'
* x // '1234.56'
* y = new BigNumber('9.9e-101')
* y.decimalPlaces() // 102
* ```
*
* @param [decimalPlaces] Decimal places, integer, 0 to 1e+9.
* @param [roundingMode] Rounding mode, integer, 0 to 8.
*/
decimalPlaces(): number;
decimalPlaces(decimalPlaces: number, roundingMode?: BigNumber.RoundingMode): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber rounded by rounding mode
* `roundingMode` to a maximum of `decimalPlaces` decimal places.
*
* If `decimalPlaces` is omitted, or is `null` or `undefined`, the return value is the number of
* decimal places of the value of this BigNumber, or `null` if the value of this BigNumber is
* ±`Infinity` or `NaN`.
*
* If `roundingMode` is omitted, or is `null` or `undefined`, `ROUNDING_MODE` is used.
*
* Throws if `decimalPlaces` or `roundingMode` is invalid.
*
* ```ts
* x = new BigNumber(1234.56)
* x.dp() // 2
* x.dp(1) // '1234.6'
* x.dp(2) // '1234.56'
* x.dp(10) // '1234.56'
* x.dp(0, 1) // '1234'
* x.dp(0, 6) // '1235'
* x.dp(1, 1) // '1234.5'
* x.dp(1, BigNumber.ROUND_HALF_EVEN) // '1234.6'
* x // '1234.56'
* y = new BigNumber('9.9e-101')
* y.dp() // 102
* ```
*
* @param [decimalPlaces] Decimal places, integer, 0 to 1e+9.
* @param [roundingMode] Rounding mode, integer, 0 to 8.
*/
dp(): number;
dp(decimalPlaces: number, roundingMode?: BigNumber.RoundingMode): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber divided by `n`, rounded
* according to the current `DECIMAL_PLACES` and `ROUNDING_MODE` settings.
*
* ```ts
* x = new BigNumber(355)
* y = new BigNumber(113)
* x.dividedBy(y) // '3.14159292035398230088'
* x.dividedBy(5) // '71'
* x.dividedBy(47, 16) // '5'
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
dividedBy(n: BigNumber.Value, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber divided by `n`, rounded
* according to the current `DECIMAL_PLACES` and `ROUNDING_MODE` settings.
*
* ```ts
* x = new BigNumber(355)
* y = new BigNumber(113)
* x.div(y) // '3.14159292035398230088'
* x.div(5) // '71'
* x.div(47, 16) // '5'
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
div(n: BigNumber.Value, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the integer part of dividing the value of this BigNumber by
* `n`.
*
* ```ts
* x = new BigNumber(5)
* y = new BigNumber(3)
* x.dividedToIntegerBy(y) // '1'
* x.dividedToIntegerBy(0.7) // '7'
* x.dividedToIntegerBy('0.f', 16) // '5'
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
dividedToIntegerBy(n: BigNumber.Value, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the integer part of dividing the value of this BigNumber by
* `n`.
*
* ```ts
* x = new BigNumber(5)
* y = new BigNumber(3)
* x.idiv(y) // '1'
* x.idiv(0.7) // '7'
* x.idiv('0.f', 16) // '5'
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
idiv(n: BigNumber.Value, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber exponentiated by `n`, i.e.
* raised to the power `n`, and optionally modulo a modulus `m`.
*
* If `n` is negative the result is rounded according to the current `DECIMAL_PLACES` and
* `ROUNDING_MODE` settings.
*
* As the number of digits of the result of the power operation can grow so large so quickly,
* e.g. 123.456**10000 has over 50000 digits, the number of significant digits calculated is
* limited to the value of the `POW_PRECISION` setting (unless a modulus `m` is specified).
*
* By default `POW_PRECISION` is set to 0. This means that an unlimited number of significant
* digits will be calculated, and that the method's performance will decrease dramatically for
* larger exponents.
*
* If `m` is specified and the value of `m`, `n` and this BigNumber are integers and `n` is
* positive, then a fast modular exponentiation algorithm is used, otherwise the operation will
* be performed as `x.exponentiatedBy(n).modulo(m)` with a `POW_PRECISION` of 0.
*
* Throws if `n` is not an integer.
*
* ```ts
* Math.pow(0.7, 2) // 0.48999999999999994
* x = new BigNumber(0.7)
* x.exponentiatedBy(2) // '0.49'
* BigNumber(3).exponentiatedBy(-2) // '0.11111111111111111111'
* ```
*
* @param n The exponent, an integer.
* @param [m] The modulus.
*/
exponentiatedBy(n: BigNumber.Value, m?: BigNumber.Value): BigNumber;
exponentiatedBy(n: number, m?: BigNumber.Value): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber exponentiated by `n`, i.e.
* raised to the power `n`, and optionally modulo a modulus `m`.
*
* If `n` is negative the result is rounded according to the current `DECIMAL_PLACES` and
* `ROUNDING_MODE` settings.
*
* As the number of digits of the result of the power operation can grow so large so quickly,
* e.g. 123.456**10000 has over 50000 digits, the number of significant digits calculated is
* limited to the value of the `POW_PRECISION` setting (unless a modulus `m` is specified).
*
* By default `POW_PRECISION` is set to 0. This means that an unlimited number of significant
* digits will be calculated, and that the method's performance will decrease dramatically for
* larger exponents.
*
* If `m` is specified and the value of `m`, `n` and this BigNumber are integers and `n` is
* positive, then a fast modular exponentiation algorithm is used, otherwise the operation will
* be performed as `x.pow(n).modulo(m)` with a `POW_PRECISION` of 0.
*
* Throws if `n` is not an integer.
*
* ```ts
* Math.pow(0.7, 2) // 0.48999999999999994
* x = new BigNumber(0.7)
* x.pow(2) // '0.49'
* BigNumber(3).pow(-2) // '0.11111111111111111111'
* ```
*
* @param n The exponent, an integer.
* @param [m] The modulus.
*/
pow(n: BigNumber.Value, m?: BigNumber.Value): BigNumber;
pow(n: number, m?: BigNumber.Value): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber rounded to an integer using
* rounding mode `rm`.
*
* If `rm` is omitted, or is `null` or `undefined`, `ROUNDING_MODE` is used.
*
* Throws if `rm` is invalid.
*
* ```ts
* x = new BigNumber(123.456)
* x.integerValue() // '123'
* x.integerValue(BigNumber.ROUND_CEIL) // '124'
* y = new BigNumber(-12.7)
* y.integerValue() // '-13'
* x.integerValue(BigNumber.ROUND_DOWN) // '-12'
* ```
*
* @param {BigNumber.RoundingMode} [rm] The roundng mode, an integer, 0 to 8.
*/
integerValue(rm?: BigNumber.RoundingMode): BigNumber;
/**
* Returns `true` if the value of this BigNumber is equal to the value of `n`, otherwise returns
* `false`.
*
* As with JavaScript, `NaN` does not equal `NaN`.
*
* ```ts
* 0 === 1e-324 // true
* x = new BigNumber(0)
* x.isEqualTo('1e-324') // false
* BigNumber(-0).isEqualTo(x) // true ( -0 === 0 )
* BigNumber(255).isEqualTo('ff', 16) // true
*
* y = new BigNumber(NaN)
* y.isEqualTo(NaN) // false
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
isEqualTo(n: BigNumber.Value, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is equal to the value of `n`, otherwise returns
* `false`.
*
* As with JavaScript, `NaN` does not equal `NaN`.
*
* ```ts
* 0 === 1e-324 // true
* x = new BigNumber(0)
* x.eq('1e-324') // false
* BigNumber(-0).eq(x) // true ( -0 === 0 )
* BigNumber(255).eq('ff', 16) // true
*
* y = new BigNumber(NaN)
* y.eq(NaN) // false
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
eq(n: BigNumber.Value, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is a finite number, otherwise returns `false`.
*
* The only possible non-finite values of a BigNumber are `NaN`, `Infinity` and `-Infinity`.
*
* ```ts
* x = new BigNumber(1)
* x.isFinite() // true
* y = new BigNumber(Infinity)
* y.isFinite() // false
* ```
*/
isFinite(): boolean;
/**
* Returns `true` if the value of this BigNumber is greater than the value of `n`, otherwise
* returns `false`.
*
* ```ts
* 0.1 > (0.3 - 0.2) // true
* x = new BigNumber(0.1)
* x.isGreaterThan(BigNumber(0.3).minus(0.2)) // false
* BigNumber(0).isGreaterThan(x) // false
* BigNumber(11, 3).isGreaterThan(11.1, 2) // true
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
isGreaterThan(n: BigNumber.Value, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is greater than the value of `n`, otherwise
* returns `false`.
*
* ```ts
* 0.1 > (0.3 - 0 // true
* x = new BigNumber(0.1)
* x.gt(BigNumber(0.3).minus(0.2)) // false
* BigNumber(0).gt(x) // false
* BigNumber(11, 3).gt(11.1, 2) // true
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
gt(n: BigNumber.Value, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is greater than or equal to the value of `n`,
* otherwise returns `false`.
*
* ```ts
* (0.3 - 0.2) >= 0.1 // false
* x = new BigNumber(0.3).minus(0.2)
* x.isGreaterThanOrEqualTo(0.1) // true
* BigNumber(1).isGreaterThanOrEqualTo(x) // true
* BigNumber(10, 18).isGreaterThanOrEqualTo('i', 36) // true
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
isGreaterThanOrEqualTo(n: BigNumber.Value, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is greater than or equal to the value of `n`,
* otherwise returns `false`.
*
* ```ts
* (0.3 - 0.2) >= 0.1 // false
* x = new BigNumber(0.3).minus(0.2)
* x.gte(0.1) // true
* BigNumber(1).gte(x) // true
* BigNumber(10, 18).gte('i', 36) // true
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
gte(n: BigNumber.Value, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is an integer, otherwise returns `false`.
*
* ```ts
* x = new BigNumber(1)
* x.isInteger() // true
* y = new BigNumber(123.456)
* y.isInteger() // false
* ```
*/
isInteger(): boolean;
/**
* Returns `true` if the value of this BigNumber is less than the value of `n`, otherwise returns
* `false`.
*
* ```ts
* (0.3 - 0.2) < 0.1 // true
* x = new BigNumber(0.3).minus(0.2)
* x.isLessThan(0.1) // false
* BigNumber(0).isLessThan(x) // true
* BigNumber(11.1, 2).isLessThan(11, 3) // true
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
isLessThan(n: BigNumber.Value, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is less than the value of `n`, otherwise returns
* `false`.
*
* ```ts
* (0.3 - 0.2) < 0.1 // true
* x = new BigNumber(0.3).minus(0.2)
* x.lt(0.1) // false
* BigNumber(0).lt(x) // true
* BigNumber(11.1, 2).lt(11, 3) // true
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
lt(n: BigNumber.Value, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is less than or equal to the value of `n`,
* otherwise returns `false`.
*
* ```ts
* 0.1 <= (0.3 - 0.2) // false
* x = new BigNumber(0.1)
* x.isLessThanOrEqualTo(BigNumber(0.3).minus(0.2)) // true
* BigNumber(-1).isLessThanOrEqualTo(x) // true
* BigNumber(10, 18).isLessThanOrEqualTo('i', 36) // true
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
isLessThanOrEqualTo(n: BigNumber.Value, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is less than or equal to the value of `n`,
* otherwise returns `false`.
*
* ```ts
* 0.1 <= (0.3 - 0.2) // false
* x = new BigNumber(0.1)
* x.lte(BigNumber(0.3).minus(0.2)) // true
* BigNumber(-1).lte(x) // true
* BigNumber(10, 18).lte('i', 36) // true
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
lte(n: BigNumber.Value, base?: number): boolean;
/**
* Returns `true` if the value of this BigNumber is `NaN`, otherwise returns `false`.
*
* ```ts
* x = new BigNumber(NaN)
* x.isNaN() // true
* y = new BigNumber('Infinity')
* y.isNaN() // false
* ```
*/
isNaN(): boolean;
/**
* Returns `true` if the value of this BigNumber is negative, otherwise returns `false`.
*
* ```ts
* x = new BigNumber(-0)
* x.isNegative() // true
* y = new BigNumber(2)
* y.isNegative() // false
* ```
*/
isNegative(): boolean;
/**
* Returns `true` if the value of this BigNumber is positive, otherwise returns `false`.
*
* ```ts
* x = new BigNumber(-0)
* x.isPositive() // false
* y = new BigNumber(2)
* y.isPositive() // true
* ```
*/
isPositive(): boolean;
/**
* Returns `true` if the value of this BigNumber is zero or minus zero, otherwise returns `false`.
*
* ```ts
* x = new BigNumber(-0)
* x.isZero() // true
* ```
*/
isZero(): boolean;
/**
* Returns a BigNumber whose value is the value of this BigNumber minus `n`.
*
* The return value is always exact and unrounded.
*
* ```ts
* 0.3 - 0.1 // 0.19999999999999998
* x = new BigNumber(0.3)
* x.minus(0.1) // '0.2'
* x.minus(0.6, 20) // '0'
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
minus(n: BigNumber.Value, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber modulo `n`, i.e. the integer
* remainder of dividing this BigNumber by `n`.
*
* The value returned, and in particular its sign, is dependent on the value of the `MODULO_MODE`
* setting of this BigNumber constructor. If it is 1 (default value), the result will have the
* same sign as this BigNumber, and it will match that of Javascript's `%` operator (within the
* limits of double precision) and BigDecimal's `remainder` method.
*
* The return value is always exact and unrounded.
*
* See `MODULO_MODE` for a description of the other modulo modes.
*
* ```ts
* 1 % 0.9 // 0.09999999999999998
* x = new BigNumber(1)
* x.modulo(0.9) // '0.1'
* y = new BigNumber(33)
* y.modulo('a', 33) // '3'
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
modulo(n: BigNumber.Value, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber modulo `n`, i.e. the integer
* remainder of dividing this BigNumber by `n`.
*
* The value returned, and in particular its sign, is dependent on the value of the `MODULO_MODE`
* setting of this BigNumber constructor. If it is 1 (default value), the result will have the
* same sign as this BigNumber, and it will match that of Javascript's `%` operator (within the
* limits of double precision) and BigDecimal's `remainder` method.
*
* The return value is always exact and unrounded.
*
* See `MODULO_MODE` for a description of the other modulo modes.
*
* ```ts
* 1 % 0.9 // 0.09999999999999998
* x = new BigNumber(1)
* x.mod(0.9) // '0.1'
* y = new BigNumber(33)
* y.mod('a', 33) // '3'
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
mod(n: BigNumber.Value, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber multiplied by `n`.
*
* The return value is always exact and unrounded.
*
* ```ts
* 0.6 * 3 // 1.7999999999999998
* x = new BigNumber(0.6)
* y = x.multipliedBy(3) // '1.8'
* BigNumber('7e+500').multipliedBy(y) // '1.26e+501'
* x.multipliedBy('-a', 16) // '-6'
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
multipliedBy(n: BigNumber.Value, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber multiplied by `n`.
*
* The return value is always exact and unrounded.
*
* ```ts
* 0.6 * 3 // 1.7999999999999998
* x = new BigNumber(0.6)
* y = x.times(3) // '1.8'
* BigNumber('7e+500').times(y) // '1.26e+501'
* x.times('-a', 16) // '-6'
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
times(n: BigNumber.Value, base?: number): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber negated, i.e. multiplied by -1.
*
* ```ts
* x = new BigNumber(1.8)
* x.negated() // '-1.8'
* y = new BigNumber(-1.3)
* y.negated() // '1.3'
* ```
*/
negated(): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber plus `n`.
*
* The return value is always exact and unrounded.
*
* ```ts
* 0.1 + 0.2 // 0.30000000000000004
* x = new BigNumber(0.1)
* y = x.plus(0.2) // '0.3'
* BigNumber(0.7).plus(x).plus(y) // '1'
* x.plus('0.1', 8) // '0.225'
* ```
*
* @param n A numeric value.
* @param [base] The base of n.
*/
plus(n: BigNumber.Value, base?: number): BigNumber;
/**
* Returns the number of significant digits of the value of this BigNumber, or `null` if the value
* of this BigNumber is ±`Infinity` or `NaN`.
*
* If `includeZeros` is true then any trailing zeros of the integer part of the value of this
* BigNumber are counted as significant digits, otherwise they are not.
*
* Throws if `includeZeros` is invalid.
*
* ```ts
* x = new BigNumber(9876.54321)
* x.precision() // 9
* y = new BigNumber(987000)
* y.precision(false) // 3
* y.precision(true) // 6
* ```
*
* @param [includeZeros] Whether to include integer trailing zeros in the significant digit count.
*/
precision(includeZeros?: boolean): number;
/**
* Returns a BigNumber whose value is the value of this BigNumber rounded to a precision of
* `significantDigits` significant digits using rounding mode `roundingMode`.
*
* If `roundingMode` is omitted or is `null` or `undefined`, `ROUNDING_MODE` will be used.
*
* Throws if `significantDigits` or `roundingMode` is invalid.
*
* ```ts
* x = new BigNumber(9876.54321)
* x.precision(6) // '9876.54'
* x.precision(6, BigNumber.ROUND_UP) // '9876.55'
* x.precision(2) // '9900'
* x.precision(2, 1) // '9800'
* x // '9876.54321'
* ```
*
* @param significantDigits Significant digits, integer, 1 to 1e+9.
* @param [roundingMode] Rounding mode, integer, 0 to 8.
*/
precision(significantDigits: number, roundingMode?: BigNumber.RoundingMode): BigNumber;
/**
* Returns the number of significant digits of the value of this BigNumber,
* or `null` if the value of this BigNumber is ±`Infinity` or `NaN`.
*
* If `includeZeros` is true then any trailing zeros of the integer part of
* the value of this BigNumber are counted as significant digits, otherwise
* they are not.
*
* Throws if `includeZeros` is invalid.
*
* ```ts
* x = new BigNumber(9876.54321)
* x.sd() // 9
* y = new BigNumber(987000)
* y.sd(false) // 3
* y.sd(true) // 6
* ```
*
* @param [includeZeros] Whether to include integer trailing zeros in the significant digit count.
*/
sd(includeZeros?: boolean): number;
/**
* Returns a BigNumber whose value is the value of this BigNumber rounded to a precision of
* `significantDigits` significant digits using rounding mode `roundingMode`.
*
* If `roundingMode` is omitted or is `null` or `undefined`, `ROUNDING_MODE` will be used.
*
* Throws if `significantDigits` or `roundingMode` is invalid.
*
* ```ts
* x = new BigNumber(9876.54321)
* x.sd(6) // '9876.54'
* x.sd(6, BigNumber.ROUND_UP) // '9876.55'
* x.sd(2) // '9900'
* x.sd(2, 1) // '9800'
* x // '9876.54321'
* ```
*
* @param significantDigits Significant digits, integer, 1 to 1e+9.
* @param [roundingMode] Rounding mode, integer, 0 to 8.
*/
sd(significantDigits: number, roundingMode?: BigNumber.RoundingMode): BigNumber;
/**
* Returns a BigNumber whose value is the value of this BigNumber shifted by `n` places.
*
* The shift is of the decimal point, i.e. of powers of ten, and is to the left if `n` is negative
* or to the right if `n` is positive.
*
* The return value is always exact and unrounded.
*
* Throws if `n` is invalid.
*
* ```ts
* x = new BigNumber(1.23)
* x.shiftedBy(3) // '1230'
* x.shiftedBy(-3) // '0.00123'
* ```
*
* @param n The shift value, integer, -9007199254740991 to 9007199254740991.
*/
shiftedBy(n: number): BigNumber;
/**
* Returns a BigNumber whose value is the square root of the value of this BigNumber, rounded
* according to the current `DECIMAL_PLACES` and `ROUNDING_MODE` settings.
*
* The return value will be correctly rounded, i.e. rounded as if the result was first calculated
* to an infinite number of correct digits before rounding.
*
* ```ts
* x = new BigNumber(16)
* x.squareRoot() // '4'
* y = new BigNumber(3)
* y.squareRoot() // '1.73205080756887729353'
* ```
*/
squareRoot(): BigNumber;
/**
* Returns a BigNumber whose value is the square root of the value of this BigNumber, rounded
* according to the current `DECIMAL_PLACES` and `ROUNDING_MODE` settings.
*
* The return value will be correctly rounded, i.e. rounded as if the result was first calculated
* to an infinite number of correct digits before rounding.
*
* ```ts
* x = new BigNumber(16)
* x.sqrt() // '4'
* y = new BigNumber(3)
* y.sqrt() // '1.73205080756887729353'
* ```
*/
sqrt(): BigNumber;
/**
* Returns a string representing the value of this BigNumber in exponential notation rounded using
* rounding mode `roundingMode` to `decimalPlaces` decimal places, i.e with one digit before the
* decimal point and `decimalPlaces` digits after it.
*
* If the value of this BigNumber in exponential notation has fewer than `decimalPlaces` fraction
* digits, the return value will be appended with zeros accordingly.
*
* If `decimalPlaces` is omitted, or is `null` or `undefined`, the number of digits after the
* decimal point defaults to the minimum number of digits necessary to represent the value
* exactly.
*
* If `roundingMode` is omitted or is `null` or `undefined`, `ROUNDING_MODE` is used.
*
* Throws if `decimalPlaces` or `roundingMode` is invalid.
*
* ```ts
* x = 45.6
* y = new BigNumber(x)
* x.toExponential() // '4.56e+1'
* y.toExponential() // '4.56e+1'
* x.toExponential(0) // '5e+1'
* y.toExponential(0) // '5e+1'
* x.toExponential(1) // '4.6e+1'
* y.toExponential(1) // '4.6e+1'
* y.toExponential(1, 1) // '4.5e+1' (ROUND_DOWN)
* x.toExponential(3) // '4.560e+1'
* y.toExponential(3) // '4.560e+1'
* ```
*
* @param [decimalPlaces] Decimal places, integer, 0 to 1e+9.
* @param [roundingMode] Rounding mode, integer, 0 to 8.
*/
toExponential(decimalPlaces: number, roundingMode?: BigNumber.RoundingMode): string;
toExponential(): string;
/**
* Returns a string representing the value of this BigNumber in normal (fixed-point) notation
* rounded to `decimalPlaces` decimal places using rounding mode `roundingMode`.
*
* If the value of this BigNumber in normal notation has fewer than `decimalPlaces` fraction
* digits, the return value will be appended with zeros accordingly.
*
* Unlike `Number.prototype.toFixed`, which returns exponential notation if a number is greater or
* equal to 10**21, this method will always return normal notation.
*
* If `decimalPlaces` is omitted or is `null` or `undefined`, the return value will be unrounded
* and in normal notation. This is also unlike `Number.prototype.toFixed`, which returns the value
* to zero decimal places. It is useful when normal notation is required and the current
* `EXPONENTIAL_AT` setting causes `toString` to return exponential notation.
*
* If `roundingMode` is omitted or is `null` or `undefined`, `ROUNDING_MODE` is used.
*
* Throws if `decimalPlaces` or `roundingMode` is invalid.
*
* ```ts
* x = 3.456
* y = new BigNumber(x)
* x.toFixed() // '3'
* y.toFixed() // '3.456'
* y.toFixed(0) // '3'
* x.toFixed(2) // '3.46'
* y.toFixed(2) // '3.46'
* y.toFixed(2, 1) // '3.45' (ROUND_DOWN)
* x.toFixed(5) // '3.45600'
* y.toFixed(5) // '3.45600'
* ```
*
* @param [decimalPlaces] Decimal places, integer, 0 to 1e+9.
* @param [roundingMode] Rounding mode, integer, 0 to 8.
*/
toFixed(decimalPlaces: number, roundingMode?: BigNumber.RoundingMode): string;
toFixed(): string;
/**
* Returns a string representing the value of this BigNumber in normal (fixed-point) notation
* rounded to `decimalPlaces` decimal places using rounding mode `roundingMode`, and formatted
* according to the properties of the `format` or `FORMAT` object.
*
* The formatting object may contain some or all of the properties shown in the examples below.
*
* If `decimalPlaces` is omitted or is `null` or `undefined`, then the return value is not
* rounded to a fixed number of decimal places.
*
* If `roundingMode` is omitted or is `null` or `undefined`, `ROUNDING_MODE` is used.
*
* If `format` is omitted or is `null` or `undefined`, `FORMAT` is used.
*
* Throws if `decimalPlaces`, `roundingMode`, or `format` is invalid.
*
* ```ts
* fmt = {
* decimalSeparator: '.',
* groupSeparator: ',',
* groupSize: 3,
* secondaryGroupSize: 0,
* fractionGroupSeparator: ' ',
* fractionGroupSize: 0
* }
*
* x = new BigNumber('123456789.123456789')
*
* // Set the global formatting options
* BigNumber.config({ FORMAT: fmt })
*
* x.toFormat() // '123,456,789.123456789'
* x.toFormat(3) // '123,456,789.123'
*
* // If a reference to the object assigned to FORMAT has been retained,
* // the format properties can be changed directly
* fmt.groupSeparator = ' '
* fmt.fractionGroupSize = 5
* x.toFormat() // '123 456 789.12345 6789'
*
* // Alternatively, pass the formatting options as an argument
* fmt = {
* decimalSeparator: ',',
* groupSeparator: '.',
* groupSize: 3,
* secondaryGroupSize: 2
* }
*
* x.toFormat() // '123 456 789.12345 6789'
* x.toFormat(fmt) // '12.34.56.789,123456789'
* x.toFormat(2, fmt) // '12.34.56.789,12'
* x.toFormat(3, BigNumber.ROUND_UP, fmt) // '12.34.56.789,124'
* ```
*
* @param [decimalPlaces] Decimal places, integer, 0 to 1e+9.
* @param [roundingMode] Rounding mode, integer, 0 to 8.
* @param [format] Formatting options object. See `BigNumber.Format`.
*/
toFormat(decimalPlaces: number, roundingMode: BigNumber.RoundingMode, format?: BigNumber.Format): string;
toFormat(decimalPlaces: number, roundingMode?: BigNumber.RoundingMode): string;
toFormat(decimalPlaces?: number): string;
toFormat(decimalPlaces: number, format: BigNumber.Format): string;
toFormat(format: BigNumber.Format): string;
/**
* Returns an array of two BigNumbers representing the value of this BigNumber as a simple
* fraction with an integer numerator and an integer denominator.
* The denominator will be a positive non-zero value less than or equal to `max_denominator`.
* If a maximum denominator, `max_denominator`, is not specified, or is `null` or `undefined`, the
* denominator will be the lowest value necessary to represent the number exactly.
*
* Throws if `max_denominator` is invalid.
*
* ```ts
* x = new BigNumber(1.75)
* x.toFraction() // '7, 4'
*
* pi = new BigNumber('3.14159265358')
* pi.toFraction() // '157079632679,50000000000'
* pi.toFraction(100000) // '312689, 99532'
* pi.toFraction(10000) // '355, 113'
* pi.toFraction(100) // '311, 99'
* pi.toFraction(10) // '22, 7'
* pi.toFraction(1) // '3, 1'
* ```
*
* @param [max_denominator] The maximum denominator, integer > 0, or Infinity.
*/
toFraction(max_denominator?: BigNumber.Value): [BigNumber, BigNumber];
/** As `valueOf`. */
toJSON(): string;
/**
* Returns the value of this BigNumber as a JavaScript primitive number.
*
* Using the unary plus operator gives the same result.
*
* ```ts
* x = new BigNumber(456.789)
* x.toNumber() // 456.789
* +x // 456.789
*
* y = new BigNumber('45987349857634085409857349856430985')
* y.toNumber() // 4.598734985763409e+34
*
* z = new BigNumber(-0)
* 1 / z.toNumber() // -Infinity
* 1 / +z // -Infinity
* ```
*/
toNumber(): number;
/**
* Returns a string representing the value of this BigNumber rounded to `significantDigits`
* significant digits using rounding mode `roundingMode`.
*
* If `significantDigits` is less than the number of digits necessary to represent the integer
* part of the value in normal (fixed-point) notation, then exponential notation is used.
*
* If `significantDigits` is omitted, or is `null` or `undefined`, then the return value is the
* same as `n.toString()`.
*
* If `roundingMode` is omitted or is `null` or `undefined`, `ROUNDING_MODE` is used.
*
* Throws if `significantDigits` or `roundingMode` is invalid.
*
* ```ts
* x = 45.6
* y = new BigNumber(x)
* x.toPrecision() // '45.6'
* y.toPrecision() // '45.6'
* x.toPrecision(1) // '5e+1'
* y.toPrecision(1) // '5e+1'
* y.toPrecision(2, 0) // '4.6e+1' (ROUND_UP)
* y.toPrecision(2, 1) // '4.5e+1' (ROUND_DOWN)
* x.toPrecision(5) // '45.600'
* y.toPrecision(5) // '45.600'
* ```
*
* @param [significantDigits] Significant digits, integer, 1 to 1e+9.
* @param [roundingMode] Rounding mode, integer 0 to 8.
*/
toPrecision(significantDigits: number, roundingMode?: BigNumber.RoundingMode): string;
toPrecision(): string;
/**
* Returns a string representing the value of this BigNumber in base `base`, or base 10 if `base`
* is omitted or is `null` or `undefined`.
*
* For bases above 10, and using the default base conversion alphabet (see `ALPHABET`), values
* from 10 to 35 are represented by a-z (the same as `Number.prototype.toString`).
*
* If a base is specified the value is rounded according to the current `DECIMAL_PLACES` and
* `ROUNDING_MODE` settings, otherwise it is not.
*
* If a base is not specified, and this BigNumber has a positive exponent that is equal to or
* greater than the positive component of the current `EXPONENTIAL_AT` setting, or a negative
* exponent equal to or less than the negative component of the setting, then exponential notation
* is returned.
*
* If `base` is `null` or `undefined` it is ignored.
*
* Throws if `base` is invalid.
*
* ```ts
* x = new BigNumber(750000)
* x.toString() // '750000'
* BigNumber.config({ EXPONENTIAL_AT: 5 })
* x.toString() // '7.5e+5'
*
* y = new BigNumber(362.875)
* y.toString(2) // '101101010.111'
* y.toString(9) // '442.77777777777777777778'
* y.toString(32) // 'ba.s'
*
* BigNumber.config({ DECIMAL_PLACES: 4 });
* z = new BigNumber('1.23456789')
* z.toString() // '1.23456789'
* z.toString(10) // '1.2346'
* ```
*
* @param [base] The base, integer, 2 to 36 (or `ALPHABET.length`, see `ALPHABET`).
*/
toString(base?: number): string;
/**
* As `toString`, but does not accept a base argument and includes the minus sign for negative
* zero.
*
* ``ts
* x = new BigNumber('-0')
* x.toString() // '0'
* x.valueOf() // '-0'
* y = new BigNumber('1.777e+457')
* y.valueOf() // '1.777e+457'
* ```
*/
valueOf(): string;
/** Helps ES6 import. */
private static readonly default?: BigNumber.Constructor;
/** Helps ES6 import. */
private static readonly BigNumber?: BigNumber.Constructor;
/** Rounds away from zero. */
static readonly ROUND_UP: 0;
/** Rounds towards zero. */
static readonly ROUND_DOWN: 1;
/** Rounds towards Infinity. */
static readonly ROUND_CEIL: 2;
/** Rounds towards -Infinity. */
static readonly ROUND_FLOOR: 3;
/** Rounds towards nearest neighbour. If equidistant, rounds away from zero . */
static readonly ROUND_HALF_UP: 4;
/** Rounds towards nearest neighbour. If equidistant, rounds towards zero. */
static readonly ROUND_HALF_DOWN: 5;
/** Rounds towards nearest neighbour. If equidistant, rounds towards even neighbour. */
static readonly ROUND_HALF_EVEN: 6;
/** Rounds towards nearest neighbour. If equidistant, rounds towards Infinity. */
static readonly ROUND_HALF_CEIL: 7;
/** Rounds towards nearest neighbour. If equidistant, rounds towards -Infinity. */
static readonly ROUND_HALF_FLOOR: 8;
/** See `MODULO_MODE`. */
static readonly EUCLID: 9;
/**
* To aid in debugging, if a `BigNumber.DEBUG` property is `true` then an error will be thrown
* if the BigNumber constructor receives an invalid `BigNumber.Value`, or if `BigNumber.isBigNumber`
* receives a BigNumber instance that is malformed.
*
* ```ts
* // No error, and BigNumber NaN is returned.
* new BigNumber('blurgh') // 'NaN'
* new BigNumber(9, 2) // 'NaN'
* BigNumber.DEBUG = true
* new BigNumber('blurgh') // '[BigNumber Error] Not a number'
* new BigNumber(9, 2) // '[BigNumber Error] Not a base 2 number'
* ```
*
* An error will also be thrown if a `BigNumber.Value` is of type number with more than 15
* significant digits, as calling `toString` or `valueOf` on such numbers may not result
* in the intended value.
*
* ```ts
* console.log(823456789123456.3) // 823456789123456.2
* // No error, and the returned BigNumber does not have the same value as the number literal.
* new BigNumber(823456789123456.3) // '823456789123456.2'
* BigNumber.DEBUG = true
* new BigNumber(823456789123456.3)
* // '[BigNumber Error] Number primitive has more than 15 significant digits'
* ```
*
* Check that a BigNumber instance is well-formed:
*
* ```ts
* x = new BigNumber(10)
*
* BigNumber.DEBUG = false
* // Change x.c to an illegitimate value.
* x.c = NaN
* // No error, as BigNumber.DEBUG is false.
* BigNumber.isBigNumber(x) // true
*
* BigNumber.DEBUG = true
* BigNumber.isBigNumber(x) // '[BigNumber Error] Invalid BigNumber'
* ```
*/
static DEBUG?: boolean;
/**
* Returns a new independent BigNumber constructor with configuration as described by `object`, or
* with the default configuration if object is `null` or `undefined`.
*
* Throws if `object` is not an object.
*
* ```ts
* BigNumber.config({ DECIMAL_PLACES: 5 })
* BN = BigNumber.clone({ DECIMAL_PLACES: 9 })
*
* x = new BigNumber(1)
* y = new BN(1)
*
* x.div(3) // 0.33333
* y.div(3) // 0.333333333
*
* // BN = BigNumber.clone({ DECIMAL_PLACES: 9 }) is equivalent to:
* BN = BigNumber.clone()
* BN.config({ DECIMAL_PLACES: 9 })
* ```
*
* @param [object] The configuration object.
*/
static clone(object?: BigNumber.Config): BigNumber.Constructor;
/**
* Configures the settings that apply to this BigNumber constructor.
*
* The configuration object, `object`, contains any number of the properties shown in the example
* below.
*
* Returns an object with the above properties and their current values.
*
* Throws if `object` is not an object, or if an invalid value is assigned to one or more of the
* properties.
*
* ```ts
* BigNumber.config({
* DECIMAL_PLACES: 40,
* ROUNDING_MODE: BigNumber.ROUND_HALF_CEIL,
* EXPONENTIAL_AT: [-10, 20],
* RANGE: [-500, 500],
* CRYPTO: true,
* MODULO_MODE: BigNumber.ROUND_FLOOR,
* POW_PRECISION: 80,
* FORMAT: {
* groupSize: 3,
* groupSeparator: ' ',
* decimalSeparator: ','
* },
* ALPHABET: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
* });
*
* BigNumber.config().DECIMAL_PLACES // 40
* ```
*
* @param object The configuration object.
*/
static config(object: BigNumber.Config): BigNumber.Config;
/**
* Returns `true` if `value` is a BigNumber instance, otherwise returns `false`.
*
* If `BigNumber.DEBUG` is `true`, throws if a BigNumber instance is not well-formed.
*
* ```ts
* x = 42
* y = new BigNumber(x)
*
* BigNumber.isBigNumber(x) // false
* y instanceof BigNumber // true
* BigNumber.isBigNumber(y) // true
*
* BN = BigNumber.clone();
* z = new BN(x)
* z instanceof BigNumber // false
* BigNumber.isBigNumber(z) // true
* ```
*
* @param value The value to test.
*/
static isBigNumber(value: any): value is BigNumber;
/**
* Returns a BigNumber whose value is the maximum of the arguments.
*
* The return value is always exact and unrounded.
*
* ```ts
* x = new BigNumber('3257869345.0378653')
* BigNumber.maximum(4e9, x, '123456789.9') // '4000000000'
*
* arr = [12, '13', new BigNumber(14)]
* BigNumber.maximum.apply(null, arr) // '14'
* ```
*
* @param n A numeric value.
*/
static maximum(...n: BigNumber.Value[]): BigNumber;
/**
* Returns a BigNumber whose value is the maximum of the arguments.
*
* The return value is always exact and unrounded.
*
* ```ts
* x = new BigNumber('3257869345.0378653')
* BigNumber.max(4e9, x, '123456789.9') // '4000000000'
*
* arr = [12, '13', new BigNumber(14)]
* BigNumber.max.apply(null, arr) // '14'
* ```
*
* @param n A numeric value.
*/
static max(...n: BigNumber.Value[]): BigNumber;
/**
* Returns a BigNumber whose value is the minimum of the arguments.
*
* The return value is always exact and unrounded.
*
* ```ts
* x = new BigNumber('3257869345.0378653')
* BigNumber.minimum(4e9, x, '123456789.9') // '123456789.9'
*
* arr = [2, new BigNumber(-14), '-15.9999', -12]
* BigNumber.minimum.apply(null, arr) // '-15.9999'
* ```
*
* @param n A numeric value.
*/
static minimum(...n: BigNumber.Value[]): BigNumber;
/**
* Returns a BigNumber whose value is the minimum of the arguments.
*
* The return value is always exact and unrounded.
*
* ```ts
* x = new BigNumber('3257869345.0378653')
* BigNumber.min(4e9, x, '123456789.9') // '123456789.9'
*
* arr = [2, new BigNumber(-14), '-15.9999', -12]
* BigNumber.min.apply(null, arr) // '-15.9999'
* ```
*
* @param n A numeric value.
*/
static min(...n: BigNumber.Value[]): BigNumber;
/**
* Returns a new BigNumber with a pseudo-random value equal to or greater than 0 and less than 1.
*
* The return value will have `decimalPlaces` decimal places, or less if trailing zeros are
* produced. If `decimalPlaces` is omitted, the current `DECIMAL_PLACES` setting will be used.
*
* Depending on the value of this BigNumber constructor's `CRYPTO` setting and the support for the
* `crypto` object in the host environment, the random digits of the return value are generated by
* either `Math.random` (fastest), `crypto.getRandomValues` (Web Cryptography API in recent
* browsers) or `crypto.randomBytes` (Node.js).
*
* To be able to set `CRYPTO` to true when using Node.js, the `crypto` object must be available
* globally:
*
* ```ts
* global.crypto = require('crypto')
* ```
*
* If `CRYPTO` is true, i.e. one of the `crypto` methods is to be used, the value of a returned
* BigNumber should be cryptographically secure and statistically indistinguishable from a random
* value.
*
* Throws if `decimalPlaces` is invalid.
*
* ```ts
* BigNumber.config({ DECIMAL_PLACES: 10 })
* BigNumber.random() // '0.4117936847'
* BigNumber.random(20) // '0.78193327636914089009'
* ```
*
* @param [decimalPlaces] Decimal places, integer, 0 to 1e+9.
*/
static random(decimalPlaces?: number): BigNumber;
/**
* Returns a BigNumber whose value is the sum of the arguments.
*
* The return value is always exact and unrounded.
*
* ```ts
* x = new BigNumber('3257869345.0378653')
* BigNumber.sum(4e9, x, '123456789.9') // '7381326134.9378653'
*
* arr = [2, new BigNumber(14), '15.9999', 12]
* BigNumber.sum.apply(null, arr) // '43.9999'
* ```
*
* @param n A numeric value.
*/
static sum(...n: BigNumber.Value[]): BigNumber;
/**
* Configures the settings that apply to this BigNumber constructor.
*
* The configuration object, `object`, contains any number of the properties shown in the example
* below.
*
* Returns an object with the above properties and their current values.
*
* Throws if `object` is not an object, or if an invalid value is assigned to one or more of the
* properties.
*
* ```ts
* BigNumber.set({
* DECIMAL_PLACES: 40,
* ROUNDING_MODE: BigNumber.ROUND_HALF_CEIL,
* EXPONENTIAL_AT: [-10, 20],
* RANGE: [-500, 500],
* CRYPTO: true,
* MODULO_MODE: BigNumber.ROUND_FLOOR,
* POW_PRECISION: 80,
* FORMAT: {
* groupSize: 3,
* groupSeparator: ' ',
* decimalSeparator: ','
* },
* ALPHABET: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
* });
*
* BigNumber.set().DECIMAL_PLACES // 40
* ```
*
* @param object The configuration object.
*/
static set(object: BigNumber.Config): BigNumber.Config;
}
;(function (globalObject) {
'use strict';
/*
* bignumber.js v9.0.0
* A JavaScript library for arbitrary-precision arithmetic.
* https://github.com/MikeMcl/bignumber.js
* Copyright (c) 2019 Michael Mclaughlin <M8ch88l@gmail.com>
* MIT Licensed.
*
* BigNumber.prototype methods | BigNumber methods
* |
* absoluteValue abs | clone
* comparedTo | config set
* decimalPlaces dp | DECIMAL_PLACES
* dividedBy div | ROUNDING_MODE
* dividedToIntegerBy idiv | EXPONENTIAL_AT
* exponentiatedBy pow | RANGE
* integerValue | CRYPTO
* isEqualTo eq | MODULO_MODE
* isFinite | POW_PRECISION
* isGreaterThan gt | FORMAT
* isGreaterThanOrEqualTo gte | ALPHABET
* isInteger | isBigNumber
* isLessThan lt | maximum max
* isLessThanOrEqualTo lte | minimum min
* isNaN | random
* isNegative | sum
* isPositive |
* isZero |
* minus |
* modulo mod |
* multipliedBy times |
* negated |
* plus |
* precision sd |
* shiftedBy |
* squareRoot sqrt |
* toExponential |
* toFixed |
* toFormat |
* toFraction |
* toJSON |
* toNumber |
* toPrecision |
* toString |
* valueOf |
*
*/
var BigNumber,
isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,
mathceil = Math.ceil,
mathfloor = Math.floor,
bignumberError = '[BigNumber Error] ',
tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ',
BASE = 1e14,
LOG_BASE = 14,
MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1
// MAX_INT32 = 0x7fffffff, // 2^31 - 1
POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],
SQRT_BASE = 1e7,
// EDITABLE
// The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and
// the arguments to toExponential, toFixed, toFormat, and toPrecision.
MAX = 1E9; // 0 to MAX_INT32
/*
* Create and return a BigNumber constructor.
*/
function clone(configObject) {
var div, convertBase, parseNumeric,
P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null },
ONE = new BigNumber(1),
//----------------------------- EDITABLE CONFIG DEFAULTS -------------------------------
// The default values below must be integers within the inclusive ranges stated.
// The values can also be changed at run-time using BigNumber.set.
// The maximum number of decimal places for operations involving division.
DECIMAL_PLACES = 20, // 0 to MAX
// The rounding mode used when rounding to the above decimal places, and when using
// toExponential, toFixed, toFormat and toPrecision, and round (default value).
// UP 0 Away from zero.
// DOWN 1 Towards zero.
// CEIL 2 Towards +Infinity.
// FLOOR 3 Towards -Infinity.
// HALF_UP 4 Towards nearest neighbour. If equidistant, up.
// HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
// HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
// HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
// HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
ROUNDING_MODE = 4, // 0 to 8
// EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]
// The exponent value at and beneath which toString returns exponential notation.
// Number type: -7
TO_EXP_NEG = -7, // 0 to -MAX
// The exponent value at and above which toString returns exponential notation.
// Number type: 21
TO_EXP_POS = 21, // 0 to MAX
// RANGE : [MIN_EXP, MAX_EXP]
// The minimum exponent value, beneath which underflow to zero occurs.
// Number type: -324 (5e-324)
MIN_EXP = -1e7, // -1 to -MAX
// The maximum exponent value, above which overflow to Infinity occurs.
// Number type: 308 (1.7976931348623157e+308)
// For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow.
MAX_EXP = 1e7, // 1 to MAX
// Whether to use cryptographically-secure random number generation, if available.
CRYPTO = false, // true or false
// The modulo mode used when calculating the modulus: a mod n.
// The quotient (q = a / n) is calculated according to the corresponding rounding mode.
// The remainder (r) is calculated as: r = a - n * q.
//
// UP 0 The remainder is positive if the dividend is negative, else is negative.
// DOWN 1 The remainder has the same sign as the dividend.
// This modulo mode is commonly known as 'truncated division' and is
// equivalent to (a % n) in JavaScript.
// FLOOR 3 The remainder has the same sign as the divisor (Python %).
// HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function.
// EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)).
// The remainder is always positive.
//
// The truncated division, floored division, Euclidian division and IEEE 754 remainder
// modes are commonly used for the modulus operation.
// Although the other rounding modes can also be used, they may not give useful results.
MODULO_MODE = 1, // 0 to 9
// The maximum number of significant digits of the result of the exponentiatedBy operation.
// If POW_PRECISION is 0, there will be unlimited significant digits.
POW_PRECISION = 0, // 0 to MAX
// The format specification used by the BigNumber.prototype.toFormat method.
FORMAT = {
prefix: '',
groupSize: 3,
secondaryGroupSize: 0,
groupSeparator: ',',
decimalSeparator: '.',
fractionGroupSize: 0,
fractionGroupSeparator: '\xA0', // non-breaking space
suffix: ''
},
// The alphabet used for base conversion. It must be at least 2 characters long, with no '+',
// '-', '.', whitespace, or repeated character.
// '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz';
//------------------------------------------------------------------------------------------
// CONSTRUCTOR
/*
* The BigNumber constructor and exported function.
* Create and return a new instance of a BigNumber object.
*
* v {number|string|BigNumber} A numeric value.
* [b] {number} The base of v. Integer, 2 to ALPHABET.length inclusive.
*/
function BigNumber(v, b) {
var alphabet, c, caseChanged, e, i, isNum, len, str,
x = this;
// Enable constructor call without `new`.
if (!(x instanceof BigNumber)) return new BigNumber(v, b);
if (b == null) {
if (v && v._isBigNumber === true) {
x.s = v.s;
if (!v.c || v.e > MAX_EXP) {
x.c = x.e = null;
} else if (v.e < MIN_EXP) {
x.c = [x.e = 0];
} else {
x.e = v.e;
x.c = v.c.slice();
}
return;
}
if ((isNum = typeof v == 'number') && v * 0 == 0) {
// Use `1 / n` to handle minus zero also.
x.s = 1 / v < 0 ? (v = -v, -1) : 1;
// Fast path for integers, where n < 2147483648 (2**31).
if (v === ~~v) {
for (e = 0, i = v; i >= 10; i /= 10, e++);
if (e > MAX_EXP) {
x.c = x.e = null;
} else {
x.e = e;
x.c = [v];
}
return;
}
str = String(v);
} else {
if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
}
// Decimal point?
if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
// Exponential form?
if ((i = str.search(/e/i)) > 0) {
// Determine exponent.
if (e < 0) e = i;
e += +str.slice(i + 1);
str = str.substring(0, i);
} else if (e < 0) {
// Integer.
e = str.length;
}
} else {
// '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
intCheck(b, 2, ALPHABET.length, 'Base');
// Allow exponential notation to be used with base 10 argument, while
// also rounding to DECIMAL_PLACES as with other bases.
if (b == 10) {
x = new BigNumber(v);
return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
}
str = String(v);
if (isNum = typeof v == 'number') {
// Avoid potential interpretation of Infinity and NaN as base 44+ values.
if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
// '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'
if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, '').length > 15) {
throw Error
(tooManyDigits + v);
}
} else {
x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
}
alphabet = ALPHABET.slice(0, b);
e = i = 0;
// Check that str is a valid base b number.
// Don't use RegExp, so alphabet can contain special characters.
for (len = str.length; i < len; i++) {
if (alphabet.indexOf(c = str.charAt(i)) < 0) {
if (c == '.') {
// If '.' is not the first character and it has not be found before.
if (i > e) {
e = len;
continue;
}
} else if (!caseChanged) {
// Allow e.g. hexadecimal 'FF' as well as 'ff'.
if (str == str.toUpperCase() && (str = str.toLowerCase()) ||
str == str.toLowerCase() && (str = str.toUpperCase())) {
caseChanged = true;
i = -1;
e = 0;
continue;
}
}
return parseNumeric(x, String(v), isNum, b);
}
}
// Prevent later check for length on converted number.
isNum = false;
str = convertBase(str, b, 10, x.s);
// Decimal point?
if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
else e = str.length;
}
// Determine leading zeros.
for (i = 0; str.charCodeAt(i) === 48; i++);
// Determine trailing zeros.
for (len = str.length; str.charCodeAt(--len) === 48;);
if (str = str.slice(i, ++len)) {
len -= i;
// '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'
if (isNum && BigNumber.DEBUG &&
len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {
throw Error
(tooManyDigits + (x.s * v));
}
// Overflow?
if ((e = e - i - 1) > MAX_EXP) {
// Infinity.
x.c = x.e = null;
// Underflow?
} else if (e < MIN_EXP) {
// Zero.
x.c = [x.e = 0];
} else {
x.e = e;
x.c = [];
// Transform base
// e is the base 10 exponent.
// i is where to slice str to get the first element of the coefficient array.
i = (e + 1) % LOG_BASE;
if (e < 0) i += LOG_BASE; // i < 1
if (i < len) {
if (i) x.c.push(+str.slice(0, i));
for (len -= LOG_BASE; i < len;) {
x.c.push(+str.slice(i, i += LOG_BASE));
}
i = LOG_BASE - (str = str.slice(i)).length;
} else {
i -= len;
}
for (; i--; str += '0');
x.c.push(+str);
}
} else {
// Zero.
x.c = [x.e = 0];
}
}
// CONSTRUCTOR PROPERTIES
BigNumber.clone = clone;
BigNumber.ROUND_UP = 0;
BigNumber.ROUND_DOWN = 1;
BigNumber.ROUND_CEIL = 2;
BigNumber.ROUND_FLOOR = 3;
BigNumber.ROUND_HALF_UP = 4;
BigNumber.ROUND_HALF_DOWN = 5;
BigNumber.ROUND_HALF_EVEN = 6;
BigNumber.ROUND_HALF_CEIL = 7;
BigNumber.ROUND_HALF_FLOOR = 8;
BigNumber.EUCLID = 9;
/*
* Configure infrequently-changing library-wide settings.
*
* Accept an object with the following optional properties (if the value of a property is
* a number, it must be an integer within the inclusive range stated):
*
* DECIMAL_PLACES {number} 0 to MAX
* ROUNDING_MODE {number} 0 to 8
* EXPONENTIAL_AT {number|number[]} -MAX to MAX or [-MAX to 0, 0 to MAX]
* RANGE {number|number[]} -MAX to MAX (not zero) or [-MAX to -1, 1 to MAX]
* CRYPTO {boolean} true or false
* MODULO_MODE {number} 0 to 9
* POW_PRECISION {number} 0 to MAX
* ALPHABET {string} A string of two or more unique characters which does
* not contain '.'.
* FORMAT {object} An object with some of the following properties:
* prefix {string}
* groupSize {number}
* secondaryGroupSize {number}
* groupSeparator {string}
* decimalSeparator {string}
* fractionGroupSize {number}
* fractionGroupSeparator {string}
* suffix {string}
*
* (The values assigned to the above FORMAT object properties are not checked for validity.)
*
* E.g.
* BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })
*
* Ignore properties/parameters set to null or undefined, except for ALPHABET.
*
* Return an object with the properties current values.
*/
BigNumber.config = BigNumber.set = function (obj) {
var p, v;
if (obj != null) {
if (typeof obj == 'object') {
// DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.
// '[BigNumber Error] DECIMAL_PLACES {not a primitive number|not an integer|out of range}: {v}'
if (obj.hasOwnProperty(p = 'DECIMAL_PLACES')) {
v = obj[p];
intCheck(v, 0, MAX, p);
DECIMAL_PLACES = v;
}
// ROUNDING_MODE {number} Integer, 0 to 8 inclusive.
// '[BigNumber Error] ROUNDING_MODE {not a primitive number|not an integer|out of range}: {v}'
if (obj.hasOwnProperty(p = 'ROUNDING_MODE')) {
v = obj[p];
intCheck(v, 0, 8, p);
ROUNDING_MODE = v;
}
// EXPONENTIAL_AT {number|number[]}
// Integer, -MAX to MAX inclusive or
// [integer -MAX to 0 inclusive, 0 to MAX inclusive].
// '[BigNumber Error] EXPONENTIAL_AT {not a primitive number|not an integer|out of range}: {v}'
if (obj.hasOwnProperty(p = 'EXPONENTIAL_AT')) {
v = obj[p];
if (v && v.pop) {
intCheck(v[0], -MAX, 0, p);
intCheck(v[1], 0, MAX, p);
TO_EXP_NEG = v[0];
TO_EXP_POS = v[1];
} else {
intCheck(v, -MAX, MAX, p);
TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
}
}
// RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
// [integer -MAX to -1 inclusive, integer 1 to MAX inclusive].
// '[BigNumber Error] RANGE {not a primitive number|not an integer|out of range|cannot be zero}: {v}'
if (obj.hasOwnProperty(p = 'RANGE')) {
v = obj[p];
if (v && v.pop) {
intCheck(v[0], -MAX, -1, p);
intCheck(v[1], 1, MAX, p);
MIN_EXP = v[0];
MAX_EXP = v[1];
} else {
intCheck(v, -MAX, MAX, p);
if (v) {
MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
} else {
throw Error
(bignumberError + p + ' cannot be zero: ' + v);
}
}
}
// CRYPTO {boolean} true or false.
// '[BigNumber Error] CRYPTO not true or false: {v}'
// '[BigNumber Error] crypto unavailable'
if (obj.hasOwnProperty(p = 'CRYPTO')) {
v = obj[p];
if (v === !!v) {
if (v) {
if (typeof crypto != 'undefined' && crypto &&
(crypto.getRandomValues || crypto.randomBytes)) {
CRYPTO = v;
} else {
CRYPTO = !v;
throw Error
(bignumberError + 'crypto unavailable');
}
} else {
CRYPTO = v;
}
} else {
throw Error
(bignumberError + p + ' not true or false: ' + v);
}
}
// MODULO_MODE {number} Integer, 0 to 9 inclusive.
// '[BigNumber Error] MODULO_MODE {not a primitive number|not an integer|out of range}: {v}'
if (obj.hasOwnProperty(p = 'MODULO_MODE')) {
v = obj[p];
intCheck(v, 0, 9, p);
MODULO_MODE = v;
}
// POW_PRECISION {number} Integer, 0 to MAX inclusive.
// '[BigNumber Error] POW_PRECISION {not a primitive number|not an integer|out of range}: {v}'
if (obj.hasOwnProperty(p = 'POW_PRECISION')) {
v = obj[p];
intCheck(v, 0, MAX, p);
POW_PRECISION = v;
}
// FORMAT {object}
// '[BigNumber Error] FORMAT not an object: {v}'
if (obj.hasOwnProperty(p = 'FORMAT')) {
v = obj[p];
if (typeof v == 'object') FORMAT = v;
else throw Error
(bignumberError + p + ' not an object: ' + v);
}
// ALPHABET {string}
// '[BigNumber Error] ALPHABET invalid: {v}'
if (obj.hasOwnProperty(p = 'ALPHABET')) {
v = obj[p];
// Disallow if only one character,
// or if it contains '+', '-', '.', whitespace, or a repeated character.
if (typeof v == 'string' && !/^.$|[+-.\s]|(.).*\1/.test(v)) {
ALPHABET = v;
} else {
throw Error
(bignumberError + p + ' invalid: ' + v);
}
}
} else {
// '[BigNumber Error] Object expected: {v}'
throw Error
(bignumberError + 'Object expected: ' + obj);
}
}
return {
DECIMAL_PLACES: DECIMAL_PLACES,
ROUNDING_MODE: ROUNDING_MODE,
EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
RANGE: [MIN_EXP, MAX_EXP],
CRYPTO: CRYPTO,
MODULO_MODE: MODULO_MODE,
POW_PRECISION: POW_PRECISION,
FORMAT: FORMAT,
ALPHABET: ALPHABET
};
};
/*
* Return true if v is a BigNumber instance, otherwise return false.
*
* If BigNumber.DEBUG is true, throw if a BigNumber instance is not well-formed.
*
* v {any}
*
* '[BigNumber Error] Invalid BigNumber: {v}'
*/
BigNumber.isBigNumber = function (v) {
if (!v || v._isBigNumber !== true) return false;
if (!BigNumber.DEBUG) return true;
var i, n,
c = v.c,
e = v.e,
s = v.s;
out: if ({}.toString.call(c) == '[object Array]') {
if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
// If the first element is zero, the BigNumber value must be zero.
if (c[0] === 0) {
if (e === 0 && c.length === 1) return true;
break out;
}
// Calculate number of digits that c[0] should have, based on the exponent.
i = (e + 1) % LOG_BASE;
if (i < 1) i += LOG_BASE;
// Calculate number of digits of c[0].
//if (Math.ceil(Math.log(c[0] + 1) / Math.LN10) == i) {
if (String(c[0]).length == i) {
for (i = 0; i < c.length; i++) {
n = c[i];
if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
}
// Last element cannot be zero, unless it is the only element.
if (n !== 0) return true;
}
}
// Infinity/NaN
} else if (c === null && e === null && (s === null || s === 1 || s === -1)) {
return true;
}
throw Error
(bignumberError + 'Invalid BigNumber: ' + v);
};
/*
* Return a new BigNumber whose value is the maximum of the arguments.
*
* arguments {number|string|BigNumber}
*/
BigNumber.maximum = BigNumber.max = function () {
return maxOrMin(arguments, P.lt);
};
/*
* Return a new BigNumber whose value is the minimum of the arguments.
*
* arguments {number|string|BigNumber}
*/
BigNumber.minimum = BigNumber.min = function () {
return maxOrMin(arguments, P.gt);
};
/*
* Return a new BigNumber with a random value equal to or greater than 0 and less than 1,
* and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing
* zeros are produced).
*
* [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp}'
* '[BigNumber Error] crypto unavailable'
*/
BigNumber.random = (function () {
var pow2_53 = 0x20000000000000;
// Return a 53 bit integer n, where 0 <= n < 9007199254740992.
// Check if Math.random() produces more than 32 bits of randomness.
// If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits.
// 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1.
var random53bitInt = (Math.random() * pow2_53) & 0x1fffff
? function () { return mathfloor(Math.random() * pow2_53); }
: function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) +
(Math.random() * 0x800000 | 0); };
return function (dp) {
var a, b, e, k, v,
i = 0,
c = [],
rand = new BigNumber(ONE);
if (dp == null) dp = DECIMAL_PLACES;
else intCheck(dp, 0, MAX);
k = mathceil(dp / LOG_BASE);
if (CRYPTO) {
// Browsers supporting crypto.getRandomValues.
if (crypto.getRandomValues) {
a = crypto.getRandomValues(new Uint32Array(k *= 2));
for (; i < k;) {
// 53 bits:
// ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2)
// 11111 11111111 11111111 11111111 11100000 00000000 00000000
// ((Math.pow(2, 32) - 1) >>> 11).toString(2)
// 11111 11111111 11111111
// 0x20000 is 2^21.
v = a[i] * 0x20000 + (a[i + 1] >>> 11);
// Rejection sampling:
// 0 <= v < 9007199254740992
// Probability that v >= 9e15, is
// 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251
if (v >= 9e15) {
b = crypto.getRandomValues(new Uint32Array(2));
a[i] = b[0];
a[i + 1] = b[1];
} else {
// 0 <= v <= 8999999999999999
// 0 <= (v % 1e14) <= 99999999999999
c.push(v % 1e14);
i += 2;
}
}
i = k / 2;
// Node.js supporting crypto.randomBytes.
} else if (crypto.randomBytes) {
// buffer
a = crypto.randomBytes(k *= 7);
for (; i < k;) {
// 0x1000000000000 is 2^48, 0x10000000000 is 2^40
// 0x100000000 is 2^32, 0x1000000 is 2^24
// 11111 11111111 11111111 11111111 11111111 11111111 11111111
// 0 <= v < 9007199254740992
v = ((a[i] & 31) * 0x1000000000000) + (a[i + 1] * 0x10000000000) +
(a[i + 2] * 0x100000000) + (a[i + 3] * 0x1000000) +
(a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6];
if (v >= 9e15) {
crypto.randomBytes(7).copy(a, i);
} else {
// 0 <= (v % 1e14) <= 99999999999999
c.push(v % 1e14);
i += 7;
}
}
i = k / 7;
} else {
CRYPTO = false;
throw Error
(bignumberError + 'crypto unavailable');
}
}
// Use Math.random.
if (!CRYPTO) {
for (; i < k;) {
v = random53bitInt();
if (v < 9e15) c[i++] = v % 1e14;
}
}
k = c[--i];
dp %= LOG_BASE;
// Convert trailing digits to zeros according to dp.
if (k && dp) {
v = POWS_TEN[LOG_BASE - dp];
c[i] = mathfloor(k / v) * v;
}
// Remove trailing elements which are zero.
for (; c[i] === 0; c.pop(), i--);
// Zero?
if (i < 0) {
c = [e = 0];
} else {
// Remove leading elements which are zero and adjust exponent accordingly.
for (e = -1 ; c[0] === 0; c.splice(0, 1), e -= LOG_BASE);
// Count the digits of the first element of c to determine leading zeros, and...
for (i = 1, v = c[0]; v >= 10; v /= 10, i++);
// adjust the exponent accordingly.
if (i < LOG_BASE) e -= LOG_BASE - i;
}
rand.e = e;
rand.c = c;
return rand;
};
})();
/*
* Return a BigNumber whose value is the sum of the arguments.
*
* arguments {number|string|BigNumber}
*/
BigNumber.sum = function () {
var i = 1,
args = arguments,
sum = new BigNumber(args[0]);
for (; i < args.length;) sum = sum.plus(args[i++]);
return sum;
};
// PRIVATE FUNCTIONS
// Called by BigNumber and BigNumber.prototype.toString.
convertBase = (function () {
var decimal = '0123456789';
/*
* Convert string of baseIn to an array of numbers of baseOut.
* Eg. toBaseOut('255', 10, 16) returns [15, 15].
* Eg. toBaseOut('ff', 16, 10) returns [2, 5, 5].
*/
function toBaseOut(str, baseIn, baseOut, alphabet) {
var j,
arr = [0],
arrL,
i = 0,
len = str.length;
for (; i < len;) {
for (arrL = arr.length; arrL--; arr[arrL] *= baseIn);
arr[0] += alphabet.indexOf(str.charAt(i++));
for (j = 0; j < arr.length; j++) {
if (arr[j] > baseOut - 1) {
if (arr[j + 1] == null) arr[j + 1] = 0;
arr[j + 1] += arr[j] / baseOut | 0;
arr[j] %= baseOut;
}
}
}
return arr.reverse();
}
// Convert a numeric string of baseIn to a numeric string of baseOut.
// If the caller is toString, we are converting from base 10 to baseOut.
// If the caller is BigNumber, we are converting from baseIn to base 10.
return function (str, baseIn, baseOut, sign, callerIsToString) {
var alphabet, d, e, k, r, x, xc, y,
i = str.indexOf('.'),
dp = DECIMAL_PLACES,
rm = ROUNDING_MODE;
// Non-integer.
if (i >= 0) {
k = POW_PRECISION;
// Unlimited precision.
POW_PRECISION = 0;
str = str.replace('.', '');
y = new BigNumber(baseIn);
x = y.pow(str.length - i);
POW_PRECISION = k;
// Convert str as if an integer, then restore the fraction part by dividing the
// result by its base raised to a power.
y.c = toBaseOut(toFixedPoint(coeffToString(x.c), x.e, '0'),
10, baseOut, decimal);
y.e = y.c.length;
}
// Convert the number as integer.
xc = toBaseOut(str, baseIn, baseOut, callerIsToString
? (alphabet = ALPHABET, decimal)
: (alphabet = decimal, ALPHABET));
// xc now represents str as an integer and converted to baseOut. e is the exponent.
e = k = xc.length;
// Remove trailing zeros.
for (; xc[--k] == 0; xc.pop());
// Zero?
if (!xc[0]) return alphabet.charAt(0);
// Does str represent an integer? If so, no need for the division.
if (i < 0) {
--e;
} else {
x.c = xc;
x.e = e;
// The sign is needed for correct rounding.
x.s = sign;
x = div(x, y, dp, rm, baseOut);
xc = x.c;
r = x.r;
e = x.e;
}
// xc now represents str converted to baseOut.
// THe index of the rounding digit.
d = e + dp + 1;
// The rounding digit: the digit to the right of the digit that may be rounded up.
i = xc[d];
// Look at the rounding digits and mode to determine whether to round up.
k = baseOut / 2;
r = r || d < 0 || xc[d + 1] != null;
r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))
: i > k || i == k &&(rm == 4 || r || rm == 6 && xc[d - 1] & 1 ||
rm == (x.s < 0 ? 8 : 7));
// If the index of the rounding digit is not greater than zero, or xc represents
// zero, then the result of the base conversion is zero or, if rounding up, a value
// such as 0.00001.
if (d < 1 || !xc[0]) {
// 1^-dp or 0
str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
} else {
// Truncate xc to the required number of decimal places.
xc.length = d;
// Round up?
if (r) {
// Rounding up may mean the previous digit has to be rounded up and so on.
for (--baseOut; ++xc[--d] > baseOut;) {
xc[d] = 0;
if (!d) {
++e;
xc = [1].concat(xc);
}
}
}
// Determine trailing zeros.
for (k = xc.length; !xc[--k];);
// E.g. [4, 11, 15] becomes 4bf.
for (i = 0, str = ''; i <= k; str += alphabet.charAt(xc[i++]));
// Add leading zeros, decimal point and trailing zeros as required.
str = toFixedPoint(str, e, alphabet.charAt(0));
}
// The caller will add the sign.
return str;
};
})();
// Perform division in the specified base. Called by div and convertBase.
div = (function () {
// Assume non-zero x and k.
function multiply(x, k, base) {
var m, temp, xlo, xhi,
carry = 0,
i = x.length,
klo = k % SQRT_BASE,
khi = k / SQRT_BASE | 0;
for (x = x.slice(); i--;) {
xlo = x[i] % SQRT_BASE;
xhi = x[i] / SQRT_BASE | 0;
m = khi * xlo + xhi * klo;
temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry;
carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
x[i] = temp % base;
}
if (carry) x = [carry].concat(x);
return x;
}
function compare(a, b, aL, bL) {
var i, cmp;
if (aL != bL) {
cmp = aL > bL ? 1 : -1;
} else {
for (i = cmp = 0; i < aL; i++) {
if (a[i] != b[i]) {
cmp = a[i] > b[i] ? 1 : -1;
break;
}
}
}
return cmp;
}
function subtract(a, b, aL, base) {
var i = 0;
// Subtract b from a.
for (; aL--;) {
a[aL] -= i;
i = a[aL] < b[aL] ? 1 : 0;
a[aL] = i * base + a[aL] - b[aL];
}
// Remove leading zeros.
for (; !a[0] && a.length > 1; a.splice(0, 1));
}
// x: dividend, y: divisor.
return function (x, y, dp, rm, base) {
var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,
yL, yz,
s = x.s == y.s ? 1 : -1,
xc = x.c,
yc = y.c;
// Either NaN, Infinity or 0?
if (!xc || !xc[0] || !yc || !yc[0]) {
return new BigNumber(
// Return NaN if either NaN, or both Infinity or 0.
!x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN :
// Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
xc && xc[0] == 0 || !yc ? s * 0 : s / 0
);
}
q = new BigNumber(s);
qc = q.c = [];
e = x.e - y.e;
s = dp + e + 1;
if (!base) {
base = BASE;
e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
s = s / LOG_BASE | 0;
}
// Result exponent may be one less then the current value of e.
// The coefficients of the BigNumbers from convertBase may have trailing zeros.
for (i = 0; yc[i] == (xc[i] || 0); i++);
if (yc[i] > (xc[i] || 0)) e--;
if (s < 0) {
qc.push(1);
more = true;
} else {
xL = xc.length;
yL = yc.length;
i = 0;
s += 2;
// Normalise xc and yc so highest order digit of yc is >= base / 2.
n = mathfloor(base / (yc[0] + 1));
// Not necessary, but to handle odd bases where yc[0] == (base / 2) - 1.
// if (n > 1 || n++ == 1 && yc[0] < base / 2) {
if (n > 1) {
yc = multiply(yc, n, base);
xc = multiply(xc, n, base);
yL = yc.length;
xL = xc.length;
}
xi = yL;
rem = xc.slice(0, yL);
remL = rem.length;
// Add zeros to make remainder as long as divisor.
for (; remL < yL; rem[remL++] = 0);
yz = yc.slice();
yz = [0].concat(yz);
yc0 = yc[0];
if (yc[1] >= base / 2) yc0++;
// Not necessary, but to prevent trial digit n > base, when using base 3.
// else if (base == 3 && yc0 == 1) yc0 = 1 + 1e-15;
do {
n = 0;
// Compare divisor and remainder.
cmp = compare(yc, rem, yL, remL);
// If divisor < remainder.
if (cmp < 0) {
// Calculate trial digit, n.
rem0 = rem[0];
if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
// n is how many times the divisor goes into the current remainder.
n = mathfloor(rem0 / yc0);
// Algorithm:
// product = divisor multiplied by trial digit (n).
// Compare product and remainder.
// If product is greater than remainder:
// Subtract divisor from product, decrement trial digit.
// Subtract product from remainder.
// If product was less than remainder at the last compare:
// Compare new remainder and divisor.
// If remainder is greater than divisor:
// Subtract divisor from remainder, increment trial digit.
if (n > 1) {
// n may be > base only when base is 3.
if (n >= base) n = base - 1;
// product = divisor * trial digit.
prod = multiply(yc, n, base);
prodL = prod.length;
remL = rem.length;
// Compare product and remainder.
// If product > remainder then trial digit n too high.
// n is 1 too high about 5% of the time, and is not known to have
// ever been more than 1 too high.
while (compare(prod, rem, prodL, remL) == 1) {
n--;
// Subtract divisor from product.
subtract(prod, yL < prodL ? yz : yc, prodL, base);
prodL = prod.length;
cmp = 1;
}
} else {
// n is 0 or 1, cmp is -1.
// If n is 0, there is no need to compare yc and rem again below,
// so change cmp to 1 to avoid it.
// If n is 1, leave cmp as -1, so yc and rem are compared again.
if (n == 0) {
// divisor < remainder, so n must be at least 1.
cmp = n = 1;
}
// product = divisor
prod = yc.slice();
prodL = prod.length;
}
if (prodL < remL) prod = [0].concat(prod);
// Subtract product from remainder.
subtract(rem, prod, remL, base);
remL = rem.length;
// If product was < remainder.
if (cmp == -1) {
// Compare divisor and new remainder.
// If divisor < new remainder, subtract divisor from remainder.
// Trial digit n too low.
// n is 1 too low about 5% of the time, and very rarely 2 too low.
while (compare(yc, rem, yL, remL) < 1) {
n++;
// Subtract divisor from remainder.
subtract(rem, yL < remL ? yz : yc, remL, base);
remL = rem.length;
}
}
} else if (cmp === 0) {
n++;
rem = [0];
} // else cmp === 1 and n will be 0
// Add the next digit, n, to the result array.
qc[i++] = n;
// Update the remainder.
if (rem[0]) {
rem[remL++] = xc[xi] || 0;
} else {
rem = [xc[xi]];
remL = 1;
}
} while ((xi++ < xL || rem[0] != null) && s--);
more = rem[0] != null;
// Leading zero?
if (!qc[0]) qc.splice(0, 1);
}
if (base == BASE) {
// To calculate q.e, first get the number of digits of qc[0].
for (i = 1, s = qc[0]; s >= 10; s /= 10, i++);
round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
// Caller is convertBase.
} else {
q.e = e;
q.r = +more;
}
return q;
};
})();
/*
* Return a string representing the value of BigNumber n in fixed-point or exponential
* notation rounded to the specified decimal places or significant digits.
*
* n: a BigNumber.
* i: the index of the last digit required (i.e. the digit that may be rounded up).
* rm: the rounding mode.
* id: 1 (toExponential) or 2 (toPrecision).
*/
function format(n, i, rm, id) {
var c0, e, ne, len, str;
if (rm == null) rm = ROUNDING_MODE;
else intCheck(rm, 0, 8);
if (!n.c) return n.toString();
c0 = n.c[0];
ne = n.e;
if (i == null) {
str = coeffToString(n.c);
str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS)
? toExponential(str, ne)
: toFixedPoint(str, ne, '0');
} else {
n = round(new BigNumber(n), i, rm);
// n.e may have changed if the value was rounded up.
e = n.e;
str = coeffToString(n.c);
len = str.length;
// toPrecision returns exponential notation if the number of significant digits
// specified is less than the number of digits necessary to represent the integer
// part of the value in fixed-point notation.
// Exponential notation.
if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
// Append zeros?
for (; len < i; str += '0', len++);
str = toExponential(str, e);
// Fixed-point notation.
} else {
i -= ne;
str = toFixedPoint(str, e, '0');
// Append zeros?
if (e + 1 > len) {
if (--i > 0) for (str += '.'; i--; str += '0');
} else {
i += e - len;
if (i > 0) {
if (e + 1 == len) str += '.';
for (; i--; str += '0');
}
}
}
}
return n.s < 0 && c0 ? '-' + str : str;
}
// Handle BigNumber.max and BigNumber.min.
function maxOrMin(args, method) {
var n,
i = 1,
m = new BigNumber(args[0]);
for (; i < args.length; i++) {
n = new BigNumber(args[i]);
// If any number is NaN, return NaN.
if (!n.s) {
m = n;
break;
} else if (method.call(m, n)) {
m = n;
}
}
return m;
}
/*
* Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.
* Called by minus, plus and times.
*/
function normalise(n, c, e) {
var i = 1,
j = c.length;
// Remove trailing zeros.
for (; !c[--j]; c.pop());
// Calculate the base 10 exponent. First get the number of digits of c[0].
for (j = c[0]; j >= 10; j /= 10, i++);
// Overflow?
if ((e = i + e * LOG_BASE - 1) > MAX_EXP) {
// Infinity.
n.c = n.e = null;
// Underflow?
} else if (e < MIN_EXP) {
// Zero.
n.c = [n.e = 0];
} else {
n.e = e;
n.c = c;
}
return n;
}
// Handle values that fail the validity test in BigNumber.
parseNumeric = (function () {
var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i,
dotAfter = /^([^.]+)\.$/,
dotBefore = /^\.([^.]+)$/,
isInfinityOrNaN = /^-?(Infinity|NaN)$/,
whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
return function (x, str, isNum, b) {
var base,
s = isNum ? str : str.replace(whitespaceOrPlus, '');
// No exception on ±Infinity or NaN.
if (isInfinityOrNaN.test(s)) {
x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
} else {
if (!isNum) {
// basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
s = s.replace(basePrefix, function (m, p1, p2) {
base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
return !b || b == base ? p1 : m;
});
if (b) {
base = b;
// E.g. '1.' to '1', '.1' to '0.1'
s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1');
}
if (str != s) return new BigNumber(s, base);
}
// '[BigNumber Error] Not a number: {n}'
// '[BigNumber Error] Not a base {b} number: {n}'
if (BigNumber.DEBUG) {
throw Error
(bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str);
}
// NaN
x.s = null;
}
x.c = x.e = null;
}
})();
/*
* Round x to sd significant digits using rounding mode rm. Check for over/under-flow.
* If r is truthy, it is known that there are more digits after the rounding digit.
*/
function round(x, sd, rm, r) {
var d, i, j, k, n, ni, rd,
xc = x.c,
pows10 = POWS_TEN;
// if x is not Infinity or NaN...
if (xc) {
// rd is the rounding digit, i.e. the digit after the digit that may be rounded up.
// n is a base 1e14 number, the value of the element of array x.c containing rd.
// ni is the index of n within x.c.
// d is the number of digits of n.
// i is the index of rd within n including leading zeros.
// j is the actual index of rd within n (if < 0, rd is a leading zero).
out: {
// Get the number of digits of the first element of xc.
for (d = 1, k = xc[0]; k >= 10; k /= 10, d++);
i = sd - d;
// If the rounding digit is in the first element of xc...
if (i < 0) {
i += LOG_BASE;
j = sd;
n = xc[ni = 0];
// Get the rounding digit at index j of n.
rd = n / pows10[d - j - 1] % 10 | 0;
} else {
ni = mathceil((i + 1) / LOG_BASE);
if (ni >= xc.length) {
if (r) {
// Needed by sqrt.
for (; xc.length <= ni; xc.push(0));
n = rd = 0;
d = 1;
i %= LOG_BASE;
j = i - LOG_BASE + 1;
} else {
break out;
}
} else {
n = k = xc[ni];
// Get the number of digits of n.
for (d = 1; k >= 10; k /= 10, d++);
// Get the index of rd within n.
i %= LOG_BASE;
// Get the index of rd within n, adjusted for leading zeros.
// The number of leading zeros of n is given by LOG_BASE - d.
j = i - LOG_BASE + d;
// Get the rounding digit at index j of n.
rd = j < 0 ? 0 : n / pows10[d - j - 1] % 10 | 0;
}
}
r = r || sd < 0 ||
// Are there any non-zero digits after the rounding digit?
// The expression n % pows10[d - j - 1] returns all digits of n to the right
// of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
r = rm < 4
? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))
: rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 &&
// Check whether the digit to the left of the rounding digit is odd.
((i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10) & 1 ||
rm == (x.s < 0 ? 8 : 7));
if (sd < 1 || !xc[0]) {
xc.length = 0;
if (r) {
// Convert sd to decimal places.
sd -= x.e + 1;
// 1, 0.1, 0.01, 0.001, 0.0001 etc.
xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
x.e = -sd || 0;
} else {
// Zero.
xc[0] = x.e = 0;
}
return x;
}
// Remove excess digits.
if (i == 0) {
xc.length = ni;
k = 1;
ni--;
} else {
xc.length = ni + 1;
k = pows10[LOG_BASE - i];
// E.g. 56700 becomes 56000 if 7 is the rounding digit.
// j > 0 means i > number of leading zeros of n.
xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
}
// Round up?
if (r) {
for (; ;) {
// If the digit to be rounded up is in the first element of xc...
if (ni == 0) {
// i will be the length of xc[0] before k is added.
for (i = 1, j = xc[0]; j >= 10; j /= 10, i++);
j = xc[0] += k;
for (k = 1; j >= 10; j /= 10, k++);
// if i != k the length has increased.
if (i != k) {
x.e++;
if (xc[0] == BASE) xc[0] = 1;
}
break;
} else {
xc[ni] += k;
if (xc[ni] != BASE) break;
xc[ni--] = 0;
k = 1;
}
}
}
// Remove trailing zeros.
for (i = xc.length; xc[--i] === 0; xc.pop());
}
// Overflow? Infinity.
if (x.e > MAX_EXP) {
x.c = x.e = null;
// Underflow? Zero.
} else if (x.e < MIN_EXP) {
x.c = [x.e = 0];
}
}
return x;
}
function valueOf(n) {
var str,
e = n.e;
if (e === null) return n.toString();
str = coeffToString(n.c);
str = e <= TO_EXP_NEG || e >= TO_EXP_POS
? toExponential(str, e)
: toFixedPoint(str, e, '0');
return n.s < 0 ? '-' + str : str;
}
// PROTOTYPE/INSTANCE METHODS
/*
* Return a new BigNumber whose value is the absolute value of this BigNumber.
*/
P.absoluteValue = P.abs = function () {
var x = new BigNumber(this);
if (x.s < 0) x.s = 1;
return x;
};
/*
* Return
* 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),
* -1 if the value of this BigNumber is less than the value of BigNumber(y, b),
* 0 if they have the same value,
* or null if the value of either is NaN.
*/
P.comparedTo = function (y, b) {
return compare(this, new BigNumber(y, b));
};
/*
* If dp is undefined or null or true or false, return the number of decimal places of the
* value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN.
*
* Otherwise, if dp is a number, return a new BigNumber whose value is the value of this
* BigNumber rounded to a maximum of dp decimal places using rounding mode rm, or
* ROUNDING_MODE if rm is omitted.
*
* [dp] {number} Decimal places: integer, 0 to MAX inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
*/
P.decimalPlaces = P.dp = function (dp, rm) {
var c, n, v,
x = this;
if (dp != null) {
intCheck(dp, 0, MAX);
if (rm == null) rm = ROUNDING_MODE;
else intCheck(rm, 0, 8);
return round(new BigNumber(x), dp + x.e + 1, rm);
}
if (!(c = x.c)) return null;
n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
// Subtract the number of trailing zeros of the last number.
if (v = c[v]) for (; v % 10 == 0; v /= 10, n--);
if (n < 0) n = 0;
return n;
};
/*
* n / 0 = I
* n / N = N
* n / I = 0
* 0 / n = 0
* 0 / 0 = N
* 0 / N = N
* 0 / I = 0
* N / n = N
* N / 0 = N
* N / N = N
* N / I = N
* I / n = I
* I / 0 = I
* I / N = N
* I / I = N
*
* Return a new BigNumber whose value is the value of this BigNumber divided by the value of
* BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.
*/
P.dividedBy = P.div = function (y, b) {
return div(this, new BigNumber(y, b), DECIMAL_PLACES, ROUNDING_MODE);
};
/*
* Return a new BigNumber whose value is the integer part of dividing the value of this
* BigNumber by the value of BigNumber(y, b).
*/
P.dividedToIntegerBy = P.idiv = function (y, b) {
return div(this, new BigNumber(y, b), 0, 1);
};
/*
* Return a BigNumber whose value is the value of this BigNumber exponentiated by n.
*
* If m is present, return the result modulo m.
* If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
* If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using ROUNDING_MODE.
*
* The modular power operation works efficiently when x, n, and m are integers, otherwise it
* is equivalent to calculating x.exponentiatedBy(n).modulo(m) with a POW_PRECISION of 0.
*
* n {number|string|BigNumber} The exponent. An integer.
* [m] {number|string|BigNumber} The modulus.
*
* '[BigNumber Error] Exponent not an integer: {n}'
*/
P.exponentiatedBy = P.pow = function (n, m) {
var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y,
x = this;
n = new BigNumber(n);
// Allow NaN and ±Infinity, but not other non-integers.
if (n.c && !n.isInteger()) {
throw Error
(bignumberError + 'Exponent not an integer: ' + valueOf(n));
}
if (m != null) m = new BigNumber(m);
// Exponent of MAX_SAFE_INTEGER is 15.
nIsBig = n.e > 14;
// If x is NaN, ±Infinity, ±0 or ±1, or n is ±Infinity, NaN or ±0.
if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
// The sign of the result of pow when x is negative depends on the evenness of n.
// If +n overflows to ±Infinity, the evenness of n would be not be known.
y = new BigNumber(Math.pow(+valueOf(x), nIsBig ? 2 - isOdd(n) : +valueOf(n)));
return m ? y.mod(m) : y;
}
nIsNeg = n.s < 0;
if (m) {
// x % m returns NaN if abs(m) is zero, or m is NaN.
if (m.c ? !m.c[0] : !m.s) return new BigNumber(NaN);
isModExp = !nIsNeg && x.isInteger() && m.isInteger();
if (isModExp) x = x.mod(m);
// Overflow to ±Infinity: >=2**1e10 or >=1.0000024**1e15.
// Underflow to ±0: <=0.79**1e10 or <=0.9999975**1e15.
} else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0
// [1, 240000000]
? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7
// [80000000000000] [99999750000000]
: x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) {
// If x is negative and n is odd, k = -0, else k = 0.
k = x.s < 0 && isOdd(n) ? -0 : 0;
// If x >= 1, k = ±Infinity.
if (x.e > -1) k = 1 / k;
// If n is negative return ±0, else return ±Infinity.
return new BigNumber(nIsNeg ? 1 / k : k);
} else if (POW_PRECISION) {
// Truncating each coefficient array to a length of k after each multiplication
// equates to truncating significant digits to POW_PRECISION + [28, 41],
// i.e. there will be a minimum of 28 guard digits retained.
k = mathceil(POW_PRECISION / LOG_BASE + 2);
}
if (nIsBig) {
half = new BigNumber(0.5);
if (nIsNeg) n.s = 1;
nIsOdd = isOdd(n);
} else {
i = Math.abs(+valueOf(n));
nIsOdd = i % 2;
}
y = new BigNumber(ONE);
// Performs 54 loop iterations for n of 9007199254740991.
for (; ;) {
if (nIsOdd) {
y = y.times(x);
if (!y.c) break;
if (k) {
if (y.c.length > k) y.c.length = k;
} else if (isModExp) {
y = y.mod(m); //y = y.minus(div(y, m, 0, MODULO_MODE).times(m));
}
}
if (i) {
i = mathfloor(i / 2);
if (i === 0) break;
nIsOdd = i % 2;
} else {
n = n.times(half);
round(n, n.e + 1, 1);
if (n.e > 14) {
nIsOdd = isOdd(n);
} else {
i = +valueOf(n);
if (i === 0) break;
nIsOdd = i % 2;
}
}
x = x.times(x);
if (k) {
if (x.c && x.c.length > k) x.c.length = k;
} else if (isModExp) {
x = x.mod(m); //x = x.minus(div(x, m, 0, MODULO_MODE).times(m));
}
}
if (isModExp) return y;
if (nIsNeg) y = ONE.div(y);
return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
};
/*
* Return a new BigNumber whose value is the value of this BigNumber rounded to an integer
* using rounding mode rm, or ROUNDING_MODE if rm is omitted.
*
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {rm}'
*/
P.integerValue = function (rm) {
var n = new BigNumber(this);
if (rm == null) rm = ROUNDING_MODE;
else intCheck(rm, 0, 8);
return round(n, n.e + 1, rm);
};
/*
* Return true if the value of this BigNumber is equal to the value of BigNumber(y, b),
* otherwise return false.
*/
P.isEqualTo = P.eq = function (y, b) {
return compare(this, new BigNumber(y, b)) === 0;
};
/*
* Return true if the value of this BigNumber is a finite number, otherwise return false.
*/
P.isFinite = function () {
return !!this.c;
};
/*
* Return true if the value of this BigNumber is greater than the value of BigNumber(y, b),
* otherwise return false.
*/
P.isGreaterThan = P.gt = function (y, b) {
return compare(this, new BigNumber(y, b)) > 0;
};
/*
* Return true if the value of this BigNumber is greater than or equal to the value of
* BigNumber(y, b), otherwise return false.
*/
P.isGreaterThanOrEqualTo = P.gte = function (y, b) {
return (b = compare(this, new BigNumber(y, b))) === 1 || b === 0;
};
/*
* Return true if the value of this BigNumber is an integer, otherwise return false.
*/
P.isInteger = function () {
return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
};
/*
* Return true if the value of this BigNumber is less than the value of BigNumber(y, b),
* otherwise return false.
*/
P.isLessThan = P.lt = function (y, b) {
return compare(this, new BigNumber(y, b)) < 0;
};
/*
* Return true if the value of this BigNumber is less than or equal to the value of
* BigNumber(y, b), otherwise return false.
*/
P.isLessThanOrEqualTo = P.lte = function (y, b) {
return (b = compare(this, new BigNumber(y, b))) === -1 || b === 0;
};
/*
* Return true if the value of this BigNumber is NaN, otherwise return false.
*/
P.isNaN = function () {
return !this.s;
};
/*
* Return true if the value of this BigNumber is negative, otherwise return false.
*/
P.isNegative = function () {
return this.s < 0;
};
/*
* Return true if the value of this BigNumber is positive, otherwise return false.
*/
P.isPositive = function () {
return this.s > 0;
};
/*
* Return true if the value of this BigNumber is 0 or -0, otherwise return false.
*/
P.isZero = function () {
return !!this.c && this.c[0] == 0;
};
/*
* n - 0 = n
* n - N = N
* n - I = -I
* 0 - n = -n
* 0 - 0 = 0
* 0 - N = N
* 0 - I = -I
* N - n = N
* N - 0 = N
* N - N = N
* N - I = N
* I - n = I
* I - 0 = I
* I - N = N
* I - I = N
*
* Return a new BigNumber whose value is the value of this BigNumber minus the value of
* BigNumber(y, b).
*/
P.minus = function (y, b) {
var i, j, t, xLTy,
x = this,
a = x.s;
y = new BigNumber(y, b);
b = y.s;
// Either NaN?
if (!a || !b) return new BigNumber(NaN);
// Signs differ?
if (a != b) {
y.s = -b;
return x.plus(y);
}
var xe = x.e / LOG_BASE,
ye = y.e / LOG_BASE,
xc = x.c,
yc = y.c;
if (!xe || !ye) {
// Either Infinity?
if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber(yc ? x : NaN);
// Either zero?
if (!xc[0] || !yc[0]) {
// Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
return yc[0] ? (y.s = -b, y) : new BigNumber(xc[0] ? x :
// IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
ROUNDING_MODE == 3 ? -0 : 0);
}
}
xe = bitFloor(xe);
ye = bitFloor(ye);
xc = xc.slice();
// Determine which is the bigger number.
if (a = xe - ye) {
if (xLTy = a < 0) {
a = -a;
t = xc;
} else {
ye = xe;
t = yc;
}
t.reverse();
// Prepend zeros to equalise exponents.
for (b = a; b--; t.push(0));
t.reverse();
} else {
// Exponents equal. Check digit by digit.
j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
for (a = b = 0; b < j; b++) {
if (xc[b] != yc[b]) {
xLTy = xc[b] < yc[b];
break;
}
}
}
// x < y? Point xc to the array of the bigger number.
if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s;
b = (j = yc.length) - (i = xc.length);
// Append zeros to xc if shorter.
// No need to add zeros to yc if shorter as subtract only needs to start at yc.length.
if (b > 0) for (; b--; xc[i++] = 0);
b = BASE - 1;
// Subtract yc from xc.
for (; j > a;) {
if (xc[--j] < yc[j]) {
for (i = j; i && !xc[--i]; xc[i] = b);
--xc[i];
xc[j] += BASE;
}
xc[j] -= yc[j];
}
// Remove leading zeros and adjust exponent accordingly.
for (; xc[0] == 0; xc.splice(0, 1), --ye);
// Zero?
if (!xc[0]) {
// Following IEEE 754 (2008) 6.3,
// n - n = +0 but n - n = -0 when rounding towards -Infinity.
y.s = ROUNDING_MODE == 3 ? -1 : 1;
y.c = [y.e = 0];
return y;
}
// No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity
// for finite x and y.
return normalise(y, xc, ye);
};
/*
* n % 0 = N
* n % N = N
* n % I = n
* 0 % n = 0
* -0 % n = -0
* 0 % 0 = N
* 0 % N = N
* 0 % I = 0
* N % n = N
* N % 0 = N
* N % N = N
* N % I = N
* I % n = N
* I % 0 = N
* I % N = N
* I % I = N
*
* Return a new BigNumber whose value is the value of this BigNumber modulo the value of
* BigNumber(y, b). The result depends on the value of MODULO_MODE.
*/
P.modulo = P.mod = function (y, b) {
var q, s,
x = this;
y = new BigNumber(y, b);
// Return NaN if x is Infinity or NaN, or y is NaN or zero.
if (!x.c || !y.s || y.c && !y.c[0]) {
return new BigNumber(NaN);
// Return x if y is Infinity or x is zero.
} else if (!y.c || x.c && !x.c[0]) {
return new BigNumber(x);
}
if (MODULO_MODE == 9) {
// Euclidian division: q = sign(y) * floor(x / abs(y))
// r = x - qy where 0 <= r < abs(y)
s = y.s;
y.s = 1;
q = div(x, y, 0, 3);
y.s = s;
q.s *= s;
} else {
q = div(x, y, 0, MODULO_MODE);
}
y = x.minus(q.times(y));
// To match JavaScript %, ensure sign of zero is sign of dividend.
if (!y.c[0] && MODULO_MODE == 1) y.s = x.s;
return y;
};
/*
* n * 0 = 0
* n * N = N
* n * I = I
* 0 * n = 0
* 0 * 0 = 0
* 0 * N = N
* 0 * I = N
* N * n = N
* N * 0 = N
* N * N = N
* N * I = N
* I * n = I
* I * 0 = N
* I * N = N
* I * I = I
*
* Return a new BigNumber whose value is the value of this BigNumber multiplied by the value
* of BigNumber(y, b).
*/
P.multipliedBy = P.times = function (y, b) {
var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc,
base, sqrtBase,
x = this,
xc = x.c,
yc = (y = new BigNumber(y, b)).c;
// Either NaN, ±Infinity or ±0?
if (!xc || !yc || !xc[0] || !yc[0]) {
// Return NaN if either is NaN, or one is 0 and the other is Infinity.
if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
y.c = y.e = y.s = null;
} else {
y.s *= x.s;
// Return ±Infinity if either is ±Infinity.
if (!xc || !yc) {
y.c = y.e = null;
// Return ±0 if either is ±0.
} else {
y.c = [0];
y.e = 0;
}
}
return y;
}
e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
y.s *= x.s;
xcL = xc.length;
ycL = yc.length;
// Ensure xc points to longer array and xcL to its length.
if (xcL < ycL) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i;
// Initialise the result array with zeros.
for (i = xcL + ycL, zc = []; i--; zc.push(0));
base = BASE;
sqrtBase = SQRT_BASE;
for (i = ycL; --i >= 0;) {
c = 0;
ylo = yc[i] % sqrtBase;
yhi = yc[i] / sqrtBase | 0;
for (k = xcL, j = i + k; j > i;) {
xlo = xc[--k] % sqrtBase;
xhi = xc[k] / sqrtBase | 0;
m = yhi * xlo + xhi * ylo;
xlo = ylo * xlo + ((m % sqrtBase) * sqrtBase) + zc[j] + c;
c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
zc[j--] = xlo % base;
}
zc[j] = c;
}
if (c) {
++e;
} else {
zc.splice(0, 1);
}
return normalise(y, zc, e);
};
/*
* Return a new BigNumber whose value is the value of this BigNumber negated,
* i.e. multiplied by -1.
*/
P.negated = function () {
var x = new BigNumber(this);
x.s = -x.s || null;
return x;
};
/*
* n + 0 = n
* n + N = N
* n + I = I
* 0 + n = n
* 0 + 0 = 0
* 0 + N = N
* 0 + I = I
* N + n = N
* N + 0 = N
* N + N = N
* N + I = N
* I + n = I
* I + 0 = I
* I + N = N
* I + I = I
*
* Return a new BigNumber whose value is the value of this BigNumber plus the value of
* BigNumber(y, b).
*/
P.plus = function (y, b) {
var t,
x = this,
a = x.s;
y = new BigNumber(y, b);
b = y.s;
// Either NaN?
if (!a || !b) return new BigNumber(NaN);
// Signs differ?
if (a != b) {
y.s = -b;
return x.minus(y);
}
var xe = x.e / LOG_BASE,
ye = y.e / LOG_BASE,
xc = x.c,
yc = y.c;
if (!xe || !ye) {
// Return ±Infinity if either ±Infinity.
if (!xc || !yc) return new BigNumber(a / 0);
// Either zero?
// Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber(xc[0] ? x : a * 0);
}
xe = bitFloor(xe);
ye = bitFloor(ye);
xc = xc.slice();
// Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.
if (a = xe - ye) {
if (a > 0) {
ye = xe;
t = yc;
} else {
a = -a;
t = xc;
}
t.reverse();
for (; a--; t.push(0));
t.reverse();
}
a = xc.length;
b = yc.length;
// Point xc to the longer array, and b to the shorter length.
if (a - b < 0) t = yc, yc = xc, xc = t, b = a;
// Only start adding at yc.length - 1 as the further digits of xc can be ignored.
for (a = 0; b;) {
a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
}
if (a) {
xc = [a].concat(xc);
++ye;
}
// No need to check for zero, as +x + +y != 0 && -x + -y != 0
// ye = MAX_EXP + 1 possible
return normalise(y, xc, ye);
};
/*
* If sd is undefined or null or true or false, return the number of significant digits of
* the value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN.
* If sd is true include integer-part trailing zeros in the count.
*
* Otherwise, if sd is a number, return a new BigNumber whose value is the value of this
* BigNumber rounded to a maximum of sd significant digits using rounding mode rm, or
* ROUNDING_MODE if rm is omitted.
*
* sd {number|boolean} number: significant digits: integer, 1 to MAX inclusive.
* boolean: whether to count integer-part trailing zeros: true or false.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}'
*/
P.precision = P.sd = function (sd, rm) {
var c, n, v,
x = this;
if (sd != null && sd !== !!sd) {
intCheck(sd, 1, MAX);
if (rm == null) rm = ROUNDING_MODE;
else intCheck(rm, 0, 8);
return round(new BigNumber(x), sd, rm);
}
if (!(c = x.c)) return null;
v = c.length - 1;
n = v * LOG_BASE + 1;
if (v = c[v]) {
// Subtract the number of trailing zeros of the last element.
for (; v % 10 == 0; v /= 10, n--);
// Add the number of digits of the first element.
for (v = c[0]; v >= 10; v /= 10, n++);
}
if (sd && x.e + 1 > n) n = x.e + 1;
return n;
};
/*
* Return a new BigNumber whose value is the value of this BigNumber shifted by k places
* (powers of 10). Shift to the right if n > 0, and to the left if n < 0.
*
* k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {k}'
*/
P.shiftedBy = function (k) {
intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
return this.times('1e' + k);
};
/*
* sqrt(-n) = N
* sqrt(N) = N
* sqrt(-I) = N
* sqrt(I) = I
* sqrt(0) = 0
* sqrt(-0) = -0
*
* Return a new BigNumber whose value is the square root of the value of this BigNumber,
* rounded according to DECIMAL_PLACES and ROUNDING_MODE.
*/
P.squareRoot = P.sqrt = function () {
var m, n, r, rep, t,
x = this,
c = x.c,
s = x.s,
e = x.e,
dp = DECIMAL_PLACES + 4,
half = new BigNumber('0.5');
// Negative/NaN/Infinity/zero?
if (s !== 1 || !c || !c[0]) {
return new BigNumber(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0);
}
// Initial estimate.
s = Math.sqrt(+valueOf(x));
// Math.sqrt underflow/overflow?
// Pass x to Math.sqrt as integer, then adjust the exponent of the result.
if (s == 0 || s == 1 / 0) {
n = coeffToString(c);
if ((n.length + e) % 2 == 0) n += '0';
s = Math.sqrt(+n);
e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
if (s == 1 / 0) {
n = '1e' + e;
} else {
n = s.toExponential();
n = n.slice(0, n.indexOf('e') + 1) + e;
}
r = new BigNumber(n);
} else {
r = new BigNumber(s + '');
}
// Check for zero.
// r could be zero if MIN_EXP is changed after the this value was created.
// This would cause a division by zero (x/t) and hence Infinity below, which would cause
// coeffToString to throw.
if (r.c[0]) {
e = r.e;
s = e + dp;
if (s < 3) s = 0;
// Newton-Raphson iteration.
for (; ;) {
t = r;
r = half.times(t.plus(div(x, t, dp, 1)));
if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
// The exponent of r may here be one less than the final result exponent,
// e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits
// are indexed correctly.
if (r.e < e) --s;
n = n.slice(s - 3, s + 1);
// The 4th rounding digit may be in error by -1 so if the 4 rounding digits
// are 9999 or 4999 (i.e. approaching a rounding boundary) continue the
// iteration.
if (n == '9999' || !rep && n == '4999') {
// On the first iteration only, check to see if rounding up gives the
// exact result as the nines may infinitely repeat.
if (!rep) {
round(t, t.e + DECIMAL_PLACES + 2, 0);
if (t.times(t).eq(x)) {
r = t;
break;
}
}
dp += 4;
s += 4;
rep = 1;
} else {
// If rounding digits are null, 0{0,4} or 50{0,3}, check for exact
// result. If not, then there are further digits and m will be truthy.
if (!+n || !+n.slice(1) && n.charAt(0) == '5') {
// Truncate to the first rounding digit.
round(r, r.e + DECIMAL_PLACES + 2, 1);
m = !r.times(r).eq(x);
}
break;
}
}
}
}
return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
};
/*
* Return a string representing the value of this BigNumber in exponential notation and
* rounded using ROUNDING_MODE to dp fixed decimal places.
*
* [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
*/
P.toExponential = function (dp, rm) {
if (dp != null) {
intCheck(dp, 0, MAX);
dp++;
}
return format(this, dp, rm, 1);
};
/*
* Return a string representing the value of this BigNumber in fixed-point notation rounding
* to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted.
*
* Note: as with JavaScript's number type, (-0).toFixed(0) is '0',
* but e.g. (-0.00001).toFixed(0) is '-0'.
*
* [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
*/
P.toFixed = function (dp, rm) {
if (dp != null) {
intCheck(dp, 0, MAX);
dp = dp + this.e + 1;
}
return format(this, dp, rm);
};
/*
* Return a string representing the value of this BigNumber in fixed-point notation rounded
* using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties
* of the format or FORMAT object (see BigNumber.set).
*
* The formatting object may contain some or all of the properties shown below.
*
* FORMAT = {
* prefix: '',
* groupSize: 3,
* secondaryGroupSize: 0,
* groupSeparator: ',',
* decimalSeparator: '.',
* fractionGroupSize: 0,
* fractionGroupSeparator: '\xA0', // non-breaking space
* suffix: ''
* };
*
* [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
* [format] {object} Formatting options. See FORMAT pbject above.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
* '[BigNumber Error] Argument not an object: {format}'
*/
P.toFormat = function (dp, rm, format) {
var str,
x = this;
if (format == null) {
if (dp != null && rm && typeof rm == 'object') {
format = rm;
rm = null;
} else if (dp && typeof dp == 'object') {
format = dp;
dp = rm = null;
} else {
format = FORMAT;
}
} else if (typeof format != 'object') {
throw Error
(bignumberError + 'Argument not an object: ' + format);
}
str = x.toFixed(dp, rm);
if (x.c) {
var i,
arr = str.split('.'),
g1 = +format.groupSize,
g2 = +format.secondaryGroupSize,
groupSeparator = format.groupSeparator || '',
intPart = arr[0],
fractionPart = arr[1],
isNeg = x.s < 0,
intDigits = isNeg ? intPart.slice(1) : intPart,
len = intDigits.length;
if (g2) i = g1, g1 = g2, g2 = i, len -= i;
if (g1 > 0 && len > 0) {
i = len % g1 || g1;
intPart = intDigits.substr(0, i);
for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1);
if (g2 > 0) intPart += groupSeparator + intDigits.slice(i);
if (isNeg) intPart = '-' + intPart;
}
str = fractionPart
? intPart + (format.decimalSeparator || '') + ((g2 = +format.fractionGroupSize)
? fractionPart.replace(new RegExp('\\d{' + g2 + '}\\B', 'g'),
'$&' + (format.fractionGroupSeparator || ''))
: fractionPart)
: intPart;
}
return (format.prefix || '') + str + (format.suffix || '');
};
/*
* Return an array of two BigNumbers representing the value of this BigNumber as a simple
* fraction with an integer numerator and an integer denominator.
* The denominator will be a positive non-zero value less than or equal to the specified
* maximum denominator. If a maximum denominator is not specified, the denominator will be
* the lowest value necessary to represent the number exactly.
*
* [md] {number|string|BigNumber} Integer >= 1, or Infinity. The maximum denominator.
*
* '[BigNumber Error] Argument {not an integer|out of range} : {md}'
*/
P.toFraction = function (md) {
var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s,
x = this,
xc = x.c;
if (md != null) {
n = new BigNumber(md);
// Throw if md is less than one or is not an integer, unless it is Infinity.
if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) {
throw Error
(bignumberError + 'Argument ' +
(n.isInteger() ? 'out of range: ' : 'not an integer: ') + valueOf(n));
}
}
if (!xc) return new BigNumber(x);
d = new BigNumber(ONE);
n1 = d0 = new BigNumber(ONE);
d1 = n0 = new BigNumber(ONE);
s = coeffToString(xc);
// Determine initial denominator.
// d is a power of 10 and the minimum max denominator that specifies the value exactly.
e = d.e = s.length - x.e - 1;
d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
md = !md || n.comparedTo(d) > 0 ? (e > 0 ? d : n1) : n;
exp = MAX_EXP;
MAX_EXP = 1 / 0;
n = new BigNumber(s);
// n0 = d1 = 0
n0.c[0] = 0;
for (; ;) {
q = div(n, d, 0, 1);
d2 = d0.plus(q.times(d1));
if (d2.comparedTo(md) == 1) break;
d0 = d1;
d1 = d2;
n1 = n0.plus(q.times(d2 = n1));
n0 = d2;
d = n.minus(q.times(d2 = d));
n = d2;
}
d2 = div(md.minus(d0), d1, 0, 1);
n0 = n0.plus(d2.times(n1));
d0 = d0.plus(d2.times(d1));
n0.s = n1.s = x.s;
e = e * 2;
// Determine which fraction is closer to x, n0/d0 or n1/d1
r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(
div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
MAX_EXP = exp;
return r;
};
/*
* Return the value of this BigNumber converted to a number primitive.
*/
P.toNumber = function () {
return +valueOf(this);
};
/*
* Return a string representing the value of this BigNumber rounded to sd significant digits
* using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
* necessary to represent the integer part of the value in fixed-point notation, then use
* exponential notation.
*
* [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}'
*/
P.toPrecision = function (sd, rm) {
if (sd != null) intCheck(sd, 1, MAX);
return format(this, sd, rm, 2);
};
/*
* Return a string representing the value of this BigNumber in base b, or base 10 if b is
* omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
* ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
* that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
* TO_EXP_NEG, return exponential notation.
*
* [b] {number} Integer, 2 to ALPHABET.length inclusive.
*
* '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
*/
P.toString = function (b) {
var str,
n = this,
s = n.s,
e = n.e;
// Infinity or NaN?
if (e === null) {
if (s) {
str = 'Infinity';
if (s < 0) str = '-' + str;
} else {
str = 'NaN';
}
} else {
if (b == null) {
str = e <= TO_EXP_NEG || e >= TO_EXP_POS
? toExponential(coeffToString(n.c), e)
: toFixedPoint(coeffToString(n.c), e, '0');
} else if (b === 10) {
n = round(new BigNumber(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
str = toFixedPoint(coeffToString(n.c), n.e, '0');
} else {
intCheck(b, 2, ALPHABET.length, 'Base');
str = convertBase(toFixedPoint(coeffToString(n.c), e, '0'), 10, b, s, true);
}
if (s < 0 && n.c[0]) str = '-' + str;
}
return str;
};
/*
* Return as toString, but do not accept a base argument, and include the minus sign for
* negative zero.
*/
P.valueOf = P.toJSON = function () {
return valueOf(this);
};
P._isBigNumber = true;
if (configObject != null) BigNumber.set(configObject);
return BigNumber;
}
// PRIVATE HELPER FUNCTIONS
// These functions don't need access to variables,
// e.g. DECIMAL_PLACES, in the scope of the `clone` function above.
function bitFloor(n) {
var i = n | 0;
return n > 0 || n === i ? i : i - 1;
}
// Return a coefficient array as a string of base 10 digits.
function coeffToString(a) {
var s, z,
i = 1,
j = a.length,
r = a[0] + '';
for (; i < j;) {
s = a[i++] + '';
z = LOG_BASE - s.length;
for (; z--; s = '0' + s);
r += s;
}
// Determine trailing zeros.
for (j = r.length; r.charCodeAt(--j) === 48;);
return r.slice(0, j + 1 || 1);
}
// Compare the value of BigNumbers x and y.
function compare(x, y) {
var a, b,
xc = x.c,
yc = y.c,
i = x.s,
j = y.s,
k = x.e,
l = y.e;
// Either NaN?
if (!i || !j) return null;
a = xc && !xc[0];
b = yc && !yc[0];
// Either zero?
if (a || b) return a ? b ? 0 : -j : i;
// Signs differ?
if (i != j) return i;
a = i < 0;
b = k == l;
// Either Infinity?
if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1;
// Compare exponents.
if (!b) return k > l ^ a ? 1 : -1;
j = (k = xc.length) < (l = yc.length) ? k : l;
// Compare digit by digit.
for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
// Compare lengths.
return k == l ? 0 : k > l ^ a ? 1 : -1;
}
/*
* Check that n is a primitive number, an integer, and in range, otherwise throw.
*/
function intCheck(n, min, max, name) {
if (n < min || n > max || n !== mathfloor(n)) {
throw Error
(bignumberError + (name || 'Argument') + (typeof n == 'number'
? n < min || n > max ? ' out of range: ' : ' not an integer: '
: ' not a primitive number: ') + String(n));
}
}
// Assumes finite n.
function isOdd(n) {
var k = n.c.length - 1;
return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
}
function toExponential(str, e) {
return (str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str) +
(e < 0 ? 'e' : 'e+') + e;
}
function toFixedPoint(str, e, z) {
var len, zs;
// Negative exponent?
if (e < 0) {
// Prepend zeros.
for (zs = z + '.'; ++e; zs += z);
str = zs + str;
// Positive exponent
} else {
len = str.length;
// Append zeros.
if (++e > len) {
for (zs = z, e -= len; --e; zs += z);
str += zs;
} else if (e < len) {
str = str.slice(0, e) + '.' + str.slice(e);
}
}
return str;
}
// EXPORT
BigNumber = clone();
BigNumber['default'] = BigNumber.BigNumber = BigNumber;
// AMD.
if (typeof define == 'function' && define.amd) {
define(function () { return BigNumber; });
// Node.js and other environments that support module.exports.
} else if (typeof module != 'undefined' && module.exports) {
module.exports = BigNumber;
// Browser.
} else {
if (!globalObject) {
globalObject = typeof self != 'undefined' && self ? self : window;
}
globalObject.BigNumber = BigNumber;
}
})(this);
/* bignumber.js v9.0.0 https://github.com/MikeMcl/bignumber.js/LICENCE */!function(e){"use strict";var r,x=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,L=Math.ceil,U=Math.floor,I="[BigNumber Error] ",T=I+"Number primitive has more than 15 significant digits: ",C=1e14,M=14,G=9007199254740991,k=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],F=1e7,q=1e9;function j(e){var r=0|e;return 0<e||e===r?r:r-1}function $(e){for(var r,n,t=1,i=e.length,o=e[0]+"";t<i;){for(r=e[t++]+"",n=M-r.length;n--;r="0"+r);o+=r}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function z(e,r){var n,t,i=e.c,o=r.c,s=e.s,f=r.s,u=e.e,l=r.e;if(!s||!f)return null;if(n=i&&!i[0],t=o&&!o[0],n||t)return n?t?0:-f:s;if(s!=f)return s;if(n=s<0,t=u==l,!i||!o)return t?0:!i^n?1:-1;if(!t)return l<u^n?1:-1;for(f=(u=i.length)<(l=o.length)?u:l,s=0;s<f;s++)if(i[s]!=o[s])return i[s]>o[s]^n?1:-1;return u==l?0:l<u^n?1:-1}function H(e,r,n,t){if(e<r||n<e||e!==U(e))throw Error(I+(t||"Argument")+("number"==typeof e?e<r||n<e?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function V(e){var r=e.c.length-1;return j(e.e/M)==r&&e.c[r]%2!=0}function W(e,r){return(1<e.length?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function X(e,r,n){var t,i;if(r<0){for(i=n+".";++r;i+=n);e=i+e}else if(++r>(t=e.length)){for(i=n,r-=t;--r;i+=n);e+=i}else r<t&&(e=e.slice(0,r)+"."+e.slice(r));return e}(r=function e(r){var v,a,h,n,l,s,f,u,c,g,t=B.prototype={constructor:B,toString:null,valueOf:null},w=new B(1),N=20,O=4,p=-7,d=21,m=-1e7,y=1e7,b=!1,o=1,E=0,A={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},S="0123456789abcdefghijklmnopqrstuvwxyz";function B(e,r){var n,t,i,o,s,f,u,l,c=this;if(!(c instanceof B))return new B(e,r);if(null==r){if(e&&!0===e._isBigNumber)return c.s=e.s,void(!e.c||e.e>y?c.c=c.e=null:e.e<m?c.c=[c.e=0]:(c.e=e.e,c.c=e.c.slice()));if((f="number"==typeof e)&&0*e==0){if(c.s=1/e<0?(e=-e,-1):1,e===~~e){for(o=0,s=e;10<=s;s/=10,o++);return void(c.c=y<o?c.e=null:(c.e=o,[e]))}l=String(e)}else{if(!x.test(l=String(e)))return h(c,l,f);c.s=45==l.charCodeAt(0)?(l=l.slice(1),-1):1}-1<(o=l.indexOf("."))&&(l=l.replace(".","")),0<(s=l.search(/e/i))?(o<0&&(o=s),o+=+l.slice(s+1),l=l.substring(0,s)):o<0&&(o=l.length)}else{if(H(r,2,S.length,"Base"),10==r)return D(c=new B(e),N+c.e+1,O);if(l=String(e),f="number"==typeof e){if(0*e!=0)return h(c,l,f,r);if(c.s=1/e<0?(l=l.slice(1),-1):1,B.DEBUG&&15<l.replace(/^0\.0*|\./,"").length)throw Error(T+e)}else c.s=45===l.charCodeAt(0)?(l=l.slice(1),-1):1;for(n=S.slice(0,r),o=s=0,u=l.length;s<u;s++)if(n.indexOf(t=l.charAt(s))<0){if("."==t){if(o<s){o=u;continue}}else if(!i&&(l==l.toUpperCase()&&(l=l.toLowerCase())||l==l.toLowerCase()&&(l=l.toUpperCase()))){i=!0,s=-1,o=0;continue}return h(c,String(e),f,r)}f=!1,-1<(o=(l=a(l,r,10,c.s)).indexOf("."))?l=l.replace(".",""):o=l.length}for(s=0;48===l.charCodeAt(s);s++);for(u=l.length;48===l.charCodeAt(--u););if(l=l.slice(s,++u)){if(u-=s,f&&B.DEBUG&&15<u&&(G<e||e!==U(e)))throw Error(T+c.s*e);if((o=o-s-1)>y)c.c=c.e=null;else if(o<m)c.c=[c.e=0];else{if(c.e=o,c.c=[],s=(o+1)%M,o<0&&(s+=M),s<u){for(s&&c.c.push(+l.slice(0,s)),u-=M;s<u;)c.c.push(+l.slice(s,s+=M));s=M-(l=l.slice(s)).length}else s-=u;for(;s--;l+="0");c.c.push(+l)}}else c.c=[c.e=0]}function i(e,r,n,t){var i,o,s,f,u;if(null==n?n=O:H(n,0,8),!e.c)return e.toString();if(i=e.c[0],s=e.e,null==r)u=$(e.c),u=1==t||2==t&&(s<=p||d<=s)?W(u,s):X(u,s,"0");else if(o=(e=D(new B(e),r,n)).e,f=(u=$(e.c)).length,1==t||2==t&&(r<=o||o<=p)){for(;f<r;u+="0",f++);u=W(u,o)}else if(r-=s,u=X(u,o,"0"),f<o+1){if(0<--r)for(u+=".";r--;u+="0");}else if(0<(r+=o-f))for(o+1==f&&(u+=".");r--;u+="0");return e.s<0&&i?"-"+u:u}function R(e,r){for(var n,t=1,i=new B(e[0]);t<e.length;t++){if(!(n=new B(e[t])).s){i=n;break}r.call(i,n)&&(i=n)}return i}function _(e,r,n){for(var t=1,i=r.length;!r[--i];r.pop());for(i=r[0];10<=i;i/=10,t++);return(n=t+n*M-1)>y?e.c=e.e=null:e.c=n<m?[e.e=0]:(e.e=n,r),e}function D(e,r,n,t){var i,o,s,f,u,l,c,a=e.c,h=k;if(a){e:{for(i=1,f=a[0];10<=f;f/=10,i++);if((o=r-i)<0)o+=M,s=r,c=(u=a[l=0])/h[i-s-1]%10|0;else if((l=L((o+1)/M))>=a.length){if(!t)break e;for(;a.length<=l;a.push(0));u=c=0,s=(o%=M)-M+(i=1)}else{for(u=f=a[l],i=1;10<=f;f/=10,i++);c=(s=(o%=M)-M+i)<0?0:u/h[i-s-1]%10|0}if(t=t||r<0||null!=a[l+1]||(s<0?u:u%h[i-s-1]),t=n<4?(c||t)&&(0==n||n==(e.s<0?3:2)):5<c||5==c&&(4==n||t||6==n&&(0<o?0<s?u/h[i-s]:0:a[l-1])%10&1||n==(e.s<0?8:7)),r<1||!a[0])return a.length=0,t?(r-=e.e+1,a[0]=h[(M-r%M)%M],e.e=-r||0):a[0]=e.e=0,e;if(0==o?(a.length=l,f=1,l--):(a.length=l+1,f=h[M-o],a[l]=0<s?U(u/h[i-s]%h[s])*f:0),t)for(;;){if(0==l){for(o=1,s=a[0];10<=s;s/=10,o++);for(s=a[0]+=f,f=1;10<=s;s/=10,f++);o!=f&&(e.e++,a[0]==C&&(a[0]=1));break}if(a[l]+=f,a[l]!=C)break;a[l--]=0,f=1}for(o=a.length;0===a[--o];a.pop());}e.e>y?e.c=e.e=null:e.e<m&&(e.c=[e.e=0])}return e}function P(e){var r,n=e.e;return null===n?e.toString():(r=$(e.c),r=n<=p||d<=n?W(r,n):X(r,n,"0"),e.s<0?"-"+r:r)}return B.clone=e,B.ROUND_UP=0,B.ROUND_DOWN=1,B.ROUND_CEIL=2,B.ROUND_FLOOR=3,B.ROUND_HALF_UP=4,B.ROUND_HALF_DOWN=5,B.ROUND_HALF_EVEN=6,B.ROUND_HALF_CEIL=7,B.ROUND_HALF_FLOOR=8,B.EUCLID=9,B.config=B.set=function(e){var r,n;if(null!=e){if("object"!=typeof e)throw Error(I+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(H(n=e[r],0,q,r),N=n),e.hasOwnProperty(r="ROUNDING_MODE")&&(H(n=e[r],0,8,r),O=n),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((n=e[r])&&n.pop?(H(n[0],-q,0,r),H(n[1],0,q,r),p=n[0],d=n[1]):(H(n,-q,q,r),p=-(d=n<0?-n:n))),e.hasOwnProperty(r="RANGE"))if((n=e[r])&&n.pop)H(n[0],-q,-1,r),H(n[1],1,q,r),m=n[0],y=n[1];else{if(H(n,-q,q,r),!n)throw Error(I+r+" cannot be zero: "+n);m=-(y=n<0?-n:n)}if(e.hasOwnProperty(r="CRYPTO")){if((n=e[r])!==!!n)throw Error(I+r+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw b=!n,Error(I+"crypto unavailable");b=n}else b=n}if(e.hasOwnProperty(r="MODULO_MODE")&&(H(n=e[r],0,9,r),o=n),e.hasOwnProperty(r="POW_PRECISION")&&(H(n=e[r],0,q,r),E=n),e.hasOwnProperty(r="FORMAT")){if("object"!=typeof(n=e[r]))throw Error(I+r+" not an object: "+n);A=n}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(n=e[r])||/^.$|[+-.\s]|(.).*\1/.test(n))throw Error(I+r+" invalid: "+n);S=n}}return{DECIMAL_PLACES:N,ROUNDING_MODE:O,EXPONENTIAL_AT:[p,d],RANGE:[m,y],CRYPTO:b,MODULO_MODE:o,POW_PRECISION:E,FORMAT:A,ALPHABET:S}},B.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!B.DEBUG)return!0;var r,n,t=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(t)){if((1===o||-1===o)&&-q<=i&&i<=q&&i===U(i)){if(0===t[0]){if(0===i&&1===t.length)return!0;break e}if((r=(i+1)%M)<1&&(r+=M),String(t[0]).length==r){for(r=0;r<t.length;r++)if((n=t[r])<0||C<=n||n!==U(n))break e;if(0!==n)return!0}}}else if(null===t&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(I+"Invalid BigNumber: "+e)},B.maximum=B.max=function(){return R(arguments,t.lt)},B.minimum=B.min=function(){return R(arguments,t.gt)},B.random=(n=9007199254740992,l=Math.random()*n&2097151?function(){return U(Math.random()*n)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,n,t,i,o,s=0,f=[],u=new B(w);if(null==e?e=N:H(e,0,q),i=L(e/M),b)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(i*=2));s<i;)9e15<=(o=131072*r[s]+(r[s+1]>>>11))?(n=crypto.getRandomValues(new Uint32Array(2)),r[s]=n[0],r[s+1]=n[1]):(f.push(o%1e14),s+=2);s=i/2}else{if(!crypto.randomBytes)throw b=!1,Error(I+"crypto unavailable");for(r=crypto.randomBytes(i*=7);s<i;)9e15<=(o=281474976710656*(31&r[s])+1099511627776*r[s+1]+4294967296*r[s+2]+16777216*r[s+3]+(r[s+4]<<16)+(r[s+5]<<8)+r[s+6])?crypto.randomBytes(7).copy(r,s):(f.push(o%1e14),s+=7);s=i/7}if(!b)for(;s<i;)(o=l())<9e15&&(f[s++]=o%1e14);for(i=f[--s],e%=M,i&&e&&(o=k[M-e],f[s]=U(i/o)*o);0===f[s];f.pop(),s--);if(s<0)f=[t=0];else{for(t=-1;0===f[0];f.splice(0,1),t-=M);for(s=1,o=f[0];10<=o;o/=10,s++);s<M&&(t-=M-s)}return u.e=t,u.c=f,u}),B.sum=function(){for(var e=1,r=arguments,n=new B(r[0]);e<r.length;)n=n.plus(r[e++]);return n},a=function(){var d="0123456789";function m(e,r,n,t){for(var i,o,s=[0],f=0,u=e.length;f<u;){for(o=s.length;o--;s[o]*=r);for(s[0]+=t.indexOf(e.charAt(f++)),i=0;i<s.length;i++)s[i]>n-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/n|0,s[i]%=n)}return s.reverse()}return function(e,r,n,t,i){var o,s,f,u,l,c,a,h,g=e.indexOf("."),p=N,w=O;for(0<=g&&(u=E,E=0,e=e.replace(".",""),c=(h=new B(r)).pow(e.length-g),E=u,h.c=m(X($(c.c),c.e,"0"),10,n,d),h.e=h.c.length),f=u=(a=m(e,r,n,i?(o=S,d):(o=d,S))).length;0==a[--u];a.pop());if(!a[0])return o.charAt(0);if(g<0?--f:(c.c=a,c.e=f,c.s=t,a=(c=v(c,h,p,w,n)).c,l=c.r,f=c.e),g=a[s=f+p+1],u=n/2,l=l||s<0||null!=a[s+1],l=w<4?(null!=g||l)&&(0==w||w==(c.s<0?3:2)):u<g||g==u&&(4==w||l||6==w&&1&a[s-1]||w==(c.s<0?8:7)),s<1||!a[0])e=l?X(o.charAt(1),-p,o.charAt(0)):o.charAt(0);else{if(a.length=s,l)for(--n;++a[--s]>n;)a[s]=0,s||(++f,a=[1].concat(a));for(u=a.length;!a[--u];);for(g=0,e="";g<=u;e+=o.charAt(a[g++]));e=X(e,f,o.charAt(0))}return e}}(),v=function(){function S(e,r,n){var t,i,o,s,f=0,u=e.length,l=r%F,c=r/F|0;for(e=e.slice();u--;)f=((i=l*(o=e[u]%F)+(t=c*o+(s=e[u]/F|0)*l)%F*F+f)/n|0)+(t/F|0)+c*s,e[u]=i%n;return f&&(e=[f].concat(e)),e}function R(e,r,n,t){var i,o;if(n!=t)o=t<n?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=r[i]){o=e[i]>r[i]?1:-1;break}return o}function _(e,r,n,t){for(var i=0;n--;)e[n]-=i,i=e[n]<r[n]?1:0,e[n]=i*t+e[n]-r[n];for(;!e[0]&&1<e.length;e.splice(0,1));}return function(e,r,n,t,i){var o,s,f,u,l,c,a,h,g,p,w,d,m,v,N,O,y,b=e.s==r.s?1:-1,E=e.c,A=r.c;if(!(E&&E[0]&&A&&A[0]))return new B(e.s&&r.s&&(E?!A||E[0]!=A[0]:A)?E&&0==E[0]||!A?0*b:b/0:NaN);for(g=(h=new B(b)).c=[],b=n+(s=e.e-r.e)+1,i||(i=C,s=j(e.e/M)-j(r.e/M),b=b/M|0),f=0;A[f]==(E[f]||0);f++);if(A[f]>(E[f]||0)&&s--,b<0)g.push(1),u=!0;else{for(v=E.length,O=A.length,b+=2,1<(l=U(i/(A[f=0]+1)))&&(A=S(A,l,i),E=S(E,l,i),O=A.length,v=E.length),m=O,w=(p=E.slice(0,O)).length;w<O;p[w++]=0);y=A.slice(),y=[0].concat(y),N=A[0],A[1]>=i/2&&N++;do{if(l=0,(o=R(A,p,O,w))<0){if(d=p[0],O!=w&&(d=d*i+(p[1]||0)),1<(l=U(d/N)))for(i<=l&&(l=i-1),a=(c=S(A,l,i)).length,w=p.length;1==R(c,p,a,w);)l--,_(c,O<a?y:A,a,i),a=c.length,o=1;else 0==l&&(o=l=1),a=(c=A.slice()).length;if(a<w&&(c=[0].concat(c)),_(p,c,w,i),w=p.length,-1==o)for(;R(A,p,O,w)<1;)l++,_(p,O<w?y:A,w,i),w=p.length}else 0===o&&(l++,p=[0]);g[f++]=l,p[0]?p[w++]=E[m]||0:(p=[E[m]],w=1)}while((m++<v||null!=p[0])&&b--);u=null!=p[0],g[0]||g.splice(0,1)}if(i==C){for(f=1,b=g[0];10<=b;b/=10,f++);D(h,n+(h.e=f+s*M-1)+1,t,u)}else h.e=s,h.r=+u;return h}}(),s=/^(-?)0([xbo])(?=\w[\w.]*$)/i,f=/^([^.]+)\.$/,u=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,g=/^\s*\+(?=[\w.])|^\s+|\s+$/g,h=function(e,r,n,t){var i,o=n?r:r.replace(g,"");if(c.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!n&&(o=o.replace(s,function(e,r,n){return i="x"==(n=n.toLowerCase())?16:"b"==n?2:8,t&&t!=i?e:r}),t&&(i=t,o=o.replace(f,"$1").replace(u,"0.$1")),r!=o))return new B(o,i);if(B.DEBUG)throw Error(I+"Not a"+(t?" base "+t:"")+" number: "+r);e.s=null}e.c=e.e=null},t.absoluteValue=t.abs=function(){var e=new B(this);return e.s<0&&(e.s=1),e},t.comparedTo=function(e,r){return z(this,new B(e,r))},t.decimalPlaces=t.dp=function(e,r){var n,t,i;if(null!=e)return H(e,0,q),null==r?r=O:H(r,0,8),D(new B(this),e+this.e+1,r);if(!(n=this.c))return null;if(t=((i=n.length-1)-j(this.e/M))*M,i=n[i])for(;i%10==0;i/=10,t--);return t<0&&(t=0),t},t.dividedBy=t.div=function(e,r){return v(this,new B(e,r),N,O)},t.dividedToIntegerBy=t.idiv=function(e,r){return v(this,new B(e,r),0,1)},t.exponentiatedBy=t.pow=function(e,r){var n,t,i,o,s,f,u,l,c=this;if((e=new B(e)).c&&!e.isInteger())throw Error(I+"Exponent not an integer: "+P(e));if(null!=r&&(r=new B(r)),s=14<e.e,!c.c||!c.c[0]||1==c.c[0]&&!c.e&&1==c.c.length||!e.c||!e.c[0])return l=new B(Math.pow(+P(c),s?2-V(e):+P(e))),r?l.mod(r):l;if(f=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new B(NaN);(t=!f&&c.isInteger()&&r.isInteger())&&(c=c.mod(r))}else{if(9<e.e&&(0<c.e||c.e<-1||(0==c.e?1<c.c[0]||s&&24e7<=c.c[1]:c.c[0]<8e13||s&&c.c[0]<=9999975e7)))return o=c.s<0&&V(e)?-0:0,-1<c.e&&(o=1/o),new B(f?1/o:o);E&&(o=L(E/M+2))}for(u=s?(n=new B(.5),f&&(e.s=1),V(e)):(i=Math.abs(+P(e)))%2,l=new B(w);;){if(u){if(!(l=l.times(c)).c)break;o?l.c.length>o&&(l.c.length=o):t&&(l=l.mod(r))}if(i){if(0===(i=U(i/2)))break;u=i%2}else if(D(e=e.times(n),e.e+1,1),14<e.e)u=V(e);else{if(0==(i=+P(e)))break;u=i%2}c=c.times(c),o?c.c&&c.c.length>o&&(c.c.length=o):t&&(c=c.mod(r))}return t?l:(f&&(l=w.div(l)),r?l.mod(r):o?D(l,E,O,void 0):l)},t.integerValue=function(e){var r=new B(this);return null==e?e=O:H(e,0,8),D(r,r.e+1,e)},t.isEqualTo=t.eq=function(e,r){return 0===z(this,new B(e,r))},t.isFinite=function(){return!!this.c},t.isGreaterThan=t.gt=function(e,r){return 0<z(this,new B(e,r))},t.isGreaterThanOrEqualTo=t.gte=function(e,r){return 1===(r=z(this,new B(e,r)))||0===r},t.isInteger=function(){return!!this.c&&j(this.e/M)>this.c.length-2},t.isLessThan=t.lt=function(e,r){return z(this,new B(e,r))<0},t.isLessThanOrEqualTo=t.lte=function(e,r){return-1===(r=z(this,new B(e,r)))||0===r},t.isNaN=function(){return!this.s},t.isNegative=function(){return this.s<0},t.isPositive=function(){return 0<this.s},t.isZero=function(){return!!this.c&&0==this.c[0]},t.minus=function(e,r){var n,t,i,o,s=this,f=s.s;if(r=(e=new B(e,r)).s,!f||!r)return new B(NaN);if(f!=r)return e.s=-r,s.plus(e);var u=s.e/M,l=e.e/M,c=s.c,a=e.c;if(!u||!l){if(!c||!a)return c?(e.s=-r,e):new B(a?s:NaN);if(!c[0]||!a[0])return a[0]?(e.s=-r,e):new B(c[0]?s:3==O?-0:0)}if(u=j(u),l=j(l),c=c.slice(),f=u-l){for((i=(o=f<0)?(f=-f,c):(l=u,a)).reverse(),r=f;r--;i.push(0));i.reverse()}else for(t=(o=(f=c.length)<(r=a.length))?f:r,f=r=0;r<t;r++)if(c[r]!=a[r]){o=c[r]<a[r];break}if(o&&(i=c,c=a,a=i,e.s=-e.s),0<(r=(t=a.length)-(n=c.length)))for(;r--;c[n++]=0);for(r=C-1;f<t;){if(c[--t]<a[t]){for(n=t;n&&!c[--n];c[n]=r);--c[n],c[t]+=C}c[t]-=a[t]}for(;0==c[0];c.splice(0,1),--l);return c[0]?_(e,c,l):(e.s=3==O?-1:1,e.c=[e.e=0],e)},t.modulo=t.mod=function(e,r){var n,t,i=this;return e=new B(e,r),!i.c||!e.s||e.c&&!e.c[0]?new B(NaN):!e.c||i.c&&!i.c[0]?new B(i):(9==o?(t=e.s,e.s=1,n=v(i,e,0,3),e.s=t,n.s*=t):n=v(i,e,0,o),(e=i.minus(n.times(e))).c[0]||1!=o||(e.s=i.s),e)},t.multipliedBy=t.times=function(e,r){var n,t,i,o,s,f,u,l,c,a,h,g,p,w,d,m=this,v=m.c,N=(e=new B(e,r)).c;if(!(v&&N&&v[0]&&N[0]))return!m.s||!e.s||v&&!v[0]&&!N||N&&!N[0]&&!v?e.c=e.e=e.s=null:(e.s*=m.s,v&&N?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=j(m.e/M)+j(e.e/M),e.s*=m.s,(u=v.length)<(a=N.length)&&(p=v,v=N,N=p,i=u,u=a,a=i),i=u+a,p=[];i--;p.push(0));for(w=C,d=F,i=a;0<=--i;){for(n=0,h=N[i]%d,g=N[i]/d|0,o=i+(s=u);i<o;)n=((l=h*(l=v[--s]%d)+(f=g*l+(c=v[s]/d|0)*h)%d*d+p[o]+n)/w|0)+(f/d|0)+g*c,p[o--]=l%w;p[o]=n}return n?++t:p.splice(0,1),_(e,p,t)},t.negated=function(){var e=new B(this);return e.s=-e.s||null,e},t.plus=function(e,r){var n,t=this,i=t.s;if(r=(e=new B(e,r)).s,!i||!r)return new B(NaN);if(i!=r)return e.s=-r,t.minus(e);var o=t.e/M,s=e.e/M,f=t.c,u=e.c;if(!o||!s){if(!f||!u)return new B(i/0);if(!f[0]||!u[0])return u[0]?e:new B(f[0]?t:0*i)}if(o=j(o),s=j(s),f=f.slice(),i=o-s){for((n=0<i?(s=o,u):(i=-i,f)).reverse();i--;n.push(0));n.reverse()}for((i=f.length)-(r=u.length)<0&&(n=u,u=f,f=n,r=i),i=0;r;)i=(f[--r]=f[r]+u[r]+i)/C|0,f[r]=C===f[r]?0:f[r]%C;return i&&(f=[i].concat(f),++s),_(e,f,s)},t.precision=t.sd=function(e,r){var n,t,i;if(null!=e&&e!==!!e)return H(e,1,q),null==r?r=O:H(r,0,8),D(new B(this),e,r);if(!(n=this.c))return null;if(t=(i=n.length-1)*M+1,i=n[i]){for(;i%10==0;i/=10,t--);for(i=n[0];10<=i;i/=10,t++);}return e&&this.e+1>t&&(t=this.e+1),t},t.shiftedBy=function(e){return H(e,-G,G),this.times("1e"+e)},t.squareRoot=t.sqrt=function(){var e,r,n,t,i,o=this,s=o.c,f=o.s,u=o.e,l=N+4,c=new B("0.5");if(1!==f||!s||!s[0])return new B(!f||f<0&&(!s||s[0])?NaN:s?o:1/0);if((n=0==(f=Math.sqrt(+P(o)))||f==1/0?(((r=$(s)).length+u)%2==0&&(r+="0"),f=Math.sqrt(+r),u=j((u+1)/2)-(u<0||u%2),new B(r=f==1/0?"1e"+u:(r=f.toExponential()).slice(0,r.indexOf("e")+1)+u)):new B(f+"")).c[0])for((f=(u=n.e)+l)<3&&(f=0);;)if(i=n,n=c.times(i.plus(v(o,i,l,1))),$(i.c).slice(0,f)===(r=$(n.c)).slice(0,f)){if(n.e<u&&--f,"9999"!=(r=r.slice(f-3,f+1))&&(t||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(D(n,n.e+N+2,1),e=!n.times(n).eq(o));break}if(!t&&(D(i,i.e+N+2,0),i.times(i).eq(o))){n=i;break}l+=4,f+=4,t=1}return D(n,n.e+N+1,O,e)},t.toExponential=function(e,r){return null!=e&&(H(e,0,q),e++),i(this,e,r,1)},t.toFixed=function(e,r){return null!=e&&(H(e,0,q),e=e+this.e+1),i(this,e,r)},t.toFormat=function(e,r,n){var t;if(null==n)null!=e&&r&&"object"==typeof r?(n=r,r=null):e&&"object"==typeof e?(n=e,e=r=null):n=A;else if("object"!=typeof n)throw Error(I+"Argument not an object: "+n);if(t=this.toFixed(e,r),this.c){var i,o=t.split("."),s=+n.groupSize,f=+n.secondaryGroupSize,u=n.groupSeparator||"",l=o[0],c=o[1],a=this.s<0,h=a?l.slice(1):l,g=h.length;if(f&&(i=s,s=f,g-=f=i),0<s&&0<g){for(i=g%s||s,l=h.substr(0,i);i<g;i+=s)l+=u+h.substr(i,s);0<f&&(l+=u+h.slice(i)),a&&(l="-"+l)}t=c?l+(n.decimalSeparator||"")+((f=+n.fractionGroupSize)?c.replace(new RegExp("\\d{"+f+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):c):l}return(n.prefix||"")+t+(n.suffix||"")},t.toFraction=function(e){var r,n,t,i,o,s,f,u,l,c,a,h,g=this,p=g.c;if(null!=e&&(!(f=new B(e)).isInteger()&&(f.c||1!==f.s)||f.lt(w)))throw Error(I+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+P(f));if(!p)return new B(g);for(r=new B(w),l=n=new B(w),t=u=new B(w),h=$(p),o=r.e=h.length-g.e-1,r.c[0]=k[(s=o%M)<0?M+s:s],e=!e||0<f.comparedTo(r)?0<o?r:l:f,s=y,y=1/0,f=new B(h),u.c[0]=0;c=v(f,r,0,1),1!=(i=n.plus(c.times(t))).comparedTo(e);)n=t,t=i,l=u.plus(c.times(i=l)),u=i,r=f.minus(c.times(i=r)),f=i;return i=v(e.minus(n),t,0,1),u=u.plus(i.times(l)),n=n.plus(i.times(t)),u.s=l.s=g.s,a=v(l,t,o*=2,O).minus(g).abs().comparedTo(v(u,n,o,O).minus(g).abs())<1?[l,t]:[u,n],y=s,a},t.toNumber=function(){return+P(this)},t.toPrecision=function(e,r){return null!=e&&H(e,1,q),i(this,e,r,2)},t.toString=function(e){var r,n=this,t=n.s,i=n.e;return null===i?t?(r="Infinity",t<0&&(r="-"+r)):r="NaN":(r=null==e?i<=p||d<=i?W($(n.c),i):X($(n.c),i,"0"):10===e?X($((n=D(new B(n),N+i+1,O)).c),n.e,"0"):(H(e,2,S.length,"Base"),a(X($(n.c),i,"0"),10,e,t,!0)),t<0&&n.c[0]&&(r="-"+r)),r},t.valueOf=t.toJSON=function(){return P(this)},t._isBigNumber=!0,null!=r&&B.set(r),B}()).default=r.BigNumber=r,"function"==typeof define&&define.amd?define(function(){return r}):"undefined"!=typeof module&&module.exports?module.exports=r:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=r)}(this);
\ No newline at end of file
{"version":3,"sources":["bignumber.js"],"names":["globalObject","BigNumber","isNumeric","mathceil","Math","ceil","mathfloor","floor","bignumberError","tooManyDigits","BASE","LOG_BASE","MAX_SAFE_INTEGER","POWS_TEN","SQRT_BASE","MAX","bitFloor","n","i","coeffToString","a","s","z","j","length","r","charCodeAt","slice","compare","x","y","b","xc","c","yc","k","e","l","intCheck","min","max","name","Error","String","isOdd","toExponential","str","charAt","toFixedPoint","len","zs","clone","configObject","div","convertBase","parseNumeric","pow2_53","random53bitInt","basePrefix","dotAfter","dotBefore","isInfinityOrNaN","whitespaceOrPlus","P","prototype","constructor","toString","valueOf","ONE","DECIMAL_PLACES","ROUNDING_MODE","TO_EXP_NEG","TO_EXP_POS","MIN_EXP","MAX_EXP","CRYPTO","MODULO_MODE","POW_PRECISION","FORMAT","prefix","groupSize","secondaryGroupSize","groupSeparator","decimalSeparator","fractionGroupSize","fractionGroupSeparator","suffix","ALPHABET","v","alphabet","caseChanged","isNum","this","_isBigNumber","test","indexOf","replace","search","substring","round","DEBUG","toUpperCase","toLowerCase","push","format","rm","id","c0","ne","maxOrMin","args","method","m","call","normalise","pop","sd","d","ni","rd","pows10","out","ROUND_UP","ROUND_DOWN","ROUND_CEIL","ROUND_FLOOR","ROUND_HALF_UP","ROUND_HALF_DOWN","ROUND_HALF_EVEN","ROUND_HALF_CEIL","ROUND_HALF_FLOOR","EUCLID","config","set","obj","p","hasOwnProperty","crypto","getRandomValues","randomBytes","EXPONENTIAL_AT","RANGE","isBigNumber","maximum","arguments","lt","minimum","gt","random","dp","rand","Uint32Array","copy","splice","sum","plus","decimal","toBaseOut","baseIn","baseOut","arrL","arr","reverse","sign","callerIsToString","pow","concat","multiply","base","temp","xlo","xhi","carry","klo","khi","aL","bL","cmp","subtract","more","prod","prodL","q","qc","rem","remL","rem0","xi","xL","yc0","yL","yz","NaN","isNaN","p1","p2","absoluteValue","abs","comparedTo","decimalPlaces","dividedBy","dividedToIntegerBy","idiv","exponentiatedBy","half","isModExp","nIsBig","nIsNeg","nIsOdd","isInteger","mod","times","integerValue","isEqualTo","eq","isFinite","isGreaterThan","isGreaterThanOrEqualTo","gte","isLessThan","isLessThanOrEqualTo","lte","isNegative","isPositive","isZero","minus","t","xLTy","xe","ye","modulo","multipliedBy","xcL","ycL","ylo","yhi","zc","sqrtBase","negated","precision","shiftedBy","squareRoot","sqrt","rep","toFixed","toFormat","split","g1","g2","intPart","fractionPart","isNeg","intDigits","substr","RegExp","toFraction","md","d0","d1","d2","exp","n0","n1","toNumber","toPrecision","toJSON","define","amd","module","exports","self","window"],"mappings":"CAAC,SAAWA,GACV,aAkDA,IAAIC,EACFC,EAAY,6CACZC,EAAWC,KAAKC,KAChBC,EAAYF,KAAKG,MAEjBC,EAAiB,qBACjBC,EAAgBD,EAAiB,yDAEjCE,EAAO,KACPC,EAAW,GACXC,EAAmB,iBAEnBC,EAAW,CAAC,EAAG,GAAI,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,KAAM,KAAM,KAAM,MAC7EC,EAAY,IAKZC,EAAM,IAioFR,SAASC,EAASC,GAChB,IAAIC,EAAQ,EAAJD,EACR,OAAW,EAAJA,GAASA,IAA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DD,OAAOC,QAAU5Q,GAIZD,IACHA,EAA8B,oBAAR8Q,MAAuBA,KAAOA,KAAOC,QAG7D/Q,EAAaC,UAAYA,GAn1F5B,CAq1FE2F"}
\ No newline at end of file
/*
* bignumber.js v9.0.0
* A JavaScript library for arbitrary-precision arithmetic.
* https://github.com/MikeMcl/bignumber.js
* Copyright (c) 2019 Michael Mclaughlin <M8ch88l@gmail.com>
* MIT Licensed.
*
* BigNumber.prototype methods | BigNumber methods
* |
* absoluteValue abs | clone
* comparedTo | config set
* decimalPlaces dp | DECIMAL_PLACES
* dividedBy div | ROUNDING_MODE
* dividedToIntegerBy idiv | EXPONENTIAL_AT
* exponentiatedBy pow | RANGE
* integerValue | CRYPTO
* isEqualTo eq | MODULO_MODE
* isFinite | POW_PRECISION
* isGreaterThan gt | FORMAT
* isGreaterThanOrEqualTo gte | ALPHABET
* isInteger | isBigNumber
* isLessThan lt | maximum max
* isLessThanOrEqualTo lte | minimum min
* isNaN | random
* isNegative | sum
* isPositive |
* isZero |
* minus |
* modulo mod |
* multipliedBy times |
* negated |
* plus |
* precision sd |
* shiftedBy |
* squareRoot sqrt |
* toExponential |
* toFixed |
* toFormat |
* toFraction |
* toJSON |
* toNumber |
* toPrecision |
* toString |
* valueOf |
*
*/
var
isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,
mathceil = Math.ceil,
mathfloor = Math.floor,
bignumberError = '[BigNumber Error] ',
tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ',
BASE = 1e14,
LOG_BASE = 14,
MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1
// MAX_INT32 = 0x7fffffff, // 2^31 - 1
POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13],
SQRT_BASE = 1e7,
// EDITABLE
// The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and
// the arguments to toExponential, toFixed, toFormat, and toPrecision.
MAX = 1E9; // 0 to MAX_INT32
/*
* Create and return a BigNumber constructor.
*/
function clone(configObject) {
var div, convertBase, parseNumeric,
P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null },
ONE = new BigNumber(1),
//----------------------------- EDITABLE CONFIG DEFAULTS -------------------------------
// The default values below must be integers within the inclusive ranges stated.
// The values can also be changed at run-time using BigNumber.set.
// The maximum number of decimal places for operations involving division.
DECIMAL_PLACES = 20, // 0 to MAX
// The rounding mode used when rounding to the above decimal places, and when using
// toExponential, toFixed, toFormat and toPrecision, and round (default value).
// UP 0 Away from zero.
// DOWN 1 Towards zero.
// CEIL 2 Towards +Infinity.
// FLOOR 3 Towards -Infinity.
// HALF_UP 4 Towards nearest neighbour. If equidistant, up.
// HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
// HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
// HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
// HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
ROUNDING_MODE = 4, // 0 to 8
// EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS]
// The exponent value at and beneath which toString returns exponential notation.
// Number type: -7
TO_EXP_NEG = -7, // 0 to -MAX
// The exponent value at and above which toString returns exponential notation.
// Number type: 21
TO_EXP_POS = 21, // 0 to MAX
// RANGE : [MIN_EXP, MAX_EXP]
// The minimum exponent value, beneath which underflow to zero occurs.
// Number type: -324 (5e-324)
MIN_EXP = -1e7, // -1 to -MAX
// The maximum exponent value, above which overflow to Infinity occurs.
// Number type: 308 (1.7976931348623157e+308)
// For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow.
MAX_EXP = 1e7, // 1 to MAX
// Whether to use cryptographically-secure random number generation, if available.
CRYPTO = false, // true or false
// The modulo mode used when calculating the modulus: a mod n.
// The quotient (q = a / n) is calculated according to the corresponding rounding mode.
// The remainder (r) is calculated as: r = a - n * q.
//
// UP 0 The remainder is positive if the dividend is negative, else is negative.
// DOWN 1 The remainder has the same sign as the dividend.
// This modulo mode is commonly known as 'truncated division' and is
// equivalent to (a % n) in JavaScript.
// FLOOR 3 The remainder has the same sign as the divisor (Python %).
// HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function.
// EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)).
// The remainder is always positive.
//
// The truncated division, floored division, Euclidian division and IEEE 754 remainder
// modes are commonly used for the modulus operation.
// Although the other rounding modes can also be used, they may not give useful results.
MODULO_MODE = 1, // 0 to 9
// The maximum number of significant digits of the result of the exponentiatedBy operation.
// If POW_PRECISION is 0, there will be unlimited significant digits.
POW_PRECISION = 0, // 0 to MAX
// The format specification used by the BigNumber.prototype.toFormat method.
FORMAT = {
prefix: '',
groupSize: 3,
secondaryGroupSize: 0,
groupSeparator: ',',
decimalSeparator: '.',
fractionGroupSize: 0,
fractionGroupSeparator: '\xA0', // non-breaking space
suffix: ''
},
// The alphabet used for base conversion. It must be at least 2 characters long, with no '+',
// '-', '.', whitespace, or repeated character.
// '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz';
//------------------------------------------------------------------------------------------
// CONSTRUCTOR
/*
* The BigNumber constructor and exported function.
* Create and return a new instance of a BigNumber object.
*
* v {number|string|BigNumber} A numeric value.
* [b] {number} The base of v. Integer, 2 to ALPHABET.length inclusive.
*/
function BigNumber(v, b) {
var alphabet, c, caseChanged, e, i, isNum, len, str,
x = this;
// Enable constructor call without `new`.
if (!(x instanceof BigNumber)) return new BigNumber(v, b);
if (b == null) {
if (v && v._isBigNumber === true) {
x.s = v.s;
if (!v.c || v.e > MAX_EXP) {
x.c = x.e = null;
} else if (v.e < MIN_EXP) {
x.c = [x.e = 0];
} else {
x.e = v.e;
x.c = v.c.slice();
}
return;
}
if ((isNum = typeof v == 'number') && v * 0 == 0) {
// Use `1 / n` to handle minus zero also.
x.s = 1 / v < 0 ? (v = -v, -1) : 1;
// Fast path for integers, where n < 2147483648 (2**31).
if (v === ~~v) {
for (e = 0, i = v; i >= 10; i /= 10, e++);
if (e > MAX_EXP) {
x.c = x.e = null;
} else {
x.e = e;
x.c = [v];
}
return;
}
str = String(v);
} else {
if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum);
x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
}
// Decimal point?
if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
// Exponential form?
if ((i = str.search(/e/i)) > 0) {
// Determine exponent.
if (e < 0) e = i;
e += +str.slice(i + 1);
str = str.substring(0, i);
} else if (e < 0) {
// Integer.
e = str.length;
}
} else {
// '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
intCheck(b, 2, ALPHABET.length, 'Base');
// Allow exponential notation to be used with base 10 argument, while
// also rounding to DECIMAL_PLACES as with other bases.
if (b == 10) {
x = new BigNumber(v);
return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
}
str = String(v);
if (isNum = typeof v == 'number') {
// Avoid potential interpretation of Infinity and NaN as base 44+ values.
if (v * 0 != 0) return parseNumeric(x, str, isNum, b);
x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1;
// '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'
if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, '').length > 15) {
throw Error
(tooManyDigits + v);
}
} else {
x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
}
alphabet = ALPHABET.slice(0, b);
e = i = 0;
// Check that str is a valid base b number.
// Don't use RegExp, so alphabet can contain special characters.
for (len = str.length; i < len; i++) {
if (alphabet.indexOf(c = str.charAt(i)) < 0) {
if (c == '.') {
// If '.' is not the first character and it has not be found before.
if (i > e) {
e = len;
continue;
}
} else if (!caseChanged) {
// Allow e.g. hexadecimal 'FF' as well as 'ff'.
if (str == str.toUpperCase() && (str = str.toLowerCase()) ||
str == str.toLowerCase() && (str = str.toUpperCase())) {
caseChanged = true;
i = -1;
e = 0;
continue;
}
}
return parseNumeric(x, String(v), isNum, b);
}
}
// Prevent later check for length on converted number.
isNum = false;
str = convertBase(str, b, 10, x.s);
// Decimal point?
if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
else e = str.length;
}
// Determine leading zeros.
for (i = 0; str.charCodeAt(i) === 48; i++);
// Determine trailing zeros.
for (len = str.length; str.charCodeAt(--len) === 48;);
if (str = str.slice(i, ++len)) {
len -= i;
// '[BigNumber Error] Number primitive has more than 15 significant digits: {n}'
if (isNum && BigNumber.DEBUG &&
len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) {
throw Error
(tooManyDigits + (x.s * v));
}
// Overflow?
if ((e = e - i - 1) > MAX_EXP) {
// Infinity.
x.c = x.e = null;
// Underflow?
} else if (e < MIN_EXP) {
// Zero.
x.c = [x.e = 0];
} else {
x.e = e;
x.c = [];
// Transform base
// e is the base 10 exponent.
// i is where to slice str to get the first element of the coefficient array.
i = (e + 1) % LOG_BASE;
if (e < 0) i += LOG_BASE; // i < 1
if (i < len) {
if (i) x.c.push(+str.slice(0, i));
for (len -= LOG_BASE; i < len;) {
x.c.push(+str.slice(i, i += LOG_BASE));
}
i = LOG_BASE - (str = str.slice(i)).length;
} else {
i -= len;
}
for (; i--; str += '0');
x.c.push(+str);
}
} else {
// Zero.
x.c = [x.e = 0];
}
}
// CONSTRUCTOR PROPERTIES
BigNumber.clone = clone;
BigNumber.ROUND_UP = 0;
BigNumber.ROUND_DOWN = 1;
BigNumber.ROUND_CEIL = 2;
BigNumber.ROUND_FLOOR = 3;
BigNumber.ROUND_HALF_UP = 4;
BigNumber.ROUND_HALF_DOWN = 5;
BigNumber.ROUND_HALF_EVEN = 6;
BigNumber.ROUND_HALF_CEIL = 7;
BigNumber.ROUND_HALF_FLOOR = 8;
BigNumber.EUCLID = 9;
/*
* Configure infrequently-changing library-wide settings.
*
* Accept an object with the following optional properties (if the value of a property is
* a number, it must be an integer within the inclusive range stated):
*
* DECIMAL_PLACES {number} 0 to MAX
* ROUNDING_MODE {number} 0 to 8
* EXPONENTIAL_AT {number|number[]} -MAX to MAX or [-MAX to 0, 0 to MAX]
* RANGE {number|number[]} -MAX to MAX (not zero) or [-MAX to -1, 1 to MAX]
* CRYPTO {boolean} true or false
* MODULO_MODE {number} 0 to 9
* POW_PRECISION {number} 0 to MAX
* ALPHABET {string} A string of two or more unique characters which does
* not contain '.'.
* FORMAT {object} An object with some of the following properties:
* prefix {string}
* groupSize {number}
* secondaryGroupSize {number}
* groupSeparator {string}
* decimalSeparator {string}
* fractionGroupSize {number}
* fractionGroupSeparator {string}
* suffix {string}
*
* (The values assigned to the above FORMAT object properties are not checked for validity.)
*
* E.g.
* BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 })
*
* Ignore properties/parameters set to null or undefined, except for ALPHABET.
*
* Return an object with the properties current values.
*/
BigNumber.config = BigNumber.set = function (obj) {
var p, v;
if (obj != null) {
if (typeof obj == 'object') {
// DECIMAL_PLACES {number} Integer, 0 to MAX inclusive.
// '[BigNumber Error] DECIMAL_PLACES {not a primitive number|not an integer|out of range}: {v}'
if (obj.hasOwnProperty(p = 'DECIMAL_PLACES')) {
v = obj[p];
intCheck(v, 0, MAX, p);
DECIMAL_PLACES = v;
}
// ROUNDING_MODE {number} Integer, 0 to 8 inclusive.
// '[BigNumber Error] ROUNDING_MODE {not a primitive number|not an integer|out of range}: {v}'
if (obj.hasOwnProperty(p = 'ROUNDING_MODE')) {
v = obj[p];
intCheck(v, 0, 8, p);
ROUNDING_MODE = v;
}
// EXPONENTIAL_AT {number|number[]}
// Integer, -MAX to MAX inclusive or
// [integer -MAX to 0 inclusive, 0 to MAX inclusive].
// '[BigNumber Error] EXPONENTIAL_AT {not a primitive number|not an integer|out of range}: {v}'
if (obj.hasOwnProperty(p = 'EXPONENTIAL_AT')) {
v = obj[p];
if (v && v.pop) {
intCheck(v[0], -MAX, 0, p);
intCheck(v[1], 0, MAX, p);
TO_EXP_NEG = v[0];
TO_EXP_POS = v[1];
} else {
intCheck(v, -MAX, MAX, p);
TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v);
}
}
// RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or
// [integer -MAX to -1 inclusive, integer 1 to MAX inclusive].
// '[BigNumber Error] RANGE {not a primitive number|not an integer|out of range|cannot be zero}: {v}'
if (obj.hasOwnProperty(p = 'RANGE')) {
v = obj[p];
if (v && v.pop) {
intCheck(v[0], -MAX, -1, p);
intCheck(v[1], 1, MAX, p);
MIN_EXP = v[0];
MAX_EXP = v[1];
} else {
intCheck(v, -MAX, MAX, p);
if (v) {
MIN_EXP = -(MAX_EXP = v < 0 ? -v : v);
} else {
throw Error
(bignumberError + p + ' cannot be zero: ' + v);
}
}
}
// CRYPTO {boolean} true or false.
// '[BigNumber Error] CRYPTO not true or false: {v}'
// '[BigNumber Error] crypto unavailable'
if (obj.hasOwnProperty(p = 'CRYPTO')) {
v = obj[p];
if (v === !!v) {
if (v) {
if (typeof crypto != 'undefined' && crypto &&
(crypto.getRandomValues || crypto.randomBytes)) {
CRYPTO = v;
} else {
CRYPTO = !v;
throw Error
(bignumberError + 'crypto unavailable');
}
} else {
CRYPTO = v;
}
} else {
throw Error
(bignumberError + p + ' not true or false: ' + v);
}
}
// MODULO_MODE {number} Integer, 0 to 9 inclusive.
// '[BigNumber Error] MODULO_MODE {not a primitive number|not an integer|out of range}: {v}'
if (obj.hasOwnProperty(p = 'MODULO_MODE')) {
v = obj[p];
intCheck(v, 0, 9, p);
MODULO_MODE = v;
}
// POW_PRECISION {number} Integer, 0 to MAX inclusive.
// '[BigNumber Error] POW_PRECISION {not a primitive number|not an integer|out of range}: {v}'
if (obj.hasOwnProperty(p = 'POW_PRECISION')) {
v = obj[p];
intCheck(v, 0, MAX, p);
POW_PRECISION = v;
}
// FORMAT {object}
// '[BigNumber Error] FORMAT not an object: {v}'
if (obj.hasOwnProperty(p = 'FORMAT')) {
v = obj[p];
if (typeof v == 'object') FORMAT = v;
else throw Error
(bignumberError + p + ' not an object: ' + v);
}
// ALPHABET {string}
// '[BigNumber Error] ALPHABET invalid: {v}'
if (obj.hasOwnProperty(p = 'ALPHABET')) {
v = obj[p];
// Disallow if only one character,
// or if it contains '+', '-', '.', whitespace, or a repeated character.
if (typeof v == 'string' && !/^.$|[+-.\s]|(.).*\1/.test(v)) {
ALPHABET = v;
} else {
throw Error
(bignumberError + p + ' invalid: ' + v);
}
}
} else {
// '[BigNumber Error] Object expected: {v}'
throw Error
(bignumberError + 'Object expected: ' + obj);
}
}
return {
DECIMAL_PLACES: DECIMAL_PLACES,
ROUNDING_MODE: ROUNDING_MODE,
EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
RANGE: [MIN_EXP, MAX_EXP],
CRYPTO: CRYPTO,
MODULO_MODE: MODULO_MODE,
POW_PRECISION: POW_PRECISION,
FORMAT: FORMAT,
ALPHABET: ALPHABET
};
};
/*
* Return true if v is a BigNumber instance, otherwise return false.
*
* If BigNumber.DEBUG is true, throw if a BigNumber instance is not well-formed.
*
* v {any}
*
* '[BigNumber Error] Invalid BigNumber: {v}'
*/
BigNumber.isBigNumber = function (v) {
if (!v || v._isBigNumber !== true) return false;
if (!BigNumber.DEBUG) return true;
var i, n,
c = v.c,
e = v.e,
s = v.s;
out: if ({}.toString.call(c) == '[object Array]') {
if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) {
// If the first element is zero, the BigNumber value must be zero.
if (c[0] === 0) {
if (e === 0 && c.length === 1) return true;
break out;
}
// Calculate number of digits that c[0] should have, based on the exponent.
i = (e + 1) % LOG_BASE;
if (i < 1) i += LOG_BASE;
// Calculate number of digits of c[0].
//if (Math.ceil(Math.log(c[0] + 1) / Math.LN10) == i) {
if (String(c[0]).length == i) {
for (i = 0; i < c.length; i++) {
n = c[i];
if (n < 0 || n >= BASE || n !== mathfloor(n)) break out;
}
// Last element cannot be zero, unless it is the only element.
if (n !== 0) return true;
}
}
// Infinity/NaN
} else if (c === null && e === null && (s === null || s === 1 || s === -1)) {
return true;
}
throw Error
(bignumberError + 'Invalid BigNumber: ' + v);
};
/*
* Return a new BigNumber whose value is the maximum of the arguments.
*
* arguments {number|string|BigNumber}
*/
BigNumber.maximum = BigNumber.max = function () {
return maxOrMin(arguments, P.lt);
};
/*
* Return a new BigNumber whose value is the minimum of the arguments.
*
* arguments {number|string|BigNumber}
*/
BigNumber.minimum = BigNumber.min = function () {
return maxOrMin(arguments, P.gt);
};
/*
* Return a new BigNumber with a random value equal to or greater than 0 and less than 1,
* and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing
* zeros are produced).
*
* [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp}'
* '[BigNumber Error] crypto unavailable'
*/
BigNumber.random = (function () {
var pow2_53 = 0x20000000000000;
// Return a 53 bit integer n, where 0 <= n < 9007199254740992.
// Check if Math.random() produces more than 32 bits of randomness.
// If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits.
// 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1.
var random53bitInt = (Math.random() * pow2_53) & 0x1fffff
? function () { return mathfloor(Math.random() * pow2_53); }
: function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) +
(Math.random() * 0x800000 | 0); };
return function (dp) {
var a, b, e, k, v,
i = 0,
c = [],
rand = new BigNumber(ONE);
if (dp == null) dp = DECIMAL_PLACES;
else intCheck(dp, 0, MAX);
k = mathceil(dp / LOG_BASE);
if (CRYPTO) {
// Browsers supporting crypto.getRandomValues.
if (crypto.getRandomValues) {
a = crypto.getRandomValues(new Uint32Array(k *= 2));
for (; i < k;) {
// 53 bits:
// ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2)
// 11111 11111111 11111111 11111111 11100000 00000000 00000000
// ((Math.pow(2, 32) - 1) >>> 11).toString(2)
// 11111 11111111 11111111
// 0x20000 is 2^21.
v = a[i] * 0x20000 + (a[i + 1] >>> 11);
// Rejection sampling:
// 0 <= v < 9007199254740992
// Probability that v >= 9e15, is
// 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251
if (v >= 9e15) {
b = crypto.getRandomValues(new Uint32Array(2));
a[i] = b[0];
a[i + 1] = b[1];
} else {
// 0 <= v <= 8999999999999999
// 0 <= (v % 1e14) <= 99999999999999
c.push(v % 1e14);
i += 2;
}
}
i = k / 2;
// Node.js supporting crypto.randomBytes.
} else if (crypto.randomBytes) {
// buffer
a = crypto.randomBytes(k *= 7);
for (; i < k;) {
// 0x1000000000000 is 2^48, 0x10000000000 is 2^40
// 0x100000000 is 2^32, 0x1000000 is 2^24
// 11111 11111111 11111111 11111111 11111111 11111111 11111111
// 0 <= v < 9007199254740992
v = ((a[i] & 31) * 0x1000000000000) + (a[i + 1] * 0x10000000000) +
(a[i + 2] * 0x100000000) + (a[i + 3] * 0x1000000) +
(a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6];
if (v >= 9e15) {
crypto.randomBytes(7).copy(a, i);
} else {
// 0 <= (v % 1e14) <= 99999999999999
c.push(v % 1e14);
i += 7;
}
}
i = k / 7;
} else {
CRYPTO = false;
throw Error
(bignumberError + 'crypto unavailable');
}
}
// Use Math.random.
if (!CRYPTO) {
for (; i < k;) {
v = random53bitInt();
if (v < 9e15) c[i++] = v % 1e14;
}
}
k = c[--i];
dp %= LOG_BASE;
// Convert trailing digits to zeros according to dp.
if (k && dp) {
v = POWS_TEN[LOG_BASE - dp];
c[i] = mathfloor(k / v) * v;
}
// Remove trailing elements which are zero.
for (; c[i] === 0; c.pop(), i--);
// Zero?
if (i < 0) {
c = [e = 0];
} else {
// Remove leading elements which are zero and adjust exponent accordingly.
for (e = -1 ; c[0] === 0; c.splice(0, 1), e -= LOG_BASE);
// Count the digits of the first element of c to determine leading zeros, and...
for (i = 1, v = c[0]; v >= 10; v /= 10, i++);
// adjust the exponent accordingly.
if (i < LOG_BASE) e -= LOG_BASE - i;
}
rand.e = e;
rand.c = c;
return rand;
};
})();
/*
* Return a BigNumber whose value is the sum of the arguments.
*
* arguments {number|string|BigNumber}
*/
BigNumber.sum = function () {
var i = 1,
args = arguments,
sum = new BigNumber(args[0]);
for (; i < args.length;) sum = sum.plus(args[i++]);
return sum;
};
// PRIVATE FUNCTIONS
// Called by BigNumber and BigNumber.prototype.toString.
convertBase = (function () {
var decimal = '0123456789';
/*
* Convert string of baseIn to an array of numbers of baseOut.
* Eg. toBaseOut('255', 10, 16) returns [15, 15].
* Eg. toBaseOut('ff', 16, 10) returns [2, 5, 5].
*/
function toBaseOut(str, baseIn, baseOut, alphabet) {
var j,
arr = [0],
arrL,
i = 0,
len = str.length;
for (; i < len;) {
for (arrL = arr.length; arrL--; arr[arrL] *= baseIn);
arr[0] += alphabet.indexOf(str.charAt(i++));
for (j = 0; j < arr.length; j++) {
if (arr[j] > baseOut - 1) {
if (arr[j + 1] == null) arr[j + 1] = 0;
arr[j + 1] += arr[j] / baseOut | 0;
arr[j] %= baseOut;
}
}
}
return arr.reverse();
}
// Convert a numeric string of baseIn to a numeric string of baseOut.
// If the caller is toString, we are converting from base 10 to baseOut.
// If the caller is BigNumber, we are converting from baseIn to base 10.
return function (str, baseIn, baseOut, sign, callerIsToString) {
var alphabet, d, e, k, r, x, xc, y,
i = str.indexOf('.'),
dp = DECIMAL_PLACES,
rm = ROUNDING_MODE;
// Non-integer.
if (i >= 0) {
k = POW_PRECISION;
// Unlimited precision.
POW_PRECISION = 0;
str = str.replace('.', '');
y = new BigNumber(baseIn);
x = y.pow(str.length - i);
POW_PRECISION = k;
// Convert str as if an integer, then restore the fraction part by dividing the
// result by its base raised to a power.
y.c = toBaseOut(toFixedPoint(coeffToString(x.c), x.e, '0'),
10, baseOut, decimal);
y.e = y.c.length;
}
// Convert the number as integer.
xc = toBaseOut(str, baseIn, baseOut, callerIsToString
? (alphabet = ALPHABET, decimal)
: (alphabet = decimal, ALPHABET));
// xc now represents str as an integer and converted to baseOut. e is the exponent.
e = k = xc.length;
// Remove trailing zeros.
for (; xc[--k] == 0; xc.pop());
// Zero?
if (!xc[0]) return alphabet.charAt(0);
// Does str represent an integer? If so, no need for the division.
if (i < 0) {
--e;
} else {
x.c = xc;
x.e = e;
// The sign is needed for correct rounding.
x.s = sign;
x = div(x, y, dp, rm, baseOut);
xc = x.c;
r = x.r;
e = x.e;
}
// xc now represents str converted to baseOut.
// THe index of the rounding digit.
d = e + dp + 1;
// The rounding digit: the digit to the right of the digit that may be rounded up.
i = xc[d];
// Look at the rounding digits and mode to determine whether to round up.
k = baseOut / 2;
r = r || d < 0 || xc[d + 1] != null;
r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))
: i > k || i == k &&(rm == 4 || r || rm == 6 && xc[d - 1] & 1 ||
rm == (x.s < 0 ? 8 : 7));
// If the index of the rounding digit is not greater than zero, or xc represents
// zero, then the result of the base conversion is zero or, if rounding up, a value
// such as 0.00001.
if (d < 1 || !xc[0]) {
// 1^-dp or 0
str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
} else {
// Truncate xc to the required number of decimal places.
xc.length = d;
// Round up?
if (r) {
// Rounding up may mean the previous digit has to be rounded up and so on.
for (--baseOut; ++xc[--d] > baseOut;) {
xc[d] = 0;
if (!d) {
++e;
xc = [1].concat(xc);
}
}
}
// Determine trailing zeros.
for (k = xc.length; !xc[--k];);
// E.g. [4, 11, 15] becomes 4bf.
for (i = 0, str = ''; i <= k; str += alphabet.charAt(xc[i++]));
// Add leading zeros, decimal point and trailing zeros as required.
str = toFixedPoint(str, e, alphabet.charAt(0));
}
// The caller will add the sign.
return str;
};
})();
// Perform division in the specified base. Called by div and convertBase.
div = (function () {
// Assume non-zero x and k.
function multiply(x, k, base) {
var m, temp, xlo, xhi,
carry = 0,
i = x.length,
klo = k % SQRT_BASE,
khi = k / SQRT_BASE | 0;
for (x = x.slice(); i--;) {
xlo = x[i] % SQRT_BASE;
xhi = x[i] / SQRT_BASE | 0;
m = khi * xlo + xhi * klo;
temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry;
carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
x[i] = temp % base;
}
if (carry) x = [carry].concat(x);
return x;
}
function compare(a, b, aL, bL) {
var i, cmp;
if (aL != bL) {
cmp = aL > bL ? 1 : -1;
} else {
for (i = cmp = 0; i < aL; i++) {
if (a[i] != b[i]) {
cmp = a[i] > b[i] ? 1 : -1;
break;
}
}
}
return cmp;
}
function subtract(a, b, aL, base) {
var i = 0;
// Subtract b from a.
for (; aL--;) {
a[aL] -= i;
i = a[aL] < b[aL] ? 1 : 0;
a[aL] = i * base + a[aL] - b[aL];
}
// Remove leading zeros.
for (; !a[0] && a.length > 1; a.splice(0, 1));
}
// x: dividend, y: divisor.
return function (x, y, dp, rm, base) {
var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0,
yL, yz,
s = x.s == y.s ? 1 : -1,
xc = x.c,
yc = y.c;
// Either NaN, Infinity or 0?
if (!xc || !xc[0] || !yc || !yc[0]) {
return new BigNumber(
// Return NaN if either NaN, or both Infinity or 0.
!x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN :
// Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
xc && xc[0] == 0 || !yc ? s * 0 : s / 0
);
}
q = new BigNumber(s);
qc = q.c = [];
e = x.e - y.e;
s = dp + e + 1;
if (!base) {
base = BASE;
e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE);
s = s / LOG_BASE | 0;
}
// Result exponent may be one less then the current value of e.
// The coefficients of the BigNumbers from convertBase may have trailing zeros.
for (i = 0; yc[i] == (xc[i] || 0); i++);
if (yc[i] > (xc[i] || 0)) e--;
if (s < 0) {
qc.push(1);
more = true;
} else {
xL = xc.length;
yL = yc.length;
i = 0;
s += 2;
// Normalise xc and yc so highest order digit of yc is >= base / 2.
n = mathfloor(base / (yc[0] + 1));
// Not necessary, but to handle odd bases where yc[0] == (base / 2) - 1.
// if (n > 1 || n++ == 1 && yc[0] < base / 2) {
if (n > 1) {
yc = multiply(yc, n, base);
xc = multiply(xc, n, base);
yL = yc.length;
xL = xc.length;
}
xi = yL;
rem = xc.slice(0, yL);
remL = rem.length;
// Add zeros to make remainder as long as divisor.
for (; remL < yL; rem[remL++] = 0);
yz = yc.slice();
yz = [0].concat(yz);
yc0 = yc[0];
if (yc[1] >= base / 2) yc0++;
// Not necessary, but to prevent trial digit n > base, when using base 3.
// else if (base == 3 && yc0 == 1) yc0 = 1 + 1e-15;
do {
n = 0;
// Compare divisor and remainder.
cmp = compare(yc, rem, yL, remL);
// If divisor < remainder.
if (cmp < 0) {
// Calculate trial digit, n.
rem0 = rem[0];
if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
// n is how many times the divisor goes into the current remainder.
n = mathfloor(rem0 / yc0);
// Algorithm:
// product = divisor multiplied by trial digit (n).
// Compare product and remainder.
// If product is greater than remainder:
// Subtract divisor from product, decrement trial digit.
// Subtract product from remainder.
// If product was less than remainder at the last compare:
// Compare new remainder and divisor.
// If remainder is greater than divisor:
// Subtract divisor from remainder, increment trial digit.
if (n > 1) {
// n may be > base only when base is 3.
if (n >= base) n = base - 1;
// product = divisor * trial digit.
prod = multiply(yc, n, base);
prodL = prod.length;
remL = rem.length;
// Compare product and remainder.
// If product > remainder then trial digit n too high.
// n is 1 too high about 5% of the time, and is not known to have
// ever been more than 1 too high.
while (compare(prod, rem, prodL, remL) == 1) {
n--;
// Subtract divisor from product.
subtract(prod, yL < prodL ? yz : yc, prodL, base);
prodL = prod.length;
cmp = 1;
}
} else {
// n is 0 or 1, cmp is -1.
// If n is 0, there is no need to compare yc and rem again below,
// so change cmp to 1 to avoid it.
// If n is 1, leave cmp as -1, so yc and rem are compared again.
if (n == 0) {
// divisor < remainder, so n must be at least 1.
cmp = n = 1;
}
// product = divisor
prod = yc.slice();
prodL = prod.length;
}
if (prodL < remL) prod = [0].concat(prod);
// Subtract product from remainder.
subtract(rem, prod, remL, base);
remL = rem.length;
// If product was < remainder.
if (cmp == -1) {
// Compare divisor and new remainder.
// If divisor < new remainder, subtract divisor from remainder.
// Trial digit n too low.
// n is 1 too low about 5% of the time, and very rarely 2 too low.
while (compare(yc, rem, yL, remL) < 1) {
n++;
// Subtract divisor from remainder.
subtract(rem, yL < remL ? yz : yc, remL, base);
remL = rem.length;
}
}
} else if (cmp === 0) {
n++;
rem = [0];
} // else cmp === 1 and n will be 0
// Add the next digit, n, to the result array.
qc[i++] = n;
// Update the remainder.
if (rem[0]) {
rem[remL++] = xc[xi] || 0;
} else {
rem = [xc[xi]];
remL = 1;
}
} while ((xi++ < xL || rem[0] != null) && s--);
more = rem[0] != null;
// Leading zero?
if (!qc[0]) qc.splice(0, 1);
}
if (base == BASE) {
// To calculate q.e, first get the number of digits of qc[0].
for (i = 1, s = qc[0]; s >= 10; s /= 10, i++);
round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more);
// Caller is convertBase.
} else {
q.e = e;
q.r = +more;
}
return q;
};
})();
/*
* Return a string representing the value of BigNumber n in fixed-point or exponential
* notation rounded to the specified decimal places or significant digits.
*
* n: a BigNumber.
* i: the index of the last digit required (i.e. the digit that may be rounded up).
* rm: the rounding mode.
* id: 1 (toExponential) or 2 (toPrecision).
*/
function format(n, i, rm, id) {
var c0, e, ne, len, str;
if (rm == null) rm = ROUNDING_MODE;
else intCheck(rm, 0, 8);
if (!n.c) return n.toString();
c0 = n.c[0];
ne = n.e;
if (i == null) {
str = coeffToString(n.c);
str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS)
? toExponential(str, ne)
: toFixedPoint(str, ne, '0');
} else {
n = round(new BigNumber(n), i, rm);
// n.e may have changed if the value was rounded up.
e = n.e;
str = coeffToString(n.c);
len = str.length;
// toPrecision returns exponential notation if the number of significant digits
// specified is less than the number of digits necessary to represent the integer
// part of the value in fixed-point notation.
// Exponential notation.
if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) {
// Append zeros?
for (; len < i; str += '0', len++);
str = toExponential(str, e);
// Fixed-point notation.
} else {
i -= ne;
str = toFixedPoint(str, e, '0');
// Append zeros?
if (e + 1 > len) {
if (--i > 0) for (str += '.'; i--; str += '0');
} else {
i += e - len;
if (i > 0) {
if (e + 1 == len) str += '.';
for (; i--; str += '0');
}
}
}
}
return n.s < 0 && c0 ? '-' + str : str;
}
// Handle BigNumber.max and BigNumber.min.
function maxOrMin(args, method) {
var n,
i = 1,
m = new BigNumber(args[0]);
for (; i < args.length; i++) {
n = new BigNumber(args[i]);
// If any number is NaN, return NaN.
if (!n.s) {
m = n;
break;
} else if (method.call(m, n)) {
m = n;
}
}
return m;
}
/*
* Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP.
* Called by minus, plus and times.
*/
function normalise(n, c, e) {
var i = 1,
j = c.length;
// Remove trailing zeros.
for (; !c[--j]; c.pop());
// Calculate the base 10 exponent. First get the number of digits of c[0].
for (j = c[0]; j >= 10; j /= 10, i++);
// Overflow?
if ((e = i + e * LOG_BASE - 1) > MAX_EXP) {
// Infinity.
n.c = n.e = null;
// Underflow?
} else if (e < MIN_EXP) {
// Zero.
n.c = [n.e = 0];
} else {
n.e = e;
n.c = c;
}
return n;
}
// Handle values that fail the validity test in BigNumber.
parseNumeric = (function () {
var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i,
dotAfter = /^([^.]+)\.$/,
dotBefore = /^\.([^.]+)$/,
isInfinityOrNaN = /^-?(Infinity|NaN)$/,
whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
return function (x, str, isNum, b) {
var base,
s = isNum ? str : str.replace(whitespaceOrPlus, '');
// No exception on ±Infinity or NaN.
if (isInfinityOrNaN.test(s)) {
x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
} else {
if (!isNum) {
// basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i
s = s.replace(basePrefix, function (m, p1, p2) {
base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8;
return !b || b == base ? p1 : m;
});
if (b) {
base = b;
// E.g. '1.' to '1', '.1' to '0.1'
s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1');
}
if (str != s) return new BigNumber(s, base);
}
// '[BigNumber Error] Not a number: {n}'
// '[BigNumber Error] Not a base {b} number: {n}'
if (BigNumber.DEBUG) {
throw Error
(bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str);
}
// NaN
x.s = null;
}
x.c = x.e = null;
}
})();
/*
* Round x to sd significant digits using rounding mode rm. Check for over/under-flow.
* If r is truthy, it is known that there are more digits after the rounding digit.
*/
function round(x, sd, rm, r) {
var d, i, j, k, n, ni, rd,
xc = x.c,
pows10 = POWS_TEN;
// if x is not Infinity or NaN...
if (xc) {
// rd is the rounding digit, i.e. the digit after the digit that may be rounded up.
// n is a base 1e14 number, the value of the element of array x.c containing rd.
// ni is the index of n within x.c.
// d is the number of digits of n.
// i is the index of rd within n including leading zeros.
// j is the actual index of rd within n (if < 0, rd is a leading zero).
out: {
// Get the number of digits of the first element of xc.
for (d = 1, k = xc[0]; k >= 10; k /= 10, d++);
i = sd - d;
// If the rounding digit is in the first element of xc...
if (i < 0) {
i += LOG_BASE;
j = sd;
n = xc[ni = 0];
// Get the rounding digit at index j of n.
rd = n / pows10[d - j - 1] % 10 | 0;
} else {
ni = mathceil((i + 1) / LOG_BASE);
if (ni >= xc.length) {
if (r) {
// Needed by sqrt.
for (; xc.length <= ni; xc.push(0));
n = rd = 0;
d = 1;
i %= LOG_BASE;
j = i - LOG_BASE + 1;
} else {
break out;
}
} else {
n = k = xc[ni];
// Get the number of digits of n.
for (d = 1; k >= 10; k /= 10, d++);
// Get the index of rd within n.
i %= LOG_BASE;
// Get the index of rd within n, adjusted for leading zeros.
// The number of leading zeros of n is given by LOG_BASE - d.
j = i - LOG_BASE + d;
// Get the rounding digit at index j of n.
rd = j < 0 ? 0 : n / pows10[d - j - 1] % 10 | 0;
}
}
r = r || sd < 0 ||
// Are there any non-zero digits after the rounding digit?
// The expression n % pows10[d - j - 1] returns all digits of n to the right
// of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]);
r = rm < 4
? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))
: rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 &&
// Check whether the digit to the left of the rounding digit is odd.
((i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10) & 1 ||
rm == (x.s < 0 ? 8 : 7));
if (sd < 1 || !xc[0]) {
xc.length = 0;
if (r) {
// Convert sd to decimal places.
sd -= x.e + 1;
// 1, 0.1, 0.01, 0.001, 0.0001 etc.
xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
x.e = -sd || 0;
} else {
// Zero.
xc[0] = x.e = 0;
}
return x;
}
// Remove excess digits.
if (i == 0) {
xc.length = ni;
k = 1;
ni--;
} else {
xc.length = ni + 1;
k = pows10[LOG_BASE - i];
// E.g. 56700 becomes 56000 if 7 is the rounding digit.
// j > 0 means i > number of leading zeros of n.
xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0;
}
// Round up?
if (r) {
for (; ;) {
// If the digit to be rounded up is in the first element of xc...
if (ni == 0) {
// i will be the length of xc[0] before k is added.
for (i = 1, j = xc[0]; j >= 10; j /= 10, i++);
j = xc[0] += k;
for (k = 1; j >= 10; j /= 10, k++);
// if i != k the length has increased.
if (i != k) {
x.e++;
if (xc[0] == BASE) xc[0] = 1;
}
break;
} else {
xc[ni] += k;
if (xc[ni] != BASE) break;
xc[ni--] = 0;
k = 1;
}
}
}
// Remove trailing zeros.
for (i = xc.length; xc[--i] === 0; xc.pop());
}
// Overflow? Infinity.
if (x.e > MAX_EXP) {
x.c = x.e = null;
// Underflow? Zero.
} else if (x.e < MIN_EXP) {
x.c = [x.e = 0];
}
}
return x;
}
function valueOf(n) {
var str,
e = n.e;
if (e === null) return n.toString();
str = coeffToString(n.c);
str = e <= TO_EXP_NEG || e >= TO_EXP_POS
? toExponential(str, e)
: toFixedPoint(str, e, '0');
return n.s < 0 ? '-' + str : str;
}
// PROTOTYPE/INSTANCE METHODS
/*
* Return a new BigNumber whose value is the absolute value of this BigNumber.
*/
P.absoluteValue = P.abs = function () {
var x = new BigNumber(this);
if (x.s < 0) x.s = 1;
return x;
};
/*
* Return
* 1 if the value of this BigNumber is greater than the value of BigNumber(y, b),
* -1 if the value of this BigNumber is less than the value of BigNumber(y, b),
* 0 if they have the same value,
* or null if the value of either is NaN.
*/
P.comparedTo = function (y, b) {
return compare(this, new BigNumber(y, b));
};
/*
* If dp is undefined or null or true or false, return the number of decimal places of the
* value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN.
*
* Otherwise, if dp is a number, return a new BigNumber whose value is the value of this
* BigNumber rounded to a maximum of dp decimal places using rounding mode rm, or
* ROUNDING_MODE if rm is omitted.
*
* [dp] {number} Decimal places: integer, 0 to MAX inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
*/
P.decimalPlaces = P.dp = function (dp, rm) {
var c, n, v,
x = this;
if (dp != null) {
intCheck(dp, 0, MAX);
if (rm == null) rm = ROUNDING_MODE;
else intCheck(rm, 0, 8);
return round(new BigNumber(x), dp + x.e + 1, rm);
}
if (!(c = x.c)) return null;
n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
// Subtract the number of trailing zeros of the last number.
if (v = c[v]) for (; v % 10 == 0; v /= 10, n--);
if (n < 0) n = 0;
return n;
};
/*
* n / 0 = I
* n / N = N
* n / I = 0
* 0 / n = 0
* 0 / 0 = N
* 0 / N = N
* 0 / I = 0
* N / n = N
* N / 0 = N
* N / N = N
* N / I = N
* I / n = I
* I / 0 = I
* I / N = N
* I / I = N
*
* Return a new BigNumber whose value is the value of this BigNumber divided by the value of
* BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE.
*/
P.dividedBy = P.div = function (y, b) {
return div(this, new BigNumber(y, b), DECIMAL_PLACES, ROUNDING_MODE);
};
/*
* Return a new BigNumber whose value is the integer part of dividing the value of this
* BigNumber by the value of BigNumber(y, b).
*/
P.dividedToIntegerBy = P.idiv = function (y, b) {
return div(this, new BigNumber(y, b), 0, 1);
};
/*
* Return a BigNumber whose value is the value of this BigNumber exponentiated by n.
*
* If m is present, return the result modulo m.
* If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE.
* If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using ROUNDING_MODE.
*
* The modular power operation works efficiently when x, n, and m are integers, otherwise it
* is equivalent to calculating x.exponentiatedBy(n).modulo(m) with a POW_PRECISION of 0.
*
* n {number|string|BigNumber} The exponent. An integer.
* [m] {number|string|BigNumber} The modulus.
*
* '[BigNumber Error] Exponent not an integer: {n}'
*/
P.exponentiatedBy = P.pow = function (n, m) {
var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y,
x = this;
n = new BigNumber(n);
// Allow NaN and ±Infinity, but not other non-integers.
if (n.c && !n.isInteger()) {
throw Error
(bignumberError + 'Exponent not an integer: ' + valueOf(n));
}
if (m != null) m = new BigNumber(m);
// Exponent of MAX_SAFE_INTEGER is 15.
nIsBig = n.e > 14;
// If x is NaN, ±Infinity, ±0 or ±1, or n is ±Infinity, NaN or ±0.
if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) {
// The sign of the result of pow when x is negative depends on the evenness of n.
// If +n overflows to ±Infinity, the evenness of n would be not be known.
y = new BigNumber(Math.pow(+valueOf(x), nIsBig ? 2 - isOdd(n) : +valueOf(n)));
return m ? y.mod(m) : y;
}
nIsNeg = n.s < 0;
if (m) {
// x % m returns NaN if abs(m) is zero, or m is NaN.
if (m.c ? !m.c[0] : !m.s) return new BigNumber(NaN);
isModExp = !nIsNeg && x.isInteger() && m.isInteger();
if (isModExp) x = x.mod(m);
// Overflow to ±Infinity: >=2**1e10 or >=1.0000024**1e15.
// Underflow to ±0: <=0.79**1e10 or <=0.9999975**1e15.
} else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0
// [1, 240000000]
? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7
// [80000000000000] [99999750000000]
: x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) {
// If x is negative and n is odd, k = -0, else k = 0.
k = x.s < 0 && isOdd(n) ? -0 : 0;
// If x >= 1, k = ±Infinity.
if (x.e > -1) k = 1 / k;
// If n is negative return ±0, else return ±Infinity.
return new BigNumber(nIsNeg ? 1 / k : k);
} else if (POW_PRECISION) {
// Truncating each coefficient array to a length of k after each multiplication
// equates to truncating significant digits to POW_PRECISION + [28, 41],
// i.e. there will be a minimum of 28 guard digits retained.
k = mathceil(POW_PRECISION / LOG_BASE + 2);
}
if (nIsBig) {
half = new BigNumber(0.5);
if (nIsNeg) n.s = 1;
nIsOdd = isOdd(n);
} else {
i = Math.abs(+valueOf(n));
nIsOdd = i % 2;
}
y = new BigNumber(ONE);
// Performs 54 loop iterations for n of 9007199254740991.
for (; ;) {
if (nIsOdd) {
y = y.times(x);
if (!y.c) break;
if (k) {
if (y.c.length > k) y.c.length = k;
} else if (isModExp) {
y = y.mod(m); //y = y.minus(div(y, m, 0, MODULO_MODE).times(m));
}
}
if (i) {
i = mathfloor(i / 2);
if (i === 0) break;
nIsOdd = i % 2;
} else {
n = n.times(half);
round(n, n.e + 1, 1);
if (n.e > 14) {
nIsOdd = isOdd(n);
} else {
i = +valueOf(n);
if (i === 0) break;
nIsOdd = i % 2;
}
}
x = x.times(x);
if (k) {
if (x.c && x.c.length > k) x.c.length = k;
} else if (isModExp) {
x = x.mod(m); //x = x.minus(div(x, m, 0, MODULO_MODE).times(m));
}
}
if (isModExp) return y;
if (nIsNeg) y = ONE.div(y);
return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y;
};
/*
* Return a new BigNumber whose value is the value of this BigNumber rounded to an integer
* using rounding mode rm, or ROUNDING_MODE if rm is omitted.
*
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {rm}'
*/
P.integerValue = function (rm) {
var n = new BigNumber(this);
if (rm == null) rm = ROUNDING_MODE;
else intCheck(rm, 0, 8);
return round(n, n.e + 1, rm);
};
/*
* Return true if the value of this BigNumber is equal to the value of BigNumber(y, b),
* otherwise return false.
*/
P.isEqualTo = P.eq = function (y, b) {
return compare(this, new BigNumber(y, b)) === 0;
};
/*
* Return true if the value of this BigNumber is a finite number, otherwise return false.
*/
P.isFinite = function () {
return !!this.c;
};
/*
* Return true if the value of this BigNumber is greater than the value of BigNumber(y, b),
* otherwise return false.
*/
P.isGreaterThan = P.gt = function (y, b) {
return compare(this, new BigNumber(y, b)) > 0;
};
/*
* Return true if the value of this BigNumber is greater than or equal to the value of
* BigNumber(y, b), otherwise return false.
*/
P.isGreaterThanOrEqualTo = P.gte = function (y, b) {
return (b = compare(this, new BigNumber(y, b))) === 1 || b === 0;
};
/*
* Return true if the value of this BigNumber is an integer, otherwise return false.
*/
P.isInteger = function () {
return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
};
/*
* Return true if the value of this BigNumber is less than the value of BigNumber(y, b),
* otherwise return false.
*/
P.isLessThan = P.lt = function (y, b) {
return compare(this, new BigNumber(y, b)) < 0;
};
/*
* Return true if the value of this BigNumber is less than or equal to the value of
* BigNumber(y, b), otherwise return false.
*/
P.isLessThanOrEqualTo = P.lte = function (y, b) {
return (b = compare(this, new BigNumber(y, b))) === -1 || b === 0;
};
/*
* Return true if the value of this BigNumber is NaN, otherwise return false.
*/
P.isNaN = function () {
return !this.s;
};
/*
* Return true if the value of this BigNumber is negative, otherwise return false.
*/
P.isNegative = function () {
return this.s < 0;
};
/*
* Return true if the value of this BigNumber is positive, otherwise return false.
*/
P.isPositive = function () {
return this.s > 0;
};
/*
* Return true if the value of this BigNumber is 0 or -0, otherwise return false.
*/
P.isZero = function () {
return !!this.c && this.c[0] == 0;
};
/*
* n - 0 = n
* n - N = N
* n - I = -I
* 0 - n = -n
* 0 - 0 = 0
* 0 - N = N
* 0 - I = -I
* N - n = N
* N - 0 = N
* N - N = N
* N - I = N
* I - n = I
* I - 0 = I
* I - N = N
* I - I = N
*
* Return a new BigNumber whose value is the value of this BigNumber minus the value of
* BigNumber(y, b).
*/
P.minus = function (y, b) {
var i, j, t, xLTy,
x = this,
a = x.s;
y = new BigNumber(y, b);
b = y.s;
// Either NaN?
if (!a || !b) return new BigNumber(NaN);
// Signs differ?
if (a != b) {
y.s = -b;
return x.plus(y);
}
var xe = x.e / LOG_BASE,
ye = y.e / LOG_BASE,
xc = x.c,
yc = y.c;
if (!xe || !ye) {
// Either Infinity?
if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber(yc ? x : NaN);
// Either zero?
if (!xc[0] || !yc[0]) {
// Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
return yc[0] ? (y.s = -b, y) : new BigNumber(xc[0] ? x :
// IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
ROUNDING_MODE == 3 ? -0 : 0);
}
}
xe = bitFloor(xe);
ye = bitFloor(ye);
xc = xc.slice();
// Determine which is the bigger number.
if (a = xe - ye) {
if (xLTy = a < 0) {
a = -a;
t = xc;
} else {
ye = xe;
t = yc;
}
t.reverse();
// Prepend zeros to equalise exponents.
for (b = a; b--; t.push(0));
t.reverse();
} else {
// Exponents equal. Check digit by digit.
j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b;
for (a = b = 0; b < j; b++) {
if (xc[b] != yc[b]) {
xLTy = xc[b] < yc[b];
break;
}
}
}
// x < y? Point xc to the array of the bigger number.
if (xLTy) t = xc, xc = yc, yc = t, y.s = -y.s;
b = (j = yc.length) - (i = xc.length);
// Append zeros to xc if shorter.
// No need to add zeros to yc if shorter as subtract only needs to start at yc.length.
if (b > 0) for (; b--; xc[i++] = 0);
b = BASE - 1;
// Subtract yc from xc.
for (; j > a;) {
if (xc[--j] < yc[j]) {
for (i = j; i && !xc[--i]; xc[i] = b);
--xc[i];
xc[j] += BASE;
}
xc[j] -= yc[j];
}
// Remove leading zeros and adjust exponent accordingly.
for (; xc[0] == 0; xc.splice(0, 1), --ye);
// Zero?
if (!xc[0]) {
// Following IEEE 754 (2008) 6.3,
// n - n = +0 but n - n = -0 when rounding towards -Infinity.
y.s = ROUNDING_MODE == 3 ? -1 : 1;
y.c = [y.e = 0];
return y;
}
// No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity
// for finite x and y.
return normalise(y, xc, ye);
};
/*
* n % 0 = N
* n % N = N
* n % I = n
* 0 % n = 0
* -0 % n = -0
* 0 % 0 = N
* 0 % N = N
* 0 % I = 0
* N % n = N
* N % 0 = N
* N % N = N
* N % I = N
* I % n = N
* I % 0 = N
* I % N = N
* I % I = N
*
* Return a new BigNumber whose value is the value of this BigNumber modulo the value of
* BigNumber(y, b). The result depends on the value of MODULO_MODE.
*/
P.modulo = P.mod = function (y, b) {
var q, s,
x = this;
y = new BigNumber(y, b);
// Return NaN if x is Infinity or NaN, or y is NaN or zero.
if (!x.c || !y.s || y.c && !y.c[0]) {
return new BigNumber(NaN);
// Return x if y is Infinity or x is zero.
} else if (!y.c || x.c && !x.c[0]) {
return new BigNumber(x);
}
if (MODULO_MODE == 9) {
// Euclidian division: q = sign(y) * floor(x / abs(y))
// r = x - qy where 0 <= r < abs(y)
s = y.s;
y.s = 1;
q = div(x, y, 0, 3);
y.s = s;
q.s *= s;
} else {
q = div(x, y, 0, MODULO_MODE);
}
y = x.minus(q.times(y));
// To match JavaScript %, ensure sign of zero is sign of dividend.
if (!y.c[0] && MODULO_MODE == 1) y.s = x.s;
return y;
};
/*
* n * 0 = 0
* n * N = N
* n * I = I
* 0 * n = 0
* 0 * 0 = 0
* 0 * N = N
* 0 * I = N
* N * n = N
* N * 0 = N
* N * N = N
* N * I = N
* I * n = I
* I * 0 = N
* I * N = N
* I * I = I
*
* Return a new BigNumber whose value is the value of this BigNumber multiplied by the value
* of BigNumber(y, b).
*/
P.multipliedBy = P.times = function (y, b) {
var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc,
base, sqrtBase,
x = this,
xc = x.c,
yc = (y = new BigNumber(y, b)).c;
// Either NaN, ±Infinity or ±0?
if (!xc || !yc || !xc[0] || !yc[0]) {
// Return NaN if either is NaN, or one is 0 and the other is Infinity.
if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
y.c = y.e = y.s = null;
} else {
y.s *= x.s;
// Return ±Infinity if either is ±Infinity.
if (!xc || !yc) {
y.c = y.e = null;
// Return ±0 if either is ±0.
} else {
y.c = [0];
y.e = 0;
}
}
return y;
}
e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE);
y.s *= x.s;
xcL = xc.length;
ycL = yc.length;
// Ensure xc points to longer array and xcL to its length.
if (xcL < ycL) zc = xc, xc = yc, yc = zc, i = xcL, xcL = ycL, ycL = i;
// Initialise the result array with zeros.
for (i = xcL + ycL, zc = []; i--; zc.push(0));
base = BASE;
sqrtBase = SQRT_BASE;
for (i = ycL; --i >= 0;) {
c = 0;
ylo = yc[i] % sqrtBase;
yhi = yc[i] / sqrtBase | 0;
for (k = xcL, j = i + k; j > i;) {
xlo = xc[--k] % sqrtBase;
xhi = xc[k] / sqrtBase | 0;
m = yhi * xlo + xhi * ylo;
xlo = ylo * xlo + ((m % sqrtBase) * sqrtBase) + zc[j] + c;
c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi;
zc[j--] = xlo % base;
}
zc[j] = c;
}
if (c) {
++e;
} else {
zc.splice(0, 1);
}
return normalise(y, zc, e);
};
/*
* Return a new BigNumber whose value is the value of this BigNumber negated,
* i.e. multiplied by -1.
*/
P.negated = function () {
var x = new BigNumber(this);
x.s = -x.s || null;
return x;
};
/*
* n + 0 = n
* n + N = N
* n + I = I
* 0 + n = n
* 0 + 0 = 0
* 0 + N = N
* 0 + I = I
* N + n = N
* N + 0 = N
* N + N = N
* N + I = N
* I + n = I
* I + 0 = I
* I + N = N
* I + I = I
*
* Return a new BigNumber whose value is the value of this BigNumber plus the value of
* BigNumber(y, b).
*/
P.plus = function (y, b) {
var t,
x = this,
a = x.s;
y = new BigNumber(y, b);
b = y.s;
// Either NaN?
if (!a || !b) return new BigNumber(NaN);
// Signs differ?
if (a != b) {
y.s = -b;
return x.minus(y);
}
var xe = x.e / LOG_BASE,
ye = y.e / LOG_BASE,
xc = x.c,
yc = y.c;
if (!xe || !ye) {
// Return ±Infinity if either ±Infinity.
if (!xc || !yc) return new BigNumber(a / 0);
// Either zero?
// Return y if y is non-zero, x if x is non-zero, or zero if both are zero.
if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber(xc[0] ? x : a * 0);
}
xe = bitFloor(xe);
ye = bitFloor(ye);
xc = xc.slice();
// Prepend zeros to equalise exponents. Faster to use reverse then do unshifts.
if (a = xe - ye) {
if (a > 0) {
ye = xe;
t = yc;
} else {
a = -a;
t = xc;
}
t.reverse();
for (; a--; t.push(0));
t.reverse();
}
a = xc.length;
b = yc.length;
// Point xc to the longer array, and b to the shorter length.
if (a - b < 0) t = yc, yc = xc, xc = t, b = a;
// Only start adding at yc.length - 1 as the further digits of xc can be ignored.
for (a = 0; b;) {
a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0;
xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE;
}
if (a) {
xc = [a].concat(xc);
++ye;
}
// No need to check for zero, as +x + +y != 0 && -x + -y != 0
// ye = MAX_EXP + 1 possible
return normalise(y, xc, ye);
};
/*
* If sd is undefined or null or true or false, return the number of significant digits of
* the value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN.
* If sd is true include integer-part trailing zeros in the count.
*
* Otherwise, if sd is a number, return a new BigNumber whose value is the value of this
* BigNumber rounded to a maximum of sd significant digits using rounding mode rm, or
* ROUNDING_MODE if rm is omitted.
*
* sd {number|boolean} number: significant digits: integer, 1 to MAX inclusive.
* boolean: whether to count integer-part trailing zeros: true or false.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}'
*/
P.precision = P.sd = function (sd, rm) {
var c, n, v,
x = this;
if (sd != null && sd !== !!sd) {
intCheck(sd, 1, MAX);
if (rm == null) rm = ROUNDING_MODE;
else intCheck(rm, 0, 8);
return round(new BigNumber(x), sd, rm);
}
if (!(c = x.c)) return null;
v = c.length - 1;
n = v * LOG_BASE + 1;
if (v = c[v]) {
// Subtract the number of trailing zeros of the last element.
for (; v % 10 == 0; v /= 10, n--);
// Add the number of digits of the first element.
for (v = c[0]; v >= 10; v /= 10, n++);
}
if (sd && x.e + 1 > n) n = x.e + 1;
return n;
};
/*
* Return a new BigNumber whose value is the value of this BigNumber shifted by k places
* (powers of 10). Shift to the right if n > 0, and to the left if n < 0.
*
* k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {k}'
*/
P.shiftedBy = function (k) {
intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
return this.times('1e' + k);
};
/*
* sqrt(-n) = N
* sqrt(N) = N
* sqrt(-I) = N
* sqrt(I) = I
* sqrt(0) = 0
* sqrt(-0) = -0
*
* Return a new BigNumber whose value is the square root of the value of this BigNumber,
* rounded according to DECIMAL_PLACES and ROUNDING_MODE.
*/
P.squareRoot = P.sqrt = function () {
var m, n, r, rep, t,
x = this,
c = x.c,
s = x.s,
e = x.e,
dp = DECIMAL_PLACES + 4,
half = new BigNumber('0.5');
// Negative/NaN/Infinity/zero?
if (s !== 1 || !c || !c[0]) {
return new BigNumber(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0);
}
// Initial estimate.
s = Math.sqrt(+valueOf(x));
// Math.sqrt underflow/overflow?
// Pass x to Math.sqrt as integer, then adjust the exponent of the result.
if (s == 0 || s == 1 / 0) {
n = coeffToString(c);
if ((n.length + e) % 2 == 0) n += '0';
s = Math.sqrt(+n);
e = bitFloor((e + 1) / 2) - (e < 0 || e % 2);
if (s == 1 / 0) {
n = '1e' + e;
} else {
n = s.toExponential();
n = n.slice(0, n.indexOf('e') + 1) + e;
}
r = new BigNumber(n);
} else {
r = new BigNumber(s + '');
}
// Check for zero.
// r could be zero if MIN_EXP is changed after the this value was created.
// This would cause a division by zero (x/t) and hence Infinity below, which would cause
// coeffToString to throw.
if (r.c[0]) {
e = r.e;
s = e + dp;
if (s < 3) s = 0;
// Newton-Raphson iteration.
for (; ;) {
t = r;
r = half.times(t.plus(div(x, t, dp, 1)));
if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) {
// The exponent of r may here be one less than the final result exponent,
// e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits
// are indexed correctly.
if (r.e < e) --s;
n = n.slice(s - 3, s + 1);
// The 4th rounding digit may be in error by -1 so if the 4 rounding digits
// are 9999 or 4999 (i.e. approaching a rounding boundary) continue the
// iteration.
if (n == '9999' || !rep && n == '4999') {
// On the first iteration only, check to see if rounding up gives the
// exact result as the nines may infinitely repeat.
if (!rep) {
round(t, t.e + DECIMAL_PLACES + 2, 0);
if (t.times(t).eq(x)) {
r = t;
break;
}
}
dp += 4;
s += 4;
rep = 1;
} else {
// If rounding digits are null, 0{0,4} or 50{0,3}, check for exact
// result. If not, then there are further digits and m will be truthy.
if (!+n || !+n.slice(1) && n.charAt(0) == '5') {
// Truncate to the first rounding digit.
round(r, r.e + DECIMAL_PLACES + 2, 1);
m = !r.times(r).eq(x);
}
break;
}
}
}
}
return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m);
};
/*
* Return a string representing the value of this BigNumber in exponential notation and
* rounded using ROUNDING_MODE to dp fixed decimal places.
*
* [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
*/
P.toExponential = function (dp, rm) {
if (dp != null) {
intCheck(dp, 0, MAX);
dp++;
}
return format(this, dp, rm, 1);
};
/*
* Return a string representing the value of this BigNumber in fixed-point notation rounding
* to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted.
*
* Note: as with JavaScript's number type, (-0).toFixed(0) is '0',
* but e.g. (-0.00001).toFixed(0) is '-0'.
*
* [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
*/
P.toFixed = function (dp, rm) {
if (dp != null) {
intCheck(dp, 0, MAX);
dp = dp + this.e + 1;
}
return format(this, dp, rm);
};
/*
* Return a string representing the value of this BigNumber in fixed-point notation rounded
* using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties
* of the format or FORMAT object (see BigNumber.set).
*
* The formatting object may contain some or all of the properties shown below.
*
* FORMAT = {
* prefix: '',
* groupSize: 3,
* secondaryGroupSize: 0,
* groupSeparator: ',',
* decimalSeparator: '.',
* fractionGroupSize: 0,
* fractionGroupSeparator: '\xA0', // non-breaking space
* suffix: ''
* };
*
* [dp] {number} Decimal places. Integer, 0 to MAX inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
* [format] {object} Formatting options. See FORMAT pbject above.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}'
* '[BigNumber Error] Argument not an object: {format}'
*/
P.toFormat = function (dp, rm, format) {
var str,
x = this;
if (format == null) {
if (dp != null && rm && typeof rm == 'object') {
format = rm;
rm = null;
} else if (dp && typeof dp == 'object') {
format = dp;
dp = rm = null;
} else {
format = FORMAT;
}
} else if (typeof format != 'object') {
throw Error
(bignumberError + 'Argument not an object: ' + format);
}
str = x.toFixed(dp, rm);
if (x.c) {
var i,
arr = str.split('.'),
g1 = +format.groupSize,
g2 = +format.secondaryGroupSize,
groupSeparator = format.groupSeparator || '',
intPart = arr[0],
fractionPart = arr[1],
isNeg = x.s < 0,
intDigits = isNeg ? intPart.slice(1) : intPart,
len = intDigits.length;
if (g2) i = g1, g1 = g2, g2 = i, len -= i;
if (g1 > 0 && len > 0) {
i = len % g1 || g1;
intPart = intDigits.substr(0, i);
for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1);
if (g2 > 0) intPart += groupSeparator + intDigits.slice(i);
if (isNeg) intPart = '-' + intPart;
}
str = fractionPart
? intPart + (format.decimalSeparator || '') + ((g2 = +format.fractionGroupSize)
? fractionPart.replace(new RegExp('\\d{' + g2 + '}\\B', 'g'),
'$&' + (format.fractionGroupSeparator || ''))
: fractionPart)
: intPart;
}
return (format.prefix || '') + str + (format.suffix || '');
};
/*
* Return an array of two BigNumbers representing the value of this BigNumber as a simple
* fraction with an integer numerator and an integer denominator.
* The denominator will be a positive non-zero value less than or equal to the specified
* maximum denominator. If a maximum denominator is not specified, the denominator will be
* the lowest value necessary to represent the number exactly.
*
* [md] {number|string|BigNumber} Integer >= 1, or Infinity. The maximum denominator.
*
* '[BigNumber Error] Argument {not an integer|out of range} : {md}'
*/
P.toFraction = function (md) {
var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s,
x = this,
xc = x.c;
if (md != null) {
n = new BigNumber(md);
// Throw if md is less than one or is not an integer, unless it is Infinity.
if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) {
throw Error
(bignumberError + 'Argument ' +
(n.isInteger() ? 'out of range: ' : 'not an integer: ') + valueOf(n));
}
}
if (!xc) return new BigNumber(x);
d = new BigNumber(ONE);
n1 = d0 = new BigNumber(ONE);
d1 = n0 = new BigNumber(ONE);
s = coeffToString(xc);
// Determine initial denominator.
// d is a power of 10 and the minimum max denominator that specifies the value exactly.
e = d.e = s.length - x.e - 1;
d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp];
md = !md || n.comparedTo(d) > 0 ? (e > 0 ? d : n1) : n;
exp = MAX_EXP;
MAX_EXP = 1 / 0;
n = new BigNumber(s);
// n0 = d1 = 0
n0.c[0] = 0;
for (; ;) {
q = div(n, d, 0, 1);
d2 = d0.plus(q.times(d1));
if (d2.comparedTo(md) == 1) break;
d0 = d1;
d1 = d2;
n1 = n0.plus(q.times(d2 = n1));
n0 = d2;
d = n.minus(q.times(d2 = d));
n = d2;
}
d2 = div(md.minus(d0), d1, 0, 1);
n0 = n0.plus(d2.times(n1));
d0 = d0.plus(d2.times(d1));
n0.s = n1.s = x.s;
e = e * 2;
// Determine which fraction is closer to x, n0/d0 or n1/d1
r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo(
div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
MAX_EXP = exp;
return r;
};
/*
* Return the value of this BigNumber converted to a number primitive.
*/
P.toNumber = function () {
return +valueOf(this);
};
/*
* Return a string representing the value of this BigNumber rounded to sd significant digits
* using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits
* necessary to represent the integer part of the value in fixed-point notation, then use
* exponential notation.
*
* [sd] {number} Significant digits. Integer, 1 to MAX inclusive.
* [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
*
* '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}'
*/
P.toPrecision = function (sd, rm) {
if (sd != null) intCheck(sd, 1, MAX);
return format(this, sd, rm, 2);
};
/*
* Return a string representing the value of this BigNumber in base b, or base 10 if b is
* omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and
* ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent
* that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than
* TO_EXP_NEG, return exponential notation.
*
* [b] {number} Integer, 2 to ALPHABET.length inclusive.
*
* '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}'
*/
P.toString = function (b) {
var str,
n = this,
s = n.s,
e = n.e;
// Infinity or NaN?
if (e === null) {
if (s) {
str = 'Infinity';
if (s < 0) str = '-' + str;
} else {
str = 'NaN';
}
} else {
if (b == null) {
str = e <= TO_EXP_NEG || e >= TO_EXP_POS
? toExponential(coeffToString(n.c), e)
: toFixedPoint(coeffToString(n.c), e, '0');
} else if (b === 10) {
n = round(new BigNumber(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE);
str = toFixedPoint(coeffToString(n.c), n.e, '0');
} else {
intCheck(b, 2, ALPHABET.length, 'Base');
str = convertBase(toFixedPoint(coeffToString(n.c), e, '0'), 10, b, s, true);
}
if (s < 0 && n.c[0]) str = '-' + str;
}
return str;
};
/*
* Return as toString, but do not accept a base argument, and include the minus sign for
* negative zero.
*/
P.valueOf = P.toJSON = function () {
return valueOf(this);
};
P._isBigNumber = true;
P[Symbol.toStringTag] = 'BigNumber';
// Node.js v10.12.0+
P[Symbol.for('nodejs.util.inspect.custom')] = P.valueOf;
if (configObject != null) BigNumber.set(configObject);
return BigNumber;
}
// PRIVATE HELPER FUNCTIONS
// These functions don't need access to variables,
// e.g. DECIMAL_PLACES, in the scope of the `clone` function above.
function bitFloor(n) {
var i = n | 0;
return n > 0 || n === i ? i : i - 1;
}
// Return a coefficient array as a string of base 10 digits.
function coeffToString(a) {
var s, z,
i = 1,
j = a.length,
r = a[0] + '';
for (; i < j;) {
s = a[i++] + '';
z = LOG_BASE - s.length;
for (; z--; s = '0' + s);
r += s;
}
// Determine trailing zeros.
for (j = r.length; r.charCodeAt(--j) === 48;);
return r.slice(0, j + 1 || 1);
}
// Compare the value of BigNumbers x and y.
function compare(x, y) {
var a, b,
xc = x.c,
yc = y.c,
i = x.s,
j = y.s,
k = x.e,
l = y.e;
// Either NaN?
if (!i || !j) return null;
a = xc && !xc[0];
b = yc && !yc[0];
// Either zero?
if (a || b) return a ? b ? 0 : -j : i;
// Signs differ?
if (i != j) return i;
a = i < 0;
b = k == l;
// Either Infinity?
if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1;
// Compare exponents.
if (!b) return k > l ^ a ? 1 : -1;
j = (k = xc.length) < (l = yc.length) ? k : l;
// Compare digit by digit.
for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1;
// Compare lengths.
return k == l ? 0 : k > l ^ a ? 1 : -1;
}
/*
* Check that n is a primitive number, an integer, and in range, otherwise throw.
*/
function intCheck(n, min, max, name) {
if (n < min || n > max || n !== mathfloor(n)) {
throw Error
(bignumberError + (name || 'Argument') + (typeof n == 'number'
? n < min || n > max ? ' out of range: ' : ' not an integer: '
: ' not a primitive number: ') + String(n));
}
}
// Assumes finite n.
function isOdd(n) {
var k = n.c.length - 1;
return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0;
}
function toExponential(str, e) {
return (str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str) +
(e < 0 ? 'e' : 'e+') + e;
}
function toFixedPoint(str, e, z) {
var len, zs;
// Negative exponent?
if (e < 0) {
// Prepend zeros.
for (zs = z + '.'; ++e; zs += z);
str = zs + str;
// Positive exponent
} else {
len = str.length;
// Append zeros.
if (++e > len) {
for (zs = z, e -= len; --e; zs += z);
str += zs;
} else if (e < len) {
str = str.slice(0, e) + '.' + str.slice(e);
}
}
return str;
}
// EXPORT
export var BigNumber = clone();
export default BigNumber;
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="Author" content="M Mclaughlin">
<title>bignumber.js API</title>
<style>
html{font-size:100%}
body{background:#fff;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;
line-height:1.65em;min-height:100%;margin:0}
body,i{color:#000}
.nav{background:#fff;position:fixed;top:0;bottom:0;left:0;width:200px;overflow-y:auto;
padding:15px 0 30px 15px}
div.container{width:600px;margin:50px 0 50px 240px}
p{margin:0 0 1em;width:600px}
pre,ul{margin:1em 0}
h1,h2,h3,h4,h5{margin:0;padding:1.5em 0 0}
h1,h2{padding:.75em 0}
h1{font:400 3em Verdana,sans-serif;color:#000;margin-bottom:1em}
h2{font-size:2.25em;color:#ff2a00}
h3{font-size:1.75em;color:#4dc71f}
h4{font-size:1.75em;color:#ff2a00;padding-bottom:.75em}
h5{font-size:1.2em;margin-bottom:.4em}
h6{font-size:1.1em;margin-bottom:0.8em;padding:0.5em 0}
dd{padding-top:.35em}
dt{padding-top:.5em}
b{font-weight:700}
dt b{font-size:1.3em}
a,a:visited{color:#ff2a00;text-decoration:none}
a:active,a:hover{outline:0;text-decoration:underline}
.nav a,.nav b,.nav a:visited{display:block;color:#ff2a00;font-weight:700; margin-top:15px}
.nav b{color:#4dc71f;margin-top:20px;cursor:default;width:auto}
ul{list-style-type:none;padding:0 0 0 20px}
.nav ul{line-height:14px;padding-left:0;margin:5px 0 0}
.nav ul a,.nav ul a:visited,span{display:inline;color:#000;font-family:Verdana,Geneva,sans-serif;
font-size:11px;font-weight:400;margin:0}
.inset,ul.inset{margin-left:20px}
.inset{font-size:.9em}
.nav li{width:auto;margin:0 0 3px}
.alias{font-style:italic;margin-left:20px}
table{border-collapse:collapse;border-spacing:0;border:2px solid #a7dbd8;margin:1.75em 0;padding:0}
td,th{text-align:left;margin:0;padding:2px 5px;border:1px dotted #a7dbd8}
th{border-top:2px solid #a7dbd8;border-bottom:2px solid #a7dbd8;color:#ff2a00}
code,pre{font-family:Consolas, monaco, monospace;font-weight:400}
pre{background:#f5f5f5;white-space:pre-wrap;word-wrap:break-word;border-left:5px solid #abef98;
padding:1px 0 1px 15px;margin:1.2em 0}
code,.nav-title{color:#ff2a00}
.end{margin-bottom:25px}
.centre{text-align:center}
.error-table{font-size:13px;width:100%}
#faq{margin:3em 0 0}
li span{float:right;margin-right:10px;color:#c0c0c0}
#js{font:inherit;color:#4dc71f}
</style>
</head>
<body>
<div class="nav">
<b>v8.1.0</b>
<a class='nav-title' href="#">API</a>
<b> CONSTRUCTOR </b>
<ul>
<li><a href="#bignumber">BigNumber</a></li>
</ul>
<a href="#methods">Methods</a>
<ul>
<li><a href="#clone">clone</a></li>
<li><a href="#config" >config</a><span>set</span></li>
<li>
<ul class="inset">
<li><a href="#decimal-places">DECIMAL_PLACES</a></li>
<li><a href="#rounding-mode" >ROUNDING_MODE</a></li>
<li><a href="#exponential-at">EXPONENTIAL_AT</a></li>
<li><a href="#range" >RANGE</a></li>
<li><a href="#crypto" >CRYPTO</a></li>
<li><a href="#modulo-mode" >MODULO_MODE</a></li>
<li><a href="#pow-precision" >POW_PRECISION</a></li>
<li><a href="#format" >FORMAT</a></li>
<li><a href="#alphabet" >ALPHABET</a></li>
</ul>
</li>
<li><a href="#isBigNumber">isBigNumber</a></li>
<li><a href="#max" >maximum</a><span>max</span></li>
<li><a href="#min" >minimum</a><span>min</span></li>
<li><a href="#random" >random</a></li>
<li><a href="#sum" >sum</a></li>
</ul>
<a href="#constructor-properties">Properties</a>
<ul>
<li><a href="#round-up" >ROUND_UP</a></li>
<li><a href="#round-down" >ROUND_DOWN</a></li>
<li><a href="#round-ceil" >ROUND_CEIL</a></li>
<li><a href="#round-floor" >ROUND_FLOOR</a></li>
<li><a href="#round-half-up" >ROUND_HALF_UP</a></li>
<li><a href="#round-half-down" >ROUND_HALF_DOWN</a></li>
<li><a href="#round-half-even" >ROUND_HALF_EVEN</a></li>
<li><a href="#round-half-ceil" >ROUND_HALF_CEIL</a></li>
<li><a href="#round-half-floor">ROUND_HALF_FLOOR</a></li>
<li><a href="#debug" >DEBUG</a></li>
</ul>
<b> INSTANCE </b>
<a href="#prototype-methods">Methods</a>
<ul>
<li><a href="#abs" >absoluteValue </a><span>abs</span> </li>
<li><a href="#cmp" >comparedTo </a> </li>
<li><a href="#dp" >decimalPlaces </a><span>dp</span> </li>
<li><a href="#div" >dividedBy </a><span>div</span> </li>
<li><a href="#divInt" >dividedToIntegerBy </a><span>idiv</span> </li>
<li><a href="#pow" >exponentiatedBy </a><span>pow</span> </li>
<li><a href="#int" >integerValue </a> </li>
<li><a href="#eq" >isEqualTo </a><span>eq</span> </li>
<li><a href="#isF" >isFinite </a> </li>
<li><a href="#gt" >isGreaterThan </a><span>gt</span> </li>
<li><a href="#gte" >isGreaterThanOrEqualTo</a><span>gte</span> </li>
<li><a href="#isInt" >isInteger </a> </li>
<li><a href="#lt" >isLessThan </a><span>lt</span> </li>
<li><a href="#lte" >isLessThanOrEqualTo </a><span>lte</span> </li>
<li><a href="#isNaN" >isNaN </a> </li>
<li><a href="#isNeg" >isNegative </a> </li>
<li><a href="#isPos" >isPositive </a> </li>
<li><a href="#isZ" >isZero </a> </li>
<li><a href="#minus" >minus </a> </li>
<li><a href="#mod" >modulo </a><span>mod</span> </li>
<li><a href="#times" >multipliedBy </a><span>times</span></li>
<li><a href="#neg" >negated </a> </li>
<li><a href="#plus" >plus </a> </li>
<li><a href="#sd" >precision </a><span>sd</span> </li>
<li><a href="#shift" >shiftedBy </a> </li>
<li><a href="#sqrt" >squareRoot </a><span>sqrt</span> </li>
<li><a href="#toE" >toExponential </a> </li>
<li><a href="#toFix" >toFixed </a> </li>
<li><a href="#toFor" >toFormat </a> </li>
<li><a href="#toFr" >toFraction </a> </li>
<li><a href="#toJSON" >toJSON </a> </li>
<li><a href="#toN" >toNumber </a> </li>
<li><a href="#toP" >toPrecision </a> </li>
<li><a href="#toS" >toString </a> </li>
<li><a href="#valueOf">valueOf </a> </li>
</ul>
<a href="#instance-properties">Properties</a>
<ul>
<li><a href="#coefficient">c: coefficient</a></li>
<li><a href="#exponent" >e: exponent</a></li>
<li><a href="#sign" >s: sign</a></li>
</ul>
<a href="#zero-nan-infinity">Zero, NaN &amp; Infinity</a>
<a href="#Errors">Errors</a>
<a href="#type-coercion">Type coercion</a>
<a class='end' href="#faq">FAQ</a>
</div>
<div class="container">
<h1>bignumber<span id='js'>.js</span></h1>
<p>A JavaScript library for arbitrary-precision arithmetic.</p>
<p><a href="https://github.com/MikeMcl/bignumber.js">Hosted on GitHub</a>. </p>
<h2>API</h2>
<p>
See the <a href='https://github.com/MikeMcl/bignumber.js'>README</a> on GitHub for a
quick-start introduction.
</p>
<p>
In all examples below, <code>var</code> and semicolons are not shown, and if a commented-out
value is in quotes it means <code>toString</code> has been called on the preceding expression.
</p>
<h3>CONSTRUCTOR</h3>
<h5 id="bignumber">
BigNumber<code class='inset'>BigNumber(n [, base]) <i>&rArr; BigNumber</i></code>
</h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<code>base</code>: <i>number</i>: integer, <code>2</code> to <code>36</code> inclusive. (See
<a href='#alphabet'><code>ALPHABET</code></a> to extend this range).
</p>
<p>
Returns a new instance of a BigNumber object with value <code>n</code>, where <code>n</code>
is a numeric value in the specified <code>base</code>, or base <code>10</code> if
<code>base</code> is omitted or is <code>null</code> or <code>undefined</code>.
</p>
<pre>
x = new BigNumber(123.4567) // '123.4567'
// 'new' is optional
y = BigNumber(x) // '123.4567'</pre>
<p>
If <code>n</code> is a base <code>10</code> value it can be in normal (fixed-point) or
exponential notation. Values in other bases must be in normal notation. Values in any base can
have fraction digits, i.e. digits after the decimal point.
</p>
<pre>
new BigNumber(43210) // '43210'
new BigNumber('4.321e+4') // '43210'
new BigNumber('-735.0918e-430') // '-7.350918e-428'
new BigNumber('123412421.234324', 5) // '607236.557696'</pre>
<p>
Signed <code>0</code>, signed <code>Infinity</code> and <code>NaN</code> are supported.
</p>
<pre>
new BigNumber('-Infinity') // '-Infinity'
new BigNumber(NaN) // 'NaN'
new BigNumber(-0) // '0'
new BigNumber('.5') // '0.5'
new BigNumber('+2') // '2'</pre>
<p>
String values in hexadecimal literal form, e.g. <code>'0xff'</code>, are valid, as are
string values with the octal and binary prefixs <code>'0o'</code> and <code>'0b'</code>.
String values in octal literal form without the prefix will be interpreted as
decimals, e.g. <code>'011'</code> is interpreted as 11, not 9.
</p>
<pre>
new BigNumber(-10110100.1, 2) // '-180.5'
new BigNumber('-0b10110100.1') // '-180.5'
new BigNumber('ff.8', 16) // '255.5'
new BigNumber('0xff.8') // '255.5'</pre>
<p>
If a base is specified, <code>n</code> is rounded according to the current
<a href='#decimal-places'><code>DECIMAL_PLACES</code></a> and
<a href='#rounding-mode'><code>ROUNDING_MODE</code></a> settings. <em>This includes base
<code>10</code> so don't include a <code>base</code> parameter for decimal values unless
this behaviour is wanted.</em>
</p>
<pre>BigNumber.config({ DECIMAL_PLACES: 5 })
new BigNumber(1.23456789) // '1.23456789'
new BigNumber(1.23456789, 10) // '1.23457'</pre>
<p>An error is thrown if <code>base</code> is invalid. See <a href='#Errors'>Errors</a>.</p>
<p>
There is no limit to the number of digits of a value of type <em>string</em> (other than
that of JavaScript's maximum array size). See <a href='#range'><code>RANGE</code></a> to set
the maximum and minimum possible exponent value of a BigNumber.
</p>
<pre>
new BigNumber('5032485723458348569331745.33434346346912144534543')
new BigNumber('4.321e10000000')</pre>
<p>BigNumber <code>NaN</code> is returned if <code>n</code> is invalid
(unless <code>BigNumber.DEBUG</code> is <code>true</code>, see below).</p>
<pre>
new BigNumber('.1*') // 'NaN'
new BigNumber('blurgh') // 'NaN'
new BigNumber(9, 2) // 'NaN'</pre>
<p>
To aid in debugging, if <code>BigNumber.DEBUG</code> is <code>true</code> then an error will
be thrown on an invalid <code>n</code>. An error will also be thrown if <code>n</code> is of
type <em>number</em> with more than <code>15</code> significant digits, as calling
<code><a href='#toS'>toString</a></code> or <code><a href='#valueOf'>valueOf</a></code> on
these numbers may not result in the intended value.
</p>
<pre>
console.log(823456789123456.3) // 823456789123456.2
new BigNumber(823456789123456.3) // '823456789123456.2'
BigNumber.DEBUG = true
// '[BigNumber Error] Number primitive has more than 15 significant digits'
new BigNumber(823456789123456.3)
// '[BigNumber Error] Not a base 2 number'
new BigNumber(9, 2)</pre>
<p>
A BigNumber can also be created from an object literal.
Use <code><a href='#isBigNumber'>isBigNumber</a></code> to check that it is well-formed.
</p>
<pre>new BigNumber({ s: 1, e: 2, c: [ 777, 12300000000000 ], _isBigNumber: true }) // '777.123'</pre>
<h4 id="methods">Methods</h4>
<p>The static methods of a BigNumber constructor.</p>
<h5 id="clone">clone
<code class='inset'>.clone([object]) <i>&rArr; BigNumber constructor</i></code>
</h5>
<p><code>object</code>: <i>object</i></p>
<p>
Returns a new independent BigNumber constructor with configuration as described by
<code>object</code> (see <a href='#config'><code>config</code></a>), or with the default
configuration if <code>object</code> is <code>null</code> or <code>undefined</code>.
</p>
<p>
Throws if <code>object</code> is not an object. See <a href='#Errors'>Errors</a>.
</p>
<pre>BigNumber.config({ DECIMAL_PLACES: 5 })
BN = BigNumber.clone({ DECIMAL_PLACES: 9 })
x = new BigNumber(1)
y = new BN(1)
x.div(3) // 0.33333
y.div(3) // 0.333333333
// BN = BigNumber.clone({ DECIMAL_PLACES: 9 }) is equivalent to:
BN = BigNumber.clone()
BN.config({ DECIMAL_PLACES: 9 })</pre>
<h5 id="config">config<code class='inset'>set([object]) <i>&rArr; object</i></code></h5>
<p>
<code>object</code>: <i>object</i>: an object that contains some or all of the following
properties.
</p>
<p>Configures the settings for this particular BigNumber constructor.</p>
<dl class='inset'>
<dt id="decimal-places"><code><b>DECIMAL_PLACES</b></code></dt>
<dd>
<i>number</i>: integer, <code>0</code> to <code>1e+9</code> inclusive<br />
Default value: <code>20</code>
</dd>
<dd>
The <u>maximum</u> number of decimal places of the results of operations involving
division, i.e. division, square root and base conversion operations, and power
operations with negative exponents.<br />
</dd>
<dd>
<pre>BigNumber.config({ DECIMAL_PLACES: 5 })
BigNumber.set({ DECIMAL_PLACES: 5 }) // equivalent</pre>
</dd>
<dt id="rounding-mode"><code><b>ROUNDING_MODE</b></code></dt>
<dd>
<i>number</i>: integer, <code>0</code> to <code>8</code> inclusive<br />
Default value: <code>4</code> <a href="#round-half-up">(<code>ROUND_HALF_UP</code>)</a>
</dd>
<dd>
The rounding mode used in the above operations and the default rounding mode of
<a href='#dp'><code>decimalPlaces</code></a>,
<a href='#sd'><code>precision</code></a>,
<a href='#toE'><code>toExponential</code></a>,
<a href='#toFix'><code>toFixed</code></a>,
<a href='#toFor'><code>toFormat</code></a> and
<a href='#toP'><code>toPrecision</code></a>.
</dd>
<dd>The modes are available as enumerated properties of the BigNumber constructor.</dd>
<dd>
<pre>BigNumber.config({ ROUNDING_MODE: 0 })
BigNumber.set({ ROUNDING_MODE: BigNumber.ROUND_UP }) // equivalent</pre>
</dd>
<dt id="exponential-at"><code><b>EXPONENTIAL_AT</b></code></dt>
<dd>
<i>number</i>: integer, magnitude <code>0</code> to <code>1e+9</code> inclusive, or
<br />
<i>number</i>[]: [ integer <code>-1e+9</code> to <code>0</code> inclusive, integer
<code>0</code> to <code>1e+9</code> inclusive ]<br />
Default value: <code>[-7, 20]</code>
</dd>
<dd>
The exponent value(s) at which <code>toString</code> returns exponential notation.
</dd>
<dd>
If a single number is assigned, the value is the exponent magnitude.<br />
If an array of two numbers is assigned then the first number is the negative exponent
value at and beneath which exponential notation is used, and the second number is the
positive exponent value at and above which the same.
</dd>
<dd>
For example, to emulate JavaScript numbers in terms of the exponent values at which they
begin to use exponential notation, use <code>[-7, 20]</code>.
</dd>
<dd>
<pre>BigNumber.config({ EXPONENTIAL_AT: 2 })
new BigNumber(12.3) // '12.3' e is only 1
new BigNumber(123) // '1.23e+2'
new BigNumber(0.123) // '0.123' e is only -1
new BigNumber(0.0123) // '1.23e-2'
BigNumber.config({ EXPONENTIAL_AT: [-7, 20] })
new BigNumber(123456789) // '123456789' e is only 8
new BigNumber(0.000000123) // '1.23e-7'
// Almost never return exponential notation:
BigNumber.config({ EXPONENTIAL_AT: 1e+9 })
// Always return exponential notation:
BigNumber.config({ EXPONENTIAL_AT: 0 })</pre>
</dd>
<dd>
Regardless of the value of <code>EXPONENTIAL_AT</code>, the <code>toFixed</code> method
will always return a value in normal notation and the <code>toExponential</code> method
will always return a value in exponential form.
</dd>
<dd>
Calling <code>toString</code> with a base argument, e.g. <code>toString(10)</code>, will
also always return normal notation.
</dd>
<dt id="range"><code><b>RANGE</b></code></dt>
<dd>
<i>number</i>: integer, magnitude <code>1</code> to <code>1e+9</code> inclusive, or
<br />
<i>number</i>[]: [ integer <code>-1e+9</code> to <code>-1</code> inclusive, integer
<code>1</code> to <code>1e+9</code> inclusive ]<br />
Default value: <code>[-1e+9, 1e+9]</code>
</dd>
<dd>
The exponent value(s) beyond which overflow to <code>Infinity</code> and underflow to
zero occurs.
</dd>
<dd>
If a single number is assigned, it is the maximum exponent magnitude: values wth a
positive exponent of greater magnitude become <code>Infinity</code> and those with a
negative exponent of greater magnitude become zero.
<dd>
If an array of two numbers is assigned then the first number is the negative exponent
limit and the second number is the positive exponent limit.
</dd>
<dd>
For example, to emulate JavaScript numbers in terms of the exponent values at which they
become zero and <code>Infinity</code>, use <code>[-324, 308]</code>.
</dd>
<dd>
<pre>BigNumber.config({ RANGE: 500 })
BigNumber.config().RANGE // [ -500, 500 ]
new BigNumber('9.999e499') // '9.999e+499'
new BigNumber('1e500') // 'Infinity'
new BigNumber('1e-499') // '1e-499'
new BigNumber('1e-500') // '0'
BigNumber.config({ RANGE: [-3, 4] })
new BigNumber(99999) // '99999' e is only 4
new BigNumber(100000) // 'Infinity' e is 5
new BigNumber(0.001) // '0.01' e is only -3
new BigNumber(0.0001) // '0' e is -4</pre>
</dd>
<dd>
The largest possible magnitude of a finite BigNumber is
<code>9.999...e+1000000000</code>.<br />
The smallest possible magnitude of a non-zero BigNumber is <code>1e-1000000000</code>.
</dd>
<dt id="crypto"><code><b>CRYPTO</b></code></dt>
<dd>
<i>boolean</i>: <code>true</code> or <code>false</code>.<br />
Default value: <code>false</code>
</dd>
<dd>
The value that determines whether cryptographically-secure pseudo-random number
generation is used.
</dd>
<dd>
If <code>CRYPTO</code> is set to <code>true</code> then the
<a href='#random'><code>random</code></a> method will generate random digits using
<code>crypto.getRandomValues</code> in browsers that support it, or
<code>crypto.randomBytes</code> if using Node.js.
</dd>
<dd>
If neither function is supported by the host environment then attempting to set
<code>CRYPTO</code> to <code>true</code> will fail and an exception will be thrown.
</dd>
<dd>
If <code>CRYPTO</code> is <code>false</code> then the source of randomness used will be
<code>Math.random</code> (which is assumed to generate at least <code>30</code> bits of
randomness).
</dd>
<dd>See <a href='#random'><code>random</code></a>.</dd>
<dd>
<pre>
// Node.js
global.crypto = require('crypto')
BigNumber.config({ CRYPTO: true })
BigNumber.config().CRYPTO // true
BigNumber.random() // 0.54340758610486147524</pre>
</dd>
<dt id="modulo-mode"><code><b>MODULO_MODE</b></code></dt>
<dd>
<i>number</i>: integer, <code>0</code> to <code>9</code> inclusive<br />
Default value: <code>1</code> (<a href="#round-down"><code>ROUND_DOWN</code></a>)
</dd>
<dd>The modulo mode used when calculating the modulus: <code>a mod n</code>.</dd>
<dd>
The quotient, <code>q = a / n</code>, is calculated according to the
<a href='#rounding-mode'><code>ROUNDING_MODE</code></a> that corresponds to the chosen
<code>MODULO_MODE</code>.
</dd>
<dd>The remainder, <code>r</code>, is calculated as: <code>r = a - n * q</code>.</dd>
<dd>
The modes that are most commonly used for the modulus/remainder operation are shown in
the following table. Although the other rounding modes can be used, they may not give
useful results.
</dd>
<dd>
<table>
<tr><th>Property</th><th>Value</th><th>Description</th></tr>
<tr>
<td><b>ROUND_UP</b></td><td class='centre'>0</td>
<td>
The remainder is positive if the dividend is negative, otherwise it is negative.
</td>
</tr>
<tr>
<td><b>ROUND_DOWN</b></td><td class='centre'>1</td>
<td>
The remainder has the same sign as the dividend.<br />
This uses 'truncating division' and matches the behaviour of JavaScript's
remainder operator <code>%</code>.
</td>
</tr>
<tr>
<td><b>ROUND_FLOOR</b></td><td class='centre'>3</td>
<td>
The remainder has the same sign as the divisor.<br />
This matches Python's <code>%</code> operator.
</td>
</tr>
<tr>
<td><b>ROUND_HALF_EVEN</b></td><td class='centre'>6</td>
<td>The <i>IEEE 754</i> remainder function.</td>
</tr>
<tr>
<td><b>EUCLID</b></td><td class='centre'>9</td>
<td>
The remainder is always positive. Euclidian division: <br />
<code>q = sign(n) * floor(a / abs(n))</code>
</td>
</tr>
</table>
</dd>
<dd>
The rounding/modulo modes are available as enumerated properties of the BigNumber
constructor.
</dd>
<dd>See <a href='#mod'><code>modulo</code></a>.</dd>
<dd>
<pre>BigNumber.config({ MODULO_MODE: BigNumber.EUCLID })
BigNumber.config({ MODULO_MODE: 9 }) // equivalent</pre>
</dd>
<dt id="pow-precision"><code><b>POW_PRECISION</b></code></dt>
<dd>
<i>number</i>: integer, <code>0</code> to <code>1e+9</code> inclusive.<br />
Default value: <code>0</code>
</dd>
<dd>
The <i>maximum</i> precision, i.e. number of significant digits, of the result of the power
operation (unless a modulus is specified).
</dd>
<dd>If set to <code>0</code>, the number of significant digits will not be limited.</dd>
<dd>See <a href='#pow'><code>exponentiatedBy</code></a>.</dd>
<dd><pre>BigNumber.config({ POW_PRECISION: 100 })</pre></dd>
<dt id="format"><code><b>FORMAT</b></code></dt>
<dd><i>object</i></dd>
<dd>
The <code>FORMAT</code> object configures the format of the string returned by the
<a href='#toFor'><code>toFormat</code></a> method.
</dd>
<dd>
The example below shows the properties of the <code>FORMAT</code> object that are
recognised, and their default values.
</dd>
<dd>
Unlike the other configuration properties, the values of the properties of the
<code>FORMAT</code> object will not be checked for validity. The existing
<code>FORMAT</code> object will simply be replaced by the object that is passed in.
The object can include any number of the properties shown below.
</dd>
<dd>See <a href='#toFor'><code>toFormat</code></a> for examples of usage.</dd>
<dd>
<pre>
BigNumber.config({
FORMAT: {
// string to prepend
prefix: '',
// decimal separator
decimalSeparator: '.',
// grouping separator of the integer part
groupSeparator: ',',
// primary grouping size of the integer part
groupSize: 3,
// secondary grouping size of the integer part
secondaryGroupSize: 0,
// grouping separator of the fraction part
fractionGroupSeparator: ' ',
// grouping size of the fraction part
fractionGroupSize: 0,
// string to append
suffix: ''
}
});</pre>
</dd>
<dt id="alphabet"><code><b>ALPHABET</b></code></dt>
<dd>
<i>string</i><br />
Default value: <code>'0123456789abcdefghijklmnopqrstuvwxyz'</code>
</dd>
<dd>
The alphabet used for base conversion. The length of the alphabet corresponds to the
maximum value of the base argument that can be passed to the
<a href='#bignumber'><code>BigNumber</code></a> constructor or
<a href='#toS'><code>toString</code></a>.
</dd>
<dd>
There is no maximum length for the alphabet, but it must be at least 2 characters long, and
it must not contain whitespace or a repeated character, or the sign indicators
<code>'+'</code> and <code>'-'</code>, or the decimal separator <code>'.'</code>.
</dd>
<dd>
<pre>// duodecimal (base 12)
BigNumber.config({ ALPHABET: '0123456789TE' })
x = new BigNumber('T', 12)
x.toString() // '10'
x.toString(12) // 'T'</pre>
</dd>
</dl>
<br /><br />
<p>Returns an object with the above properties and their current values.</p>
<p>
Throws if <code>object</code> is not an object, or if an invalid value is assigned to
one or more of the above properties. See <a href='#Errors'>Errors</a>.
</p>
<pre>
BigNumber.config({
DECIMAL_PLACES: 40,
ROUNDING_MODE: BigNumber.ROUND_HALF_CEIL,
EXPONENTIAL_AT: [-10, 20],
RANGE: [-500, 500],
CRYPTO: true,
MODULO_MODE: BigNumber.ROUND_FLOOR,
POW_PRECISION: 80,
FORMAT: {
groupSize: 3,
groupSeparator: ' ',
decimalSeparator: ','
},
ALPHABET: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_'
});
obj = BigNumber.config();
obj.DECIMAL_PLACES // 40
obj.RANGE // [-500, 500]</pre>
<h5 id="isBigNumber">
isBigNumber<code class='inset'>.isBigNumber(value) <i>&rArr; boolean</i></code>
</h5>
<p><code>value</code>: <i>any</i><br /></p>
<p>
Returns <code>true</code> if <code>value</code> is a BigNumber instance, otherwise returns
<code>false</code>.
</p>
<pre>x = 42
y = new BigNumber(x)
BigNumber.isBigNumber(x) // false
y instanceof BigNumber // true
BigNumber.isBigNumber(y) // true
BN = BigNumber.clone();
z = new BN(x)
z instanceof BigNumber // false
BigNumber.isBigNumber(z) // true</pre>
<p>
If <code>value</code> is a BigNumber instance and <code>BigNumber.DEBUG</code> is <code>true</code>,
then this method will also check if <code>value</code> is well-formed, and throw if it is not.
See <a href='#Errors'>Errors</a>.
</p>
<p>
The check can be useful if creating a BigNumber from an object literal.
See <a href='#bignumber'>BigNumber</a>.
</p>
<pre>
x = new BigNumber(10)
// Change x.c to an illegitimate value.
x.c = NaN
BigNumber.DEBUG = false
// No error.
BigNumber.isBigNumber(x) // true
BigNumber.DEBUG = true
// Error.
BigNumber.isBigNumber(x) // '[BigNumber Error] Invalid BigNumber'</pre>
<h5 id="max">maximum<code class='inset'>.max(n...) <i>&rArr; BigNumber</i></code></h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<i>See <code><a href="#bignumber">BigNumber</a></code> for further parameter details.</i>
</p>
<p>
Returns a BigNumber whose value is the maximum of the arguments.
</p>
<p>The return value is always exact and unrounded.</p>
<pre>x = new BigNumber('3257869345.0378653')
BigNumber.maximum(4e9, x, '123456789.9') // '4000000000'
arr = [12, '13', new BigNumber(14)]
BigNumber.max.apply(null, arr) // '14'</pre>
<h5 id="min">minimum<code class='inset'>.min(n...) <i>&rArr; BigNumber</i></code></h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<i>See <code><a href="#bignumber">BigNumber</a></code> for further parameter details.</i>
</p>
<p>
Returns a BigNumber whose value is the minimum of the arguments.
</p>
<p>The return value is always exact and unrounded.</p>
<pre>x = new BigNumber('3257869345.0378653')
BigNumber.minimum(4e9, x, '123456789.9') // '123456789.9'
arr = [2, new BigNumber(-14), '-15.9999', -12]
BigNumber.min.apply(null, arr) // '-15.9999'</pre>
<h5 id="random">
random<code class='inset'>.random([dp]) <i>&rArr; BigNumber</i></code>
</h5>
<p><code>dp</code>: <i>number</i>: integer, <code>0</code> to <code>1e+9</code> inclusive</p>
<p>
Returns a new BigNumber with a pseudo-random value equal to or greater than <code>0</code> and
less than <code>1</code>.
</p>
<p>
The return value will have <code>dp</code> decimal places (or less if trailing zeros are
produced).<br />
If <code>dp</code> is omitted then the number of decimal places will default to the current
<a href='#decimal-places'><code>DECIMAL_PLACES</code></a> setting.
</p>
<p>
Depending on the value of this BigNumber constructor's
<a href='#crypto'><code>CRYPTO</code></a> setting and the support for the
<code>crypto</code> object in the host environment, the random digits of the return value are
generated by either <code>Math.random</code> (fastest), <code>crypto.getRandomValues</code>
(Web Cryptography API in recent browsers) or <code>crypto.randomBytes</code> (Node.js).
</p>
<p>
To be able to set <a href='#crypto'><code>CRYPTO</code></a> to <code>true</code> when using
Node.js, the <code>crypto</code> object must be available globally:
</p>
<pre>global.crypto = require('crypto')</pre>
<p>
If <a href='#crypto'><code>CRYPTO</code></a> is <code>true</code>, i.e. one of the
<code>crypto</code> methods is to be used, the value of a returned BigNumber should be
cryptographically-secure and statistically indistinguishable from a random value.
</p>
<p>
Throws if <code>dp</code> is invalid. See <a href='#Errors'>Errors</a>.
</p>
<pre>BigNumber.config({ DECIMAL_PLACES: 10 })
BigNumber.random() // '0.4117936847'
BigNumber.random(20) // '0.78193327636914089009'</pre>
<h5 id="sum">sum<code class='inset'>.sum(n...) <i>&rArr; BigNumber</i></code></h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<i>See <code><a href="#bignumber">BigNumber</a></code> for further parameter details.</i>
</p>
<p>Returns a BigNumber whose value is the sum of the arguments.</p>
<p>The return value is always exact and unrounded.</p>
<pre>x = new BigNumber('3257869345.0378653')
BigNumber.sum(4e9, x, '123456789.9') // '7381326134.9378653'
arr = [2, new BigNumber(14), '15.9999', 12]
BigNumber.sum.apply(null, arr) // '43.9999'</pre>
<h4 id="constructor-properties">Properties</h4>
<p>
The library's enumerated rounding modes are stored as properties of the constructor.<br />
(They are not referenced internally by the library itself.)
</p>
<p>
Rounding modes <code>0</code> to <code>6</code> (inclusive) are the same as those of Java's
BigDecimal class.
</p>
<table>
<tr>
<th>Property</th>
<th>Value</th>
<th>Description</th>
</tr>
<tr>
<td id="round-up"><b>ROUND_UP</b></td>
<td class='centre'>0</td>
<td>Rounds away from zero</td>
</tr>
<tr>
<td id="round-down"><b>ROUND_DOWN</b></td>
<td class='centre'>1</td>
<td>Rounds towards zero</td>
</tr>
<tr>
<td id="round-ceil"><b>ROUND_CEIL</b></td>
<td class='centre'>2</td>
<td>Rounds towards <code>Infinity</code></td>
</tr>
<tr>
<td id="round-floor"><b>ROUND_FLOOR</b></td>
<td class='centre'>3</td>
<td>Rounds towards <code>-Infinity</code></td>
</tr>
<tr>
<td id="round-half-up"><b>ROUND_HALF_UP</b></td>
<td class='centre'>4</td>
<td>
Rounds towards nearest neighbour.<br />
If equidistant, rounds away from zero
</td>
</tr>
<tr>
<td id="round-half-down"><b>ROUND_HALF_DOWN</b></td>
<td class='centre'>5</td>
<td>
Rounds towards nearest neighbour.<br />
If equidistant, rounds towards zero
</td>
</tr>
<tr>
<td id="round-half-even"><b>ROUND_HALF_EVEN</b></td>
<td class='centre'>6</td>
<td>
Rounds towards nearest neighbour.<br />
If equidistant, rounds towards even neighbour
</td>
</tr>
<tr>
<td id="round-half-ceil"><b>ROUND_HALF_CEIL</b></td>
<td class='centre'>7</td>
<td>
Rounds towards nearest neighbour.<br />
If equidistant, rounds towards <code>Infinity</code>
</td>
</tr>
<tr>
<td id="round-half-floor"><b>ROUND_HALF_FLOOR</b></td>
<td class='centre'>8</td>
<td>
Rounds towards nearest neighbour.<br />
If equidistant, rounds towards <code>-Infinity</code>
</td>
</tr>
</table>
<pre>
BigNumber.config({ ROUNDING_MODE: BigNumber.ROUND_CEIL })
BigNumber.config({ ROUNDING_MODE: 2 }) // equivalent</pre>
<h5 id="debug">DEBUG</h5>
<p><i>undefined|false|true</i></p>
<p>
If <code>BigNumber.DEBUG</code> is set <code>true</code> then an error will be thrown
if this <a href='#bignumber'>BigNumber</a> constructor receives an invalid value, such as
a value of type <em>number</em> with more than <code>15</code> significant digits.
See <a href='#bignumber'>BigNumber</a>.
</p>
<p>
An error will also be thrown if the <code><a href='#isBigNumber'>isBigNumber</a></code>
method receives a BigNumber that is not well-formed.
See <code><a href='#isBigNumber'>isBigNumber</a></code>.
</p>
<pre>BigNumber.DEBUG = true</pre>
<h3>INSTANCE</h3>
<h4 id="prototype-methods">Methods</h4>
<p>The methods inherited by a BigNumber instance from its constructor's prototype object.</p>
<p>A BigNumber is immutable in the sense that it is not changed by its methods. </p>
<p>
The treatment of &plusmn;<code>0</code>, &plusmn;<code>Infinity</code> and <code>NaN</code> is
consistent with how JavaScript treats these values.
</p>
<p>Many method names have a shorter alias.</p>
<h5 id="abs">absoluteValue<code class='inset'>.abs() <i>&rArr; BigNumber</i></code></h5>
<p>
Returns a BigNumber whose value is the absolute value, i.e. the magnitude, of the value of
this BigNumber.
</p>
<p>The return value is always exact and unrounded.</p>
<pre>
x = new BigNumber(-0.8)
y = x.absoluteValue() // '0.8'
z = y.abs() // '0.8'</pre>
<h5 id="cmp">
comparedTo<code class='inset'>.comparedTo(n [, base]) <i>&rArr; number</i></code>
</h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<code>base</code>: <i>number</i><br />
<i>See <a href="#bignumber">BigNumber</a> for further parameter details.</i>
</p>
<table>
<tr><th>Returns</th><th>&nbsp;</th></tr>
<tr>
<td class='centre'><code>1</code></td>
<td>If the value of this BigNumber is greater than the value of <code>n</code></td>
</tr>
<tr>
<td class='centre'><code>-1</code></td>
<td>If the value of this BigNumber is less than the value of <code>n</code></td>
</tr>
<tr>
<td class='centre'><code>0</code></td>
<td>If this BigNumber and <code>n</code> have the same value</td>
</tr>
<tr>
<td class='centre'><code>null</code></td>
<td>If the value of either this BigNumber or <code>n</code> is <code>NaN</code></td>
</tr>
</table>
<pre>
x = new BigNumber(Infinity)
y = new BigNumber(5)
x.comparedTo(y) // 1
x.comparedTo(x.minus(1)) // 0
y.comparedTo(NaN) // null
y.comparedTo('110', 2) // -1</pre>
<h5 id="dp">
decimalPlaces<code class='inset'>.dp([dp [, rm]]) <i>&rArr; BigNumber|number</i></code>
</h5>
<p>
<code>dp</code>: <i>number</i>: integer, <code>0</code> to <code>1e+9</code> inclusive<br />
<code>rm</code>: <i>number</i>: integer, <code>0</code> to <code>8</code> inclusive
</p>
<p>
If <code>dp</code> is a number, returns a BigNumber whose value is the value of this BigNumber
rounded by rounding mode <code>rm</code> to a maximum of <code>dp</code> decimal places.
</p>
<p>
If <code>dp</code> is omitted, or is <code>null</code> or <code>undefined</code>, the return
value is the number of decimal places of the value of this BigNumber, or <code>null</code> if
the value of this BigNumber is &plusmn;<code>Infinity</code> or <code>NaN</code>.
</p>
<p>
If <code>rm</code> is omitted, or is <code>null</code> or <code>undefined</code>,
<a href='#rounding-mode'><code>ROUNDING_MODE</code></a> is used.
</p>
<p>
Throws if <code>dp</code> or <code>rm</code> is invalid. See <a href='#Errors'>Errors</a>.
</p>
<pre>
x = new BigNumber(1234.56)
x.decimalPlaces(1) // '1234.6'
x.dp() // 2
x.decimalPlaces(2) // '1234.56'
x.dp(10) // '1234.56'
x.decimalPlaces(0, 1) // '1234'
x.dp(0, 6) // '1235'
x.decimalPlaces(1, 1) // '1234.5'
x.dp(1, BigNumber.ROUND_HALF_EVEN) // '1234.6'
x // '1234.56'
y = new BigNumber('9.9e-101')
y.dp() // 102</pre>
<h5 id="div">dividedBy<code class='inset'>.div(n [, base]) <i>&rArr; BigNumber</i></code>
</h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<code>base</code>: <i>number</i><br />
<i>See <a href="#bignumber">BigNumber</a> for further parameter details.</i>
</p>
<p>
Returns a BigNumber whose value is the value of this BigNumber divided by
<code>n</code>, rounded according to the current
<a href='#decimal-places'><code>DECIMAL_PLACES</code></a> and
<a href='#rounding-mode'><code>ROUNDING_MODE</code></a> settings.
</p>
<pre>
x = new BigNumber(355)
y = new BigNumber(113)
x.dividedBy(y) // '3.14159292035398230088'
x.div(5) // '71'
x.div(47, 16) // '5'</pre>
<h5 id="divInt">
dividedToIntegerBy<code class='inset'>.idiv(n [, base]) &rArr;
<i>BigNumber</i></code>
</h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<code>base</code>: <i>number</i><br />
<i>See <a href="#bignumber">BigNumber</a> for further parameter details.</i>
</p>
<p>
Returns a BigNumber whose value is the integer part of dividing the value of this BigNumber by
<code>n</code>.
</p>
<pre>
x = new BigNumber(5)
y = new BigNumber(3)
x.dividedToIntegerBy(y) // '1'
x.idiv(0.7) // '7'
x.idiv('0.f', 16) // '5'</pre>
<h5 id="pow">
exponentiatedBy<code class='inset'>.pow(n [, m]) <i>&rArr; BigNumber</i></code>
</h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i>: integer<br />
<code>m</code>: <i>number|string|BigNumber</i>
</p>
<p>
Returns a BigNumber whose value is the value of this BigNumber exponentiated by
<code>n</code>, i.e. raised to the power <code>n</code>, and optionally modulo a modulus
<code>m</code>.
</p>
<p>
Throws if <code>n</code> is not an integer. See <a href='#Errors'>Errors</a>.
</p>
<p>
If <code>n</code> is negative the result is rounded according to the current
<a href='#decimal-places'><code>DECIMAL_PLACES</code></a> and
<a href='#rounding-mode'><code>ROUNDING_MODE</code></a> settings.
</p>
<p>
As the number of digits of the result of the power operation can grow so large so quickly,
e.g. 123.456<sup>10000</sup> has over <code>50000</code> digits, the number of significant
digits calculated is limited to the value of the
<a href='#pow-precision'><code>POW_PRECISION</code></a> setting (unless a modulus
<code>m</code> is specified).
</p>
<p>
By default <a href='#pow-precision'><code>POW_PRECISION</code></a> is set to <code>0</code>.
This means that an unlimited number of significant digits will be calculated, and that the
method's performance will decrease dramatically for larger exponents.
</p>
<p>
If <code>m</code> is specified and the value of <code>m</code>, <code>n</code> and this
BigNumber are integers, and <code>n</code> is positive, then a fast modular exponentiation
algorithm is used, otherwise the operation will be performed as
<code>x.exponentiatedBy(n).modulo(m)</code> with a
<a href='#pow-precision'><code>POW_PRECISION</code></a> of <code>0</code>.
</p>
<pre>
Math.pow(0.7, 2) // 0.48999999999999994
x = new BigNumber(0.7)
x.exponentiatedBy(2) // '0.49'
BigNumber(3).pow(-2) // '0.11111111111111111111'</pre>
<h5 id="int">
integerValue<code class='inset'>.integerValue([rm]) <i>&rArr; BigNumber</i></code>
</h5>
<p>
<code>rm</code>: <i>number</i>: integer, <code>0</code> to <code>8</code> inclusive
</p>
<p>
Returns a BigNumber whose value is the value of this BigNumber rounded to an integer using
rounding mode <code>rm</code>.
</p>
<p>
If <code>rm</code> is omitted, or is <code>null</code> or <code>undefined</code>,
<a href='#rounding-mode'><code>ROUNDING_MODE</code></a> is used.
</p>
<p>
Throws if <code>rm</code> is invalid. See <a href='#Errors'>Errors</a>.
</p>
<pre>
x = new BigNumber(123.456)
x.integerValue() // '123'
x.integerValue(BigNumber.ROUND_CEIL) // '124'
y = new BigNumber(-12.7)
y.integerValue() // '-13'
y.integerValue(BigNumber.ROUND_DOWN) // '-12'</pre>
<p>
The following is an example of how to add a prototype method that emulates JavaScript's
<code>Math.round</code> function. <code>Math.ceil</code>, <code>Math.floor</code> and
<code>Math.trunc</code> can be emulated in the same way with
<code>BigNumber.ROUND_CEIL</code>, <code>BigNumber.ROUND_FLOOR</code> and
<code> BigNumber.ROUND_DOWN</code> respectively.
</p>
<pre>
BigNumber.prototype.round = function (n) {
return n.integerValue(BigNumber.ROUND_HALF_CEIL);
};
x.round() // '123'</pre>
<h5 id="eq">isEqualTo<code class='inset'>.eq(n [, base]) <i>&rArr; boolean</i></code></h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<code>base</code>: <i>number</i><br />
<i>See <a href="#bignumber">BigNumber</a> for further parameter details.</i>
</p>
<p>
Returns <code>true</code> if the value of this BigNumber is equal to the value of
<code>n</code>, otherwise returns <code>false</code>.<br />
As with JavaScript, <code>NaN</code> does not equal <code>NaN</code>.
</p>
<p>Note: This method uses the <a href='#cmp'><code>comparedTo</code></a> method internally.</p>
<pre>
0 === 1e-324 // true
x = new BigNumber(0)
x.isEqualTo('1e-324') // false
BigNumber(-0).eq(x) // true ( -0 === 0 )
BigNumber(255).eq('ff', 16) // true
y = new BigNumber(NaN)
y.isEqualTo(NaN) // false</pre>
<h5 id="isF">isFinite<code class='inset'>.isFinite() <i>&rArr; boolean</i></code></h5>
<p>
Returns <code>true</code> if the value of this BigNumber is a finite number, otherwise
returns <code>false</code>.
</p>
<p>
The only possible non-finite values of a BigNumber are <code>NaN</code>, <code>Infinity</code>
and <code>-Infinity</code>.
</p>
<pre>
x = new BigNumber(1)
x.isFinite() // true
y = new BigNumber(Infinity)
y.isFinite() // false</pre>
<p>
Note: The native method <code>isFinite()</code> can be used if
<code>n &lt;= Number.MAX_VALUE</code>.
</p>
<h5 id="gt">isGreaterThan<code class='inset'>.gt(n [, base]) <i>&rArr; boolean</i></code></h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<code>base</code>: <i>number</i><br />
<i>See <a href="#bignumber">BigNumber</a> for further parameter details.</i>
</p>
<p>
Returns <code>true</code> if the value of this BigNumber is greater than the value of
<code>n</code>, otherwise returns <code>false</code>.
</p>
<p>Note: This method uses the <a href='#cmp'><code>comparedTo</code></a> method internally.</p>
<pre>
0.1 &gt; (0.3 - 0.2) // true
x = new BigNumber(0.1)
x.isGreaterThan(BigNumber(0.3).minus(0.2)) // false
BigNumber(0).gt(x) // false
BigNumber(11, 3).gt(11.1, 2) // true</pre>
<h5 id="gte">
isGreaterThanOrEqualTo<code class='inset'>.gte(n [, base]) <i>&rArr; boolean</i></code>
</h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<code>base</code>: <i>number</i><br />
<i>See <a href="#bignumber">BigNumber</a> for further parameter details.</i>
</p>
<p>
Returns <code>true</code> if the value of this BigNumber is greater than or equal to the value
of <code>n</code>, otherwise returns <code>false</code>.
</p>
<p>Note: This method uses the <a href='#cmp'><code>comparedTo</code></a> method internally.</p>
<pre>
(0.3 - 0.2) &gt;= 0.1 // false
x = new BigNumber(0.3).minus(0.2)
x.isGreaterThanOrEqualTo(0.1) // true
BigNumber(1).gte(x) // true
BigNumber(10, 18).gte('i', 36) // true</pre>
<h5 id="isInt">isInteger<code class='inset'>.isInteger() <i>&rArr; boolean</i></code></h5>
<p>
Returns <code>true</code> if the value of this BigNumber is an integer, otherwise returns
<code>false</code>.
</p>
<pre>
x = new BigNumber(1)
x.isInteger() // true
y = new BigNumber(123.456)
y.isInteger() // false</pre>
<h5 id="lt">isLessThan<code class='inset'>.lt(n [, base]) <i>&rArr; boolean</i></code></h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<code>base</code>: <i>number</i><br />
<i>See <a href="#bignumber">BigNumber</a> for further parameter details.</i>
</p>
<p>
Returns <code>true</code> if the value of this BigNumber is less than the value of
<code>n</code>, otherwise returns <code>false</code>.
</p>
<p>Note: This method uses the <a href='#cmp'><code>comparedTo</code></a> method internally.</p>
<pre>
(0.3 - 0.2) &lt; 0.1 // true
x = new BigNumber(0.3).minus(0.2)
x.isLessThan(0.1) // false
BigNumber(0).lt(x) // true
BigNumber(11.1, 2).lt(11, 3) // true</pre>
<h5 id="lte">
isLessThanOrEqualTo<code class='inset'>.lte(n [, base]) <i>&rArr; boolean</i></code>
</h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<code>base</code>: <i>number</i><br />
<i>See <a href="#bignumber">BigNumber</a> for further parameter details.</i>
</p>
<p>
Returns <code>true</code> if the value of this BigNumber is less than or equal to the value of
<code>n</code>, otherwise returns <code>false</code>.
</p>
<p>Note: This method uses the <a href='#cmp'><code>comparedTo</code></a> method internally.</p>
<pre>
0.1 &lt;= (0.3 - 0.2) // false
x = new BigNumber(0.1)
x.isLessThanOrEqualTo(BigNumber(0.3).minus(0.2)) // true
BigNumber(-1).lte(x) // true
BigNumber(10, 18).lte('i', 36) // true</pre>
<h5 id="isNaN">isNaN<code class='inset'>.isNaN() <i>&rArr; boolean</i></code></h5>
<p>
Returns <code>true</code> if the value of this BigNumber is <code>NaN</code>, otherwise
returns <code>false</code>.
</p>
<pre>
x = new BigNumber(NaN)
x.isNaN() // true
y = new BigNumber('Infinity')
y.isNaN() // false</pre>
<p>Note: The native method <code>isNaN()</code> can also be used.</p>
<h5 id="isNeg">isNegative<code class='inset'>.isNegative() <i>&rArr; boolean</i></code></h5>
<p>
Returns <code>true</code> if the sign of this BigNumber is negative, otherwise returns
<code>false</code>.
</p>
<pre>
x = new BigNumber(-0)
x.isNegative() // true
y = new BigNumber(2)
y.isNegative() // false</pre>
<p>Note: <code>n &lt; 0</code> can be used if <code>n &lt;= -Number.MIN_VALUE</code>.</p>
<h5 id="isPos">isPositive<code class='inset'>.isPositive() <i>&rArr; boolean</i></code></h5>
<p>
Returns <code>true</code> if the sign of this BigNumber is positive, otherwise returns
<code>false</code>.
</p>
<pre>
x = new BigNumber(-0)
x.isPositive() // false
y = new BigNumber(2)
y.isPositive() // true</pre>
<h5 id="isZ">isZero<code class='inset'>.isZero() <i>&rArr; boolean</i></code></h5>
<p>
Returns <code>true</code> if the value of this BigNumber is zero or minus zero, otherwise
returns <code>false</code>.
</p>
<pre>
x = new BigNumber(-0)
x.isZero() && x.isNegative() // true
y = new BigNumber(Infinity)
y.isZero() // false</pre>
<p>Note: <code>n == 0</code> can be used if <code>n &gt;= Number.MIN_VALUE</code>.</p>
<h5 id="minus">
minus<code class='inset'>.minus(n [, base]) <i>&rArr; BigNumber</i></code>
</h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<code>base</code>: <i>number</i><br />
<i>See <a href="#bignumber">BigNumber</a> for further parameter details.</i>
</p>
<p>Returns a BigNumber whose value is the value of this BigNumber minus <code>n</code>.</p>
<p>The return value is always exact and unrounded.</p>
<pre>
0.3 - 0.1 // 0.19999999999999998
x = new BigNumber(0.3)
x.minus(0.1) // '0.2'
x.minus(0.6, 20) // '0'</pre>
<h5 id="mod">modulo<code class='inset'>.mod(n [, base]) <i>&rArr; BigNumber</i></code></h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<code>base</code>: <i>number</i><br />
<i>See <a href="#bignumber">BigNumber</a> for further parameter details.</i>
</p>
<p>
Returns a BigNumber whose value is the value of this BigNumber modulo <code>n</code>, i.e.
the integer remainder of dividing this BigNumber by <code>n</code>.
</p>
<p>
The value returned, and in particular its sign, is dependent on the value of the
<a href='#modulo-mode'><code>MODULO_MODE</code></a> setting of this BigNumber constructor.
If it is <code>1</code> (default value), the result will have the same sign as this BigNumber,
and it will match that of Javascript's <code>%</code> operator (within the limits of double
precision) and BigDecimal's <code>remainder</code> method.
</p>
<p>The return value is always exact and unrounded.</p>
<p>
See <a href='#modulo-mode'><code>MODULO_MODE</code></a> for a description of the other
modulo modes.
</p>
<pre>
1 % 0.9 // 0.09999999999999998
x = new BigNumber(1)
x.modulo(0.9) // '0.1'
y = new BigNumber(33)
y.mod('a', 33) // '3'</pre>
<h5 id="times">
multipliedBy<code class='inset'>.times(n [, base]) <i>&rArr; BigNumber</i></code>
</h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<code>base</code>: <i>number</i><br />
<i>See <a href="#bignumber">BigNumber</a> for further parameter details.</i>
</p>
<p>
Returns a BigNumber whose value is the value of this BigNumber multiplied by <code>n</code>.
</p>
<p>The return value is always exact and unrounded.</p>
<pre>
0.6 * 3 // 1.7999999999999998
x = new BigNumber(0.6)
y = x.multipliedBy(3) // '1.8'
BigNumber('7e+500').times(y) // '1.26e+501'
x.multipliedBy('-a', 16) // '-6'</pre>
<h5 id="neg">negated<code class='inset'>.negated() <i>&rArr; BigNumber</i></code></h5>
<p>
Returns a BigNumber whose value is the value of this BigNumber negated, i.e. multiplied by
<code>-1</code>.
</p>
<pre>
x = new BigNumber(1.8)
x.negated() // '-1.8'
y = new BigNumber(-1.3)
y.negated() // '1.3'</pre>
<h5 id="plus">plus<code class='inset'>.plus(n [, base]) <i>&rArr; BigNumber</i></code></h5>
<p>
<code>n</code>: <i>number|string|BigNumber</i><br />
<code>base</code>: <i>number</i><br />
<i>See <a href="#bignumber">BigNumber</a> for further parameter details.</i>
</p>
<p>Returns a BigNumber whose value is the value of this BigNumber plus <code>n</code>.</p>
<p>The return value is always exact and unrounded.</p>
<pre>
0.1 + 0.2 // 0.30000000000000004
x = new BigNumber(0.1)
y = x.plus(0.2) // '0.3'
BigNumber(0.7).plus(x).plus(y) // '1'
x.plus('0.1', 8) // '0.225'</pre>
<h5 id="sd">
precision<code class='inset'>.sd([d [, rm]]) <i>&rArr; BigNumber|number</i></code>
</h5>
<p>
<code>d</code>: <i>number|boolean</i>: integer, <code>1</code> to <code>1e+9</code>
inclusive, or <code>true</code> or <code>false</code><br />
<code>rm</code>: <i>number</i>: integer, <code>0</code> to <code>8</code> inclusive.
</p>
<p>
If <code>d</code> is a number, returns a BigNumber whose value is the value of this BigNumber
rounded to a precision of <code>d</code> significant digits using rounding mode
<code>rm</code>.
</p>
<p>
If <code>d</code> is omitted or is <code>null</code> or <code>undefined</code>, the return
value is the number of significant digits of the value of this BigNumber, or <code>null</code>
if the value of this BigNumber is &plusmn;<code>Infinity</code> or <code>NaN</code>.</p>
</p>
<p>
If <code>d</code> is <code>true</code> then any trailing zeros of the integer
part of a number are counted as significant digits, otherwise they are not.
</p>
<p>
If <code>rm</code> is omitted or is <code>null</code> or <code>undefined</code>,
<a href='#rounding-mode'><code>ROUNDING_MODE</code></a> will be used.
</p>
<p>
Throws if <code>d</code> or <code>rm</code> is invalid. See <a href='#Errors'>Errors</a>.
</p>
<pre>
x = new BigNumber(9876.54321)
x.precision(6) // '9876.54'
x.sd() // 9
x.precision(6, BigNumber.ROUND_UP) // '9876.55'
x.sd(2) // '9900'
x.precision(2, 1) // '9800'
x // '9876.54321'
y = new BigNumber(987000)
y.precision() // 3
y.sd(true) // 6</pre>
<h5 id="shift">shiftedBy<code class='inset'>.shiftedBy(n) <i>&rArr; BigNumber</i></code></h5>
<p>
<code>n</code>: <i>number</i>: integer,
<code>-9007199254740991</code> to <code>9007199254740991</code> inclusive
</p>
<p>
Returns a BigNumber whose value is the value of this BigNumber shifted by <code>n</code>
places.
<p>
The shift is of the decimal point, i.e. of powers of ten, and is to the left if <code>n</code>
is negative or to the right if <code>n</code> is positive.
</p>
<p>The return value is always exact and unrounded.</p>
<p>
Throws if <code>n</code> is invalid. See <a href='#Errors'>Errors</a>.
</p>
<pre>
x = new BigNumber(1.23)
x.shiftedBy(3) // '1230'
x.shiftedBy(-3) // '0.00123'</pre>
<h5 id="sqrt">squareRoot<code class='inset'>.sqrt() <i>&rArr; BigNumber</i></code></h5>
<p>
Returns a BigNumber whose value is the square root of the value of this BigNumber,
rounded according to the current
<a href='#decimal-places'><code>DECIMAL_PLACES</code></a> and
<a href='#rounding-mode'><code>ROUNDING_MODE</code></a> settings.
</p>
<p>
The return value will be correctly rounded, i.e. rounded as if the result was first calculated
to an infinite number of correct digits before rounding.
</p>
<pre>
x = new BigNumber(16)
x.squareRoot() // '4'
y = new BigNumber(3)
y.sqrt() // '1.73205080756887729353'</pre>
<h5 id="toE">
toExponential<code class='inset'>.toExponential([dp [, rm]]) <i>&rArr; string</i></code>
</h5>
<p>
<code>dp</code>: <i>number</i>: integer, <code>0</code> to <code>1e+9</code> inclusive<br />
<code>rm</code>: <i>number</i>: integer, <code>0</code> to <code>8</code> inclusive
</p>
<p>
Returns a string representing the value of this BigNumber in exponential notation rounded
using rounding mode <code>rm</code> to <code>dp</code> decimal places, i.e with one digit
before the decimal point and <code>dp</code> digits after it.
</p>
<p>
If the value of this BigNumber in exponential notation has fewer than <code>dp</code> fraction
digits, the return value will be appended with zeros accordingly.
</p>
<p>
If <code>dp</code> is omitted, or is <code>null</code> or <code>undefined</code>, the number
of digits after the decimal point defaults to the minimum number of digits necessary to
represent the value exactly.<br />
If <code>rm</code> is omitted or is <code>null</code> or <code>undefined</code>,
<a href='#rounding-mode'><code>ROUNDING_MODE</code></a> is used.
</p>
<p>
Throws if <code>dp</code> or <code>rm</code> is invalid. See <a href='#Errors'>Errors</a>.
</p>
<pre>
x = 45.6
y = new BigNumber(x)
x.toExponential() // '4.56e+1'
y.toExponential() // '4.56e+1'
x.toExponential(0) // '5e+1'
y.toExponential(0) // '5e+1'
x.toExponential(1) // '4.6e+1'
y.toExponential(1) // '4.6e+1'
y.toExponential(1, 1) // '4.5e+1' (ROUND_DOWN)
x.toExponential(3) // '4.560e+1'
y.toExponential(3) // '4.560e+1'</pre>
<h5 id="toFix">
toFixed<code class='inset'>.toFixed([dp [, rm]]) <i>&rArr; string</i></code>
</h5>
<p>
<code>dp</code>: <i>number</i>: integer, <code>0</code> to <code>1e+9</code> inclusive<br />
<code>rm</code>: <i>number</i>: integer, <code>0</code> to <code>8</code> inclusive
</p>
<p>
Returns a string representing the value of this BigNumber in normal (fixed-point) notation
rounded to <code>dp</code> decimal places using rounding mode <code>rm</code>.
</p>
<p>
If the value of this BigNumber in normal notation has fewer than <code>dp</code> fraction
digits, the return value will be appended with zeros accordingly.
</p>
<p>
Unlike <code>Number.prototype.toFixed</code>, which returns exponential notation if a number
is greater or equal to <code>10<sup>21</sup></code>, this method will always return normal
notation.
</p>
<p>
If <code>dp</code> is omitted or is <code>null</code> or <code>undefined</code>, the return
value will be unrounded and in normal notation. This is also unlike
<code>Number.prototype.toFixed</code>, which returns the value to zero decimal places.<br />
It is useful when fixed-point notation is required and the current
<a href="#exponential-at"><code>EXPONENTIAL_AT</code></a> setting causes
<code><a href='#toS'>toString</a></code> to return exponential notation.<br />
If <code>rm</code> is omitted or is <code>null</code> or <code>undefined</code>,
<a href='#rounding-mode'><code>ROUNDING_MODE</code></a> is used.
</p>
<p>
Throws if <code>dp</code> or <code>rm</code> is invalid. See <a href='#Errors'>Errors</a>.
</p>
<pre>
x = 3.456
y = new BigNumber(x)
x.toFixed() // '3'
y.toFixed() // '3.456'
y.toFixed(0) // '3'
x.toFixed(2) // '3.46'
y.toFixed(2) // '3.46'
y.toFixed(2, 1) // '3.45' (ROUND_DOWN)
x.toFixed(5) // '3.45600'
y.toFixed(5) // '3.45600'</pre>
<h5 id="toFor">
toFormat<code class='inset'>.toFormat([dp [, rm[, format]]]) <i>&rArr; string</i></code>
</h5>
<p>
<code>dp</code>: <i>number</i>: integer, <code>0</code> to <code>1e+9</code> inclusive<br />
<code>rm</code>: <i>number</i>: integer, <code>0</code> to <code>8</code> inclusive<br />
<code>format</code>: <i>object</i>: see <a href='#format'><code>FORMAT</code></a>
</p>
<p>
<p>
Returns a string representing the value of this BigNumber in normal (fixed-point) notation
rounded to <code>dp</code> decimal places using rounding mode <code>rm</code>, and formatted
according to the properties of the <code>format</code> object.
</p>
<p>
See <a href='#format'><code>FORMAT</code></a> and the examples below for the properties of the
<code>format</code> object, their types, and their usage. A formatting object may contain
some or all of the recognised properties.
</p>
<p>
If <code>dp</code> is omitted or is <code>null</code> or <code>undefined</code>, then the
return value is not rounded to a fixed number of decimal places.<br />
If <code>rm</code> is omitted or is <code>null</code> or <code>undefined</code>,
<a href='#rounding-mode'><code>ROUNDING_MODE</code></a> is used.<br />
If <code>format</code> is omitted or is <code>null</code> or <code>undefined</code>, the
<a href='#format'><code>FORMAT</code></a> object is used.
</p>
<p>
Throws if <code>dp</code>, <code>rm</code> or <code>format</code> is invalid. See
<a href='#Errors'>Errors</a>.
</p>
<pre>
fmt = {
prefix = '',
decimalSeparator: '.',
groupSeparator: ',',
groupSize: 3,
secondaryGroupSize: 0,
fractionGroupSeparator: ' ',
fractionGroupSize: 0,
suffix = ''
}
x = new BigNumber('123456789.123456789')
// Set the global formatting options
BigNumber.config({ FORMAT: fmt })
x.toFormat() // '123,456,789.123456789'
x.toFormat(3) // '123,456,789.123'
// If a reference to the object assigned to FORMAT has been retained,
// the format properties can be changed directly
fmt.groupSeparator = ' '
fmt.fractionGroupSize = 5
x.toFormat() // '123 456 789.12345 6789'
// Alternatively, pass the formatting options as an argument
fmt = {
prefix: '=> ',
decimalSeparator: ',',
groupSeparator: '.',
groupSize: 3,
secondaryGroupSize: 2
}
x.toFormat() // '123 456 789.12345 6789'
x.toFormat(fmt) // '=> 12.34.56.789,123456789'
x.toFormat(2, fmt) // '=> 12.34.56.789,12'
x.toFormat(3, BigNumber.ROUND_UP, fmt) // '=> 12.34.56.789,124'</pre>
<h5 id="toFr">
toFraction<code class='inset'>.toFraction([maximum_denominator])
<i>&rArr; [BigNumber, BigNumber]</i></code>
</h5>
<p>
<code>maximum_denominator</code>:
<i>number|string|BigNumber</i>: integer &gt;= <code>1</code> and &lt;=
<code>Infinity</code>
</p>
<p>
Returns an array of two BigNumbers representing the value of this BigNumber as a simple
fraction with an integer numerator and an integer denominator. The denominator will be a
positive non-zero value less than or equal to <code>maximum_denominator</code>.
</p>
<p>
If a <code>maximum_denominator</code> is not specified, or is <code>null</code> or
<code>undefined</code>, the denominator will be the lowest value necessary to represent the
number exactly.
</p>
<p>
Throws if <code>maximum_denominator</code> is invalid. See <a href='#Errors'>Errors</a>.
</p>
<pre>
x = new BigNumber(1.75)
x.toFraction() // '7, 4'
pi = new BigNumber('3.14159265358')
pi.toFraction() // '157079632679,50000000000'
pi.toFraction(100000) // '312689, 99532'
pi.toFraction(10000) // '355, 113'
pi.toFraction(100) // '311, 99'
pi.toFraction(10) // '22, 7'
pi.toFraction(1) // '3, 1'</pre>
<h5 id="toJSON">toJSON<code class='inset'>.toJSON() <i>&rArr; string</i></code></h5>
<p>As <a href='#valueOf'><code>valueOf</code></a>.</p>
<pre>
x = new BigNumber('177.7e+457')
y = new BigNumber(235.4325)
z = new BigNumber('0.0098074')
// Serialize an array of three BigNumbers
str = JSON.stringify( [x, y, z] )
// "["1.777e+459","235.4325","0.0098074"]"
// Return an array of three BigNumbers
JSON.parse(str, function (key, val) {
return key === '' ? val : new BigNumber(val)
})</pre>
<h5 id="toN">toNumber<code class='inset'>.toNumber() <i>&rArr; number</i></code></h5>
<p>Returns the value of this BigNumber as a JavaScript number primitive.</p>
<p>
This method is identical to using type coercion with the unary plus operator.
</p>
<pre>
x = new BigNumber(456.789)
x.toNumber() // 456.789
+x // 456.789
y = new BigNumber('45987349857634085409857349856430985')
y.toNumber() // 4.598734985763409e+34
z = new BigNumber(-0)
1 / z.toNumber() // -Infinity
1 / +z // -Infinity</pre>
<h5 id="toP">
toPrecision<code class='inset'>.toPrecision([sd [, rm]]) <i>&rArr; string</i></code>
</h5>
<p>
<code>sd</code>: <i>number</i>: integer, <code>1</code> to <code>1e+9</code> inclusive<br />
<code>rm</code>: <i>number</i>: integer, <code>0</code> to <code>8</code> inclusive
</p>
<p>
Returns a string representing the value of this BigNumber rounded to <code>sd</code>
significant digits using rounding mode <code>rm</code>.
</p>
<p>
If <code>sd</code> is less than the number of digits necessary to represent the integer part
of the value in normal (fixed-point) notation, then exponential notation is used.
</p>
<p>
If <code>sd</code> is omitted, or is <code>null</code> or <code>undefined</code>, then the
return value is the same as <code>n.toString()</code>.<br />
If <code>rm</code> is omitted or is <code>null</code> or <code>undefined</code>,
<a href='#rounding-mode'><code>ROUNDING_MODE</code></a> is used.
</p>
<p>
Throws if <code>sd</code> or <code>rm</code> is invalid. See <a href='#Errors'>Errors</a>.
</p>
<pre>
x = 45.6
y = new BigNumber(x)
x.toPrecision() // '45.6'
y.toPrecision() // '45.6'
x.toPrecision(1) // '5e+1'
y.toPrecision(1) // '5e+1'
y.toPrecision(2, 0) // '4.6e+1' (ROUND_UP)
y.toPrecision(2, 1) // '4.5e+1' (ROUND_DOWN)
x.toPrecision(5) // '45.600'
y.toPrecision(5) // '45.600'</pre>
<h5 id="toS">toString<code class='inset'>.toString([base]) <i>&rArr; string</i></code></h5>
<p>
<code>base</code>: <i>number</i>: integer, <code>2</code> to <code>ALPHABET.length</code>
inclusive (see <a href='#alphabet'><code>ALPHABET</code></a>).
</p>
<p>
Returns a string representing the value of this BigNumber in the specified base, or base
<code>10</code> if <code>base</code> is omitted or is <code>null</code> or
<code>undefined</code>.
</p>
<p>
For bases above <code>10</code>, and using the default base conversion alphabet
(see <a href='#alphabet'><code>ALPHABET</code></a>), values from <code>10</code> to
<code>35</code> are represented by <code>a-z</code>
(as with <code>Number.prototype.toString</code>).
</p>
<p>
If a base is specified the value is rounded according to the current
<a href='#decimal-places'><code>DECIMAL_PLACES</code></a>
and <a href='#rounding-mode'><code>ROUNDING_MODE</code></a> settings.
</p>
<p>
If a base is not specified, and this BigNumber has a positive
exponent that is equal to or greater than the positive component of the
current <a href="#exponential-at"><code>EXPONENTIAL_AT</code></a> setting,
or a negative exponent equal to or less than the negative component of the
setting, then exponential notation is returned.
</p>
<p>If <code>base</code> is <code>null</code> or <code>undefined</code> it is ignored.</p>
<p>
Throws if <code>base</code> is invalid. See <a href='#Errors'>Errors</a>.
</p>
<pre>
x = new BigNumber(750000)
x.toString() // '750000'
BigNumber.config({ EXPONENTIAL_AT: 5 })
x.toString() // '7.5e+5'
y = new BigNumber(362.875)
y.toString(2) // '101101010.111'
y.toString(9) // '442.77777777777777777778'
y.toString(32) // 'ba.s'
BigNumber.config({ DECIMAL_PLACES: 4 });
z = new BigNumber('1.23456789')
z.toString() // '1.23456789'
z.toString(10) // '1.2346'</pre>
<h5 id="valueOf">valueOf<code class='inset'>.valueOf() <i>&rArr; string</i></code></h5>
<p>
As <a href='#toS'><code>toString</code></a>, but does not accept a base argument and includes
the minus sign for negative zero.
</p>
<pre>
x = new BigNumber('-0')
x.toString() // '0'
x.valueOf() // '-0'
y = new BigNumber('1.777e+457')
y.valueOf() // '1.777e+457'</pre>
<h4 id="instance-properties">Properties</h4>
<p>The properties of a BigNumber instance:</p>
<table>
<tr>
<th>Property</th>
<th>Description</th>
<th>Type</th>
<th>Value</th>
</tr>
<tr>
<td class='centre' id='coefficient'><b>c</b></td>
<td>coefficient<sup>*</sup></td>
<td><i>number</i><code>[]</code></td>
<td> Array of base <code>1e14</code> numbers</td>
</tr>
<tr>
<td class='centre' id='exponent'><b>e</b></td>
<td>exponent</td>
<td><i>number</i></td>
<td>Integer, <code>-1000000000</code> to <code>1000000000</code> inclusive</td>
</tr>
<tr>
<td class='centre' id='sign'><b>s</b></td>
<td>sign</td>
<td><i>number</i></td>
<td><code>-1</code> or <code>1</code></td>
</tr>
</table>
<p><sup>*</sup>significand</p>
<p>
The value of any of the <code>c</code>, <code>e</code> and <code>s</code> properties may also
be <code>null</code>.
</p>
<p>
The above properties are best considered to be read-only. In early versions of this library it
was okay to change the exponent of a BigNumber by writing to its exponent property directly,
but this is no longer reliable as the value of the first element of the coefficient array is
now dependent on the exponent.
</p>
<p>
Note that, as with JavaScript numbers, the original exponent and fractional trailing zeros are
not necessarily preserved.
</p>
<pre>x = new BigNumber(0.123) // '0.123'
x.toExponential() // '1.23e-1'
x.c // '1,2,3'
x.e // -1
x.s // 1
y = new Number(-123.4567000e+2) // '-12345.67'
y.toExponential() // '-1.234567e+4'
z = new BigNumber('-123.4567000e+2') // '-12345.67'
z.toExponential() // '-1.234567e+4'
z.c // '1,2,3,4,5,6,7'
z.e // 4
z.s // -1</pre>
<h4 id="zero-nan-infinity">Zero, NaN and Infinity</h4>
<p>
The table below shows how &plusmn;<code>0</code>, <code>NaN</code> and
&plusmn;<code>Infinity</code> are stored.
</p>
<table>
<tr>
<th> </th>
<th class='centre'>c</th>
<th class='centre'>e</th>
<th class='centre'>s</th>
</tr>
<tr>
<td>&plusmn;0</td>
<td><code>[0]</code></td>
<td><code>0</code></td>
<td><code>&plusmn;1</code></td>
</tr>
<tr>
<td>NaN</td>
<td><code>null</code></td>
<td><code>null</code></td>
<td><code>null</code></td>
</tr>
<tr>
<td>&plusmn;Infinity</td>
<td><code>null</code></td>
<td><code>null</code></td>
<td><code>&plusmn;1</code></td>
</tr>
</table>
<pre>
x = new Number(-0) // 0
1 / x == -Infinity // true
y = new BigNumber(-0) // '0'
y.c // '0' ( [0].toString() )
y.e // 0
y.s // -1</pre>
<h4 id='Errors'>Errors</h4>
<p>The table below shows the errors that are thrown.</p>
<p>
The errors are generic <code>Error</code> objects whose message begins
<code>'[BigNumber Error]'</code>.
</p>
<table class='error-table'>
<tr>
<th>Method</th>
<th>Throws</th>
</tr>
<tr>
<td rowspan=6>
<code>BigNumber</code><br />
<code>comparedTo</code><br />
<code>dividedBy</code><br />
<code>dividedToIntegerBy</code><br />
<code>isEqualTo</code><br />
<code>isGreaterThan</code><br />
<code>isGreaterThanOrEqualTo</code><br />
<code>isLessThan</code><br />
<code>isLessThanOrEqualTo</code><br />
<code>minus</code><br />
<code>modulo</code><br />
<code>plus</code><br />
<code>multipliedBy</code>
</td>
<td>Base not a primitive number</td>
</tr>
<tr>
<td>Base not an integer</td>
</tr>
<tr>
<td>Base out of range</td>
</tr>
<tr>
<td>Number primitive has more than 15 significant digits<sup>*</sup></td>
</tr>
<tr>
<td>Not a base... number<sup>*</sup></td>
</tr>
<tr>
<td>Not a number<sup>*</sup></td>
</tr>
<tr>
<td><code>clone</code></td>
<td>Object expected</td>
</tr>
<tr>
<td rowspan=24><code>config</code></td>
<td>Object expected</td>
</tr>
<tr>
<td><code>DECIMAL_PLACES</code> not a primitive number</td>
</tr>
<tr>
<td><code>DECIMAL_PLACES</code> not an integer</td>
</tr>
<tr>
<td><code>DECIMAL_PLACES</code> out of range</td>
</tr>
<tr>
<td><code>ROUNDING_MODE</code> not a primitive number</td>
</tr>
<tr>
<td><code>ROUNDING_MODE</code> not an integer</td>
</tr>
<tr>
<td><code>ROUNDING_MODE</code> out of range</td>
</tr>
<tr>
<td><code>EXPONENTIAL_AT</code> not a primitive number</td>
</tr>
<tr>
<td><code>EXPONENTIAL_AT</code> not an integer</td>
</tr>
<tr>
<td><code>EXPONENTIAL_AT</code> out of range</td>
</tr>
<tr>
<td><code>RANGE</code> not a primitive number</td>
</tr>
<tr>
<td><code>RANGE</code> not an integer</td>
</tr>
<tr>
<td><code>RANGE</code> cannot be zero</td>
</tr>
<tr>
<td><code>RANGE</code> cannot be zero</td>
</tr>
<tr>
<td><code>CRYPTO</code> not true or false</td>
</tr>
<tr>
<td><code>crypto</code> unavailable</td>
</tr>
<tr>
<td><code>MODULO_MODE</code> not a primitive number</td>
</tr>
<tr>
<td><code>MODULO_MODE</code> not an integer</td>
</tr>
<tr>
<td><code>MODULO_MODE</code> out of range</td>
</tr>
<tr>
<td><code>POW_PRECISION</code> not a primitive number</td>
</tr>
<tr>
<td><code>POW_PRECISION</code> not an integer</td>
</tr>
<tr>
<td><code>POW_PRECISION</code> out of range</td>
</tr>
<tr>
<td><code>FORMAT</code> not an object</td>
</tr>
<tr>
<td><code>ALPHABET</code> invalid</td>
</tr>
<tr>
<td rowspan=3>
<code>decimalPlaces</code><br />
<code>precision</code><br />
<code>random</code><br />
<code>shiftedBy</code><br />
<code>toExponential</code><br />
<code>toFixed</code><br />
<code>toFormat</code><br />
<code>toPrecision</code>
</td>
<td>Argument not a primitive number</td>
</tr>
<tr>
<td>Argument not an integer</td>
</tr>
<tr>
<td>Argument out of range</td>
</tr>
<tr>
<td>
<code>decimalPlaces</code><br />
<code>precision</code>
</td>
<td>Argument not true or false</td>
</tr>
<tr>
<td><code>exponentiatedBy</code></td>
<td>Argument not an integer</td>
</tr>
<tr>
<td><code>isBigNumber</code></td>
<td>Invalid BigNumber<sup>*</sup></td>
</tr>
<tr>
<td>
<code>minimum</code><br />
<code>maximum</code>
</td>
<td>Not a number<sup>*</sup></td>
</tr>
<tr>
<td>
<code>random</code>
</td>
<td>crypto unavailable</td>
</tr>
<tr>
<td>
<code>toFormat</code>
</td>
<td>Argument not an object</td>
</tr>
<tr>
<td rowspan=2><code>toFraction</code></td>
<td>Argument not an integer</td>
</tr>
<tr>
<td>Argument out of range</td>
</tr>
<tr>
<td rowspan=3><code>toString</code></td>
<td>Base not a primitive number</td>
</tr>
<tr>
<td>Base not an integer</td>
</tr>
<tr>
<td>Base out of range</td>
</tr>
</table>
<p><sup>*</sup>Only thrown if <code>BigNumber.DEBUG</code> is <code>true</code>.</p>
<p>To determine if an exception is a BigNumber Error:</p>
<pre>
try {
// ...
} catch (e) {
if (e instanceof Error && e.message.indexOf('[BigNumber Error]') === 0) {
// ...
}
}</pre>
<h4 id="type-coercion">Type coercion</h4>
<p>
To prevent the accidental use of a BigNumber in primitive number operations, or the
accidental addition of a BigNumber to a string, the <code>valueOf</code> method can be safely
overwritten as shown below.
</p>
<p>
The <a href='#valueOf'><code>valueOf</code></a> method is the same as the
<a href='#toJSON'><code>toJSON</code></a> method, and both are the same as the
<a href='#toS'><code>toString</code></a> method except they do not take a <code>base</code>
argument and they include the minus sign for negative zero.
</p>
<pre>
BigNumber.prototype.valueOf = function () {
throw Error('valueOf called!')
}
x = new BigNumber(1)
x / 2 // '[BigNumber Error] valueOf called!'
x + 'abc' // '[BigNumber Error] valueOf called!'
</pre>
<h4 id='faq'>FAQ</h4>
<h6>Why are trailing fractional zeros removed from BigNumbers?</h6>
<p>
Some arbitrary-precision libraries retain trailing fractional zeros as they can indicate the
precision of a value. This can be useful but the results of arithmetic operations can be
misleading.
</p>
<pre>
x = new BigDecimal("1.0")
y = new BigDecimal("1.1000")
z = x.add(y) // 2.1000
x = new BigDecimal("1.20")
y = new BigDecimal("3.45000")
z = x.multiply(y) // 4.1400000</pre>
<p>
To specify the precision of a value is to specify that the value lies
within a certain range.
</p>
<p>
In the first example, <code>x</code> has a value of <code>1.0</code>. The trailing zero shows
the precision of the value, implying that it is in the range <code>0.95</code> to
<code>1.05</code>. Similarly, the precision indicated by the trailing zeros of <code>y</code>
indicates that the value is in the range <code>1.09995</code> to <code>1.10005</code>.
</p>
<p>
If we add the two lowest values in the ranges we have, <code>0.95 + 1.09995 = 2.04995</code>,
and if we add the two highest values we have, <code>1.05 + 1.10005 = 2.15005</code>, so the
range of the result of the addition implied by the precision of its operands is
<code>2.04995</code> to <code>2.15005</code>.
</p>
<p>
The result given by BigDecimal of <code>2.1000</code> however, indicates that the value is in
the range <code>2.09995</code> to <code>2.10005</code> and therefore the precision implied by
its trailing zeros may be misleading.
</p>
<p>
In the second example, the true range is <code>4.122744</code> to <code>4.157256</code> yet
the BigDecimal answer of <code>4.1400000</code> indicates a range of <code>4.13999995</code>
to <code>4.14000005</code>. Again, the precision implied by the trailing zeros may be
misleading.
</p>
<p>
This library, like binary floating point and most calculators, does not retain trailing
fractional zeros. Instead, the <code>toExponential</code>, <code>toFixed</code> and
<code>toPrecision</code> methods enable trailing zeros to be added if and when required.<br />
</p>
</div>
</body>
</html>
{
"_from": "bignumber.js@9.0.0",
"_id": "bignumber.js@9.0.0",
"_inBundle": false,
"_integrity": "sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A==",
"_location": "/bignumber.js",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "bignumber.js@9.0.0",
"name": "bignumber.js",
"escapedName": "bignumber.js",
"rawSpec": "9.0.0",
"saveSpec": null,
"fetchSpec": "9.0.0"
},
"_requiredBy": [
"/mysql"
],
"_resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz",
"_shasum": "805880f84a329b5eac6e7cb6f8274b6d82bdf075",
"_spec": "bignumber.js@9.0.0",
"_where": "C:\\Users\\user\\Desktop\\Singer-Composer\\node_modules\\mysql",
"author": {
"name": "Michael Mclaughlin",
"email": "M8ch88l@gmail.com"
},
"browser": "bignumber.js",
"bugs": {
"url": "https://github.com/MikeMcl/bignumber.js/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "A library for arbitrary-precision decimal and non-decimal arithmetic",
"engines": {
"node": "*"
},
"homepage": "https://github.com/MikeMcl/bignumber.js#readme",
"keywords": [
"arbitrary",
"precision",
"arithmetic",
"big",
"number",
"decimal",
"float",
"biginteger",
"bigdecimal",
"bignumber",
"bigint",
"bignum"
],
"license": "MIT",
"main": "bignumber",
"module": "bignumber.mjs",
"name": "bignumber.js",
"repository": {
"type": "git",
"url": "git+https://github.com/MikeMcl/bignumber.js.git"
},
"scripts": {
"build": "uglifyjs bignumber.js --source-map -c -m -o bignumber.min.js",
"test": "node test/test"
},
"types": "bignumber.d.ts",
"version": "9.0.0"
}
language: node_js
node_js:
- "0.8"
- "0.10"
test:
@node_modules/.bin/tape test.js
.PHONY: test
# isarray
`Array#isArray` for older browsers.
[![build status](https://secure.travis-ci.org/juliangruber/isarray.svg)](http://travis-ci.org/juliangruber/isarray)
[![downloads](https://img.shields.io/npm/dm/isarray.svg)](https://www.npmjs.org/package/isarray)
[![browser support](https://ci.testling.com/juliangruber/isarray.png)
](https://ci.testling.com/juliangruber/isarray)
## Usage
```js
var isArray = require('isarray');
console.log(isArray([])); // => true
console.log(isArray({})); // => false
```
## Installation
With [npm](http://npmjs.org) do
```bash
$ npm install isarray
```
Then bundle for the browser with
[browserify](https://github.com/substack/browserify).
With [component](http://component.io) do
```bash
$ component install juliangruber/isarray
```
## License
(MIT)
Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
{
"name" : "isarray",
"description" : "Array#isArray for older browsers",
"version" : "0.0.1",
"repository" : "juliangruber/isarray",
"homepage": "https://github.com/juliangruber/isarray",
"main" : "index.js",
"scripts" : [
"index.js"
],
"dependencies" : {},
"keywords": ["browser","isarray","array"],
"author": {
"name": "Julian Gruber",
"email": "mail@juliangruber.com",
"url": "http://juliangruber.com"
},
"license": "MIT"
}
var toString = {}.toString;
module.exports = Array.isArray || function (arr) {
return toString.call(arr) == '[object Array]';
};
{
"_from": "isarray@~1.0.0",
"_id": "isarray@1.0.0",
"_inBundle": false,
"_integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
"_location": "/isarray",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "isarray@~1.0.0",
"name": "isarray",
"escapedName": "isarray",
"rawSpec": "~1.0.0",
"saveSpec": null,
"fetchSpec": "~1.0.0"
},
"_requiredBy": [
"/readable-stream"
],
"_resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"_shasum": "bb935d48582cba168c06834957a54a3e07124f11",
"_spec": "isarray@~1.0.0",
"_where": "C:\\Users\\user\\Desktop\\Singer-Composer\\node_modules\\readable-stream",
"author": {
"name": "Julian Gruber",
"email": "mail@juliangruber.com",
"url": "http://juliangruber.com"
},
"bugs": {
"url": "https://github.com/juliangruber/isarray/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "Array#isArray for older browsers",
"devDependencies": {
"tape": "~2.13.4"
},
"homepage": "https://github.com/juliangruber/isarray",
"keywords": [
"browser",
"isarray",
"array"
],
"license": "MIT",
"main": "index.js",
"name": "isarray",
"repository": {
"type": "git",
"url": "git://github.com/juliangruber/isarray.git"
},
"scripts": {
"test": "tape test.js"
},
"testling": {
"files": "test.js",
"browsers": [
"ie/8..latest",
"firefox/17..latest",
"firefox/nightly",
"chrome/22..latest",
"chrome/canary",
"opera/12..latest",
"opera/next",
"safari/5.1..latest",
"ipad/6.0..latest",
"iphone/6.0..latest",
"android-browser/4.2..latest"
]
},
"version": "1.0.0"
}
var isArray = require('./');
var test = require('tape');
test('is array', function(t){
t.ok(isArray([]));
t.notOk(isArray({}));
t.notOk(isArray(null));
t.notOk(isArray(false));
var obj = {};
obj[0] = true;
t.notOk(isArray(obj));
var arr = [];
arr.foo = 'bar';
t.ok(isArray(arr));
t.end();
});
language: node_js
sudo: false
script: npm run coverage
node_js:
- '6'
- '7'
cache:
directories:
- node_modules
## [v2.0.0]
> Jun 5, 2018
See [Upgrading to v2.0.0](https://github.com/rstacruz/mocha-jsdom#upgrading-to-v200) for notes on how to update from an older version.
* [#32] - `jsdom` is now a direct dependency of `mocha-jsdom` :tada:
[#32]: https://github.com/rstacruz/mocha-jsdom/issues/32
[v2.0.0]: https://github.com/rstacruz/mocha-jsdom/compare/v1.2.0...v2.0.0
## [v1.2.0]
> Jun 5, 2018
* [#29] - Update Jsdom compatibility ([@RobLoach])
* [#31] - Update all npm dependencies
[#29]: https://github.com/rstacruz/mocha-jsdom/issues/29
[#31]: https://github.com/rstacruz/mocha-jsdom/issues/31
[@RobLoach]: https://github.com/robloach
[v1.2.0]: https://github.com/rstacruz/mocha-jsdom/compare/v1.1.0...v1.2.0
## [v1.1.0]
> Feb 22, 2016
* [#18] - Initialize global.window when it is undefined; fixes compatibility with [airbnb/enzyme][]. ([@moonboots])
[v1.1.0]: https://github.com/rstacruz/mocha-jsdom/compare/v1.0.0...v1.1.0
## [v1.0.0] - Jul 4, 2015
* Add testling/browserify support.
* Add more examples.
[v1.0.0]: https://github.com/rstacruz/mocha-jsdom/compare/v0.5.0...v1.0.0
## [v0.5.0] - Jun 26, 2015
* Add `rerequire()` to help with using mocha-jsdom with `mocha --watch`.
* Internal: change coding standard to feross/standard.
## [v0.4.0] - May 25, 2015
* [#5] - Add `useEach` option. ([@jasco], [#6])
* [#7] - Add a `skipWindowCheck` option.
## [v0.3.0] - Apr 3, 2015
* [#3] - Bump `jsdom` dependency version. This fixes the "needs a context" error ([@nacyot], [#3])
[#3]: https://github.com/rstacruz/mocha-jsdom/issues/3
[#4]: https://github.com/rstacruz/mocha-jsdom/issues/4
[@nacyot]: https://github.com/nacyot
## [v0.2.1] - Feb 19, 2014
* Add `LICENSE` file
* Update documentation
* No functionality changes
## [v0.2.0] - November 5, 2014
* Skip warnings. Add `JSDOM_VERBOSE=1` to your env to reenable them.
## [v0.1.2] - September 27, 2014
* Throw a useful error when invoked twice.
## [v0.1.1] - September 27, 2014
* Re-release with updated Readme.
[airbnb/enzyme]: https://github.com/airbnb/enzyme
## v0.1.0 - September 25, 2014
* Initial version.
[#5]: https://github.com/rstacruz/mocha-jsdom/issues/5
[#6]: https://github.com/rstacruz/mocha-jsdom/issues/6
[#7]: https://github.com/rstacruz/mocha-jsdom/issues/7
[@jasco]: https://github.com/jasco
[v0.5.0]: https://github.com/rstacruz/mocha-jsdom/compare/v0.4.0...v0.5.0
[v0.4.0]: https://github.com/rstacruz/mocha-jsdom/compare/v0.3.0...v0.4.0
[v0.3.0]: https://github.com/rstacruz/mocha-jsdom/compare/v0.2.1...v0.3.0
[v0.2.1]: https://github.com/rstacruz/mocha-jsdom/compare/v0.2.0...v0.2.1
[v0.2.0]: https://github.com/rstacruz/mocha-jsdom/compare/v0.1.2...v0.2.0
[v0.1.2]: https://github.com/rstacruz/mocha-jsdom/compare/v0.1.1...v0.1.2
[v0.1.1]: https://github.com/rstacruz/mocha-jsdom/compare/v0.1.0...v0.1.1
[#18]: https://github.com/rstacruz/mocha-jsdom/issues/18
[@moonboots]: https://github.com/moonboots
Copyright © 2015 Rico Sta. Cruz
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> _Deprecation notice:_
> Consider [jsdom-global](https://github.com/rstacruz/jsdom-global) instead, a simpler alternative that also works outside of Mocha. `mocha-jsdom` still works, but `jsdom-global` is better supported.
---
# mocha-jsdom
> Test frontend libraries in the console using Node.js, [mocha] and [jsdom].
[![Status](https://travis-ci.org/rstacruz/mocha-jsdom.svg?branch=master)](https://travis-ci.org/rstacruz/mocha-jsdom "See test builds")
<br>
## Usage
```sh
$ npm i --save-dev mocha-jsdom
```
[![npm version](http://img.shields.io/npm/v/mocha-jsdom.svg?style=flat)](https://npmjs.org/package/mocha-jsdom "View this project on npm")
Use `jsdom()` inside your `describe(...)` block (or the global context). It will
turn your Node.js environment into a mock browser environment supporting the
full DOM and browser API. The variables `window`, `document`, `history` (and so
on) will then be available for use.
```js
var jsdom = require('mocha-jsdom')
var expect = require('chai').expect
describe('mocha tests', function () {
jsdom()
it('has document', function () {
var div = document.createElement('div')
expect(div.nodeName).eql('DIV')
})
})
```
See [examples/basic](examples/basic) for an example of a basic setup.
<br>
## Upgrading to v2.0.0
If you are coming from mocha-jsdom v1.x, remove `jsdom` if you're not using it before upgrading. `jsdom` is now a direct dependency of `mocha-jsdom`.
```bash
# using Yarn
yarn remove jsdom
yarn upgrade mocha-jsdom
```
```bash
# using npm
npm uninstall -S -D jsdom
npm upgrade mocha-jsdom
```
<br>
## Node and io.js information
As of jsdom 4.0.0, [jsdom now requires io.js](https://github.com/tmpvar/jsdom/blob/master/Changelog.md#400) and will not work with Node.js 0.12 or below.
<br>
## How it works
mocha-jsdom is a simple glue to integrate [jsdom] to mocha.
Invoking `jsdom()` will inject `before` and `after` handlers to the current
mocha suite which will setup and teardown jsdom. Here's what it does:
* __Window__: `global.window` will be available as the jsdom.
* __Globals__: global variables like `document` and `history` are propagated,
and they're cleaned up after tests run.
* __Error handling__: jsdom errors are sanitized so that their stack traces are
shortened.
__NB:__ Before you try this library, learn about jsdom first. In fact, you may be
able to integrate jsdom into your tests *without* this library; this is mostly
syntactic sugar and reasonable defaults.
<br>
## Using with a library
Perfect for testing small DOM-consuming utilities in the console. See
[test/jquery.js](test/jquery.js) for an example.
```js
describe('mocha tests', function () {
var $
jsdom()
before(function () {
$ = require('jquery')
})
it('works', function () {
document.body.innerHTML = '<div>hola</div>'
expect($("div").html()).eql('hola')
})
})
```
See [examples/basic](examples/basic) for an example of a basic setup.
<br>
## Using with a library, alternate
You can also pass the source code via `src`:
```js
describe('mocha tests', function () {
jsdom({
src: fs.readFileSync('jquery.js', 'utf-8')
})
...
})
```
<br>
## Configuration
You can pass jsdom options:
```js
describe('mocha tests', function () {
jsdom({
parsingMode: 'xml'
})
...
})
```
<br>
## Working with mocha --watch
When using with `--watch`, you my encounter strange errors from 3rd-party
libraries like jQuery not working properly.
In these cases, use `require('mocha-jsdom').rerequire` instead of `require()`.
This will ensure that the `require()` call will always happen.
```js
var $
var jsdom = require('mocha-jsdom')
var rerequire = jsdom.rerequire
jsdom()
before(function () {
$ = rerequire('jquery')
})
```
<br>
## Special config
Other mocha-jsdom specific options:
* `globalize` - propagates to values in `window` to `global`. defaults to true.
* `console` - allows you to use `console.log` inside a jsdom script. defaults
to true.
* `useEach` - bind to Mocha's `beforeEach`/`afterEach` rather than `before`/`after`.
defaults to false.
* `skipWindowCheck` - skips checking of `window` at startup. When false,
mocha-jsdom will throw an error if `window` already exists. Defaults to false.
[jsdom]: https://www.npmjs.org/package/jsdom
[mocha]: https://www.npmjs.com/package/mocha
<br>
## Testling support
Yes, fully compatible with testling. A test suite using jsdom should be able to use testling.
See [examples/basic](examples/basic/) for a setup that allows for testing via iojs (jsdom), testling, and mocha via the browser.
<br>
## Thanks
> **mocha-jsdom** © 2014-2018 Rico Sta. Cruz. Released under the [MIT] License.<br>
> Authored and maintained by Rico Sta. Cruz with help from contributors ([list][contributors]).
[![](https://img.shields.io/github/followers/rstacruz.svg?style=social&label=@rstacruz)](https://github.com/rstacruz)
&nbsp;&nbsp;
[![](https://img.shields.io/twitter/follow/rstacruz.svg?style=social&label=@rstacruz)](https://twitter.com/rstacruz)
&nbsp;&nbsp;
**[ricostacruz.com](http://ricostacruz.com)**
[mit]: http://mit-license.org/
[contributors]: http://github.com/rstacruz/mocha-jsdom/contributors
/*
* A noop version in case your tests are browserified (eg, when using
* testling).
*/
module.exports = function () {}
This is a basic example of what you can put in your project's `test/` folder.
It will allow you to run tests in both jsdom (iojs/node) and the browser.
<!doctype html>
<html>
<head>
<title>Mocha</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css" rel="stylesheet" />
</head>
<body>
<div id="mocha"></div>
<script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
<script src="https://cdn.rawgit.com/chaijs/chai/2.3.0/chai.js"></script>
<script>mocha.setup('bdd')</script>
<!-- thing to test -->
<script src="../index.js"></script>
<!-- your test files -->
<script src="setup.js"></script>
<script src="test.js"></script>
<script>mocha.run()</script>
</body>
</html>
if (typeof process === 'object') {
// Initialize node environment
global.expect = require('chai').expect
require('mocha-jsdom')()
} else {
window.expect = window.chai.expect
window.require = function () { /* noop */ }
}
/* global describe, it, before, expect */
require('./setup')
describe('my library', function () {
var mylib
before(function () {
mylib = require('mylib') || window.mylib
})
it('works', function () {
expect(mylib.greet()).to.eql('hola')
})
})
These examples are here so you can see what failures look like.
Run `mocha one.js` or `mocha two.js` to see.
/* global it, expect, describe */
/* jshint expr: true */
var jsdom = require('../../index')
describe('error', function () {
jsdom({
src: "(function () { throw new Error('ffff'); })()"
})
it('fails', function () {
expect(global.document).be.undefined // eslint-disable-line no-unused-expressions
})
})
/* global describe, it, expect */
describe('src', function () {
require('../../index')({
src: '}}'
})
it('works', function () {
expect(window.lol()).eql('DIV')
})
})
var extend = Object.assign || require('util')._extend // eslint-disable-line node/no-deprecated-api
var Path = require('path')
/*
* store original global keys
*/
var blacklist = Object.keys(global)
blacklist.push('constructor')
/*
* default config
*/
var defaults = {
globalize: true,
console: true,
useEach: false,
skipWindowCheck: false,
html:
"<!doctype html><html><head><meta charset='utf-8'></head>" +
'<body></body></html>'
}
/*
* simple jsdom integration.
* You can pass jsdom options in, too:
*
* require('./support/jsdom')({
* src: [ jquery ]
* })
*/
module.exports = function (_options) {
var options = extend(extend({}, defaults), _options)
var keys = []
var before = options.useEach ? global.beforeEach : global.before
var after = options.useEach ? global.afterEach : global.after
/*
* register jsdom before the entire test suite
*/
before(function (next) {
if (global.window && !options.skipWindowCheck) {
throw new Error(
'mocha-jsdom: already a browser environment, or mocha-jsdom invoked ' +
"twice. use 'skipWindowCheck' to disable this check."
)
}
require('jsdom/lib/old-api').env(
extend(extend({}, options), { done: done })
)
function done (errors, window) {
if (options.globalize) {
propagateToGlobal(window)
} else {
global.window = window
}
if (options.console) {
window.console = global.console
}
if (errors) {
return next(getError(errors))
}
next(null)
}
})
/*
* undo keys from being propagated to global after the test suite
*/
after(function () {
if (options.globalize) {
keys.forEach(function (key) {
delete global[key]
})
} else {
delete global.window
}
})
/*
* propagate keys from `window` to `global`
*/
function propagateToGlobal (window) {
for (var key in window) {
if (!window.hasOwnProperty(key)) continue
if (~blacklist.indexOf(key)) continue
if (global[key]) {
if (process.env.JSDOM_VERBOSE) {
console.warn(
"[jsdom] Warning: skipping cleanup of global['" + key + "']"
)
}
continue
}
keys.push(key)
global[key] = window[key]
}
}
/*
* re-throws jsdom errors
*/
function getError (errors) {
var data = errors[0].data
var err = data.error
err.message = err.message + ' [jsdom]'
// clean up stack trace
if (err.stack) {
err.stack = err.stack
.split('\n')
.reduce(function (list, line) {
if (line.match(/node_modules.+(jsdom|mocha)/)) {
return list
}
line = line
.replace(/file:\/\/.*<script>/g, '<script>')
.replace(/:undefined:undefined/g, '')
list.push(line)
return list
}, [])
.join('\n')
}
return err
}
}
module.exports.rerequire = rerequire
/**
* Requires a module via `require()`, but invalidates the cache so it may be
* called again in the future. Useful for `mocha --watch`.
*
* var rerequire = require('mocha-jsdom').rerequire
* var $ = rerequire('jquery')
*/
function rerequire (module) {
if (module[0] === '.') {
module = Path.join(Path.dirname(getCaller()), module)
}
var oldkeys = Object.keys(require.cache)
var result = require(module)
var newkeys = Object.keys(require.cache)
newkeys.forEach(function (newkey) {
if (!~oldkeys.indexOf(newkey)) {
delete require.cache[newkey]
}
})
return result
}
/**
* Internal: gets the filename of the caller function. The `offset` defines how
* many hops away it's expected to be from in the stack trace.
*
* See: http://stackoverflow.com/questions/16697791/nodejs-get-filename-of-caller-function
*/
function getCaller (offset) {
/* eslint-disable handle-callback-err */
if (typeof offset !== 'number') offset = 1
var old = Error.prepareStackTrace
var err = new Error()
Error.prepareStackTrace = function (err, stack) {
return stack
}
var fname = err.stack[1 + offset].getFileName()
Error.prepareStackTrace = old
return fname
}
{
"_args": [
[
"mocha-jsdom@2.0.0",
"C:\\Users\\user\\Desktop\\Singer-Composer"
]
],
"_development": true,
"_from": "mocha-jsdom@2.0.0",
"_id": "mocha-jsdom@2.0.0",
"_inBundle": false,
"_integrity": "sha512-+3D++FPXHXEesbBD7Q/r4dkc3XzVFMPLJVIECaQ685dj9qKQYzliqX8IXyIUbUL4x1QfgD9h8Zao8cn03NKKEA==",
"_location": "/mocha-jsdom",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "mocha-jsdom@2.0.0",
"name": "mocha-jsdom",
"escapedName": "mocha-jsdom",
"rawSpec": "2.0.0",
"saveSpec": null,
"fetchSpec": "2.0.0"
},
"_requiredBy": [
"#DEV:/"
],
"_resolved": "https://registry.npmjs.org/mocha-jsdom/-/mocha-jsdom-2.0.0.tgz",
"_spec": "2.0.0",
"_where": "C:\\Users\\user\\Desktop\\Singer-Composer",
"author": {
"name": "Rico Sta. Cruz",
"email": "rico@ricostacruz.com"
},
"browser": "browser.js",
"bugs": {
"url": "https://github.com/rstacruz/mocha-jsdom/issues"
},
"dependencies": {
"jsdom": "^11.11.0"
},
"description": "Simple integration of jsdom into mocha tests",
"devDependencies": {
"chai": "4.1.2",
"istanbul": "0.4.5",
"jquery": "3.3.1",
"mocha": "5.2.0",
"mocha-standard": "1.0.0",
"standard": "11.0.1"
},
"directories": {
"test": "test"
},
"homepage": "https://github.com/rstacruz/mocha-jsdom#readme",
"keywords": [
"jsdom",
"mocha"
],
"license": "MIT",
"main": "index.js",
"name": "mocha-jsdom",
"peerDependencies": {
"mocha": "*"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rstacruz/mocha-jsdom.git"
},
"scripts": {
"coverage": "istanbul cover _mocha -- -R spec",
"test": "mocha"
},
"version": "2.0.0"
}
/* this module will have side effects if it's ran more than once.
* we're gonna test for that. */
global._rerequirable_count++
/* global describe, it, expect */
/* jshint expr: true */
var jsdom = require('../index')
describe('globalize', function () {
jsdom({ globalize: false })
it('does not globalize', function () {
expect(global.document).be.undefined // eslint-disable-line no-unused-expressions
})
})
/* global describe, before, it, document, expect */
var jsdom = require('../index')
describe('jquery', function () {
var $
jsdom()
before(function () {
$ = require('jquery')
})
it('creating elements works', function () {
var div = $('<div>hello <b>world</b></div>')
expect(div.html()).to.eql('hello <b>world</b>')
})
it('lookup works', function () {
document.body.innerHTML = '<div>hola</div>'
expect($('div').html()).eql('hola')
})
})
--require test/setup
--timeout 5000
/* global describe, it, beforeEach, expect */
var rerequire = require('../index').rerequire
describe('rerequire', function () {
beforeEach(function () {
global._rerequirable_count = 0
})
it('has a fixture that works', function () {
rerequire('./fixtures/rerequirable')
expect(global._rerequirable_count).eql(1)
})
// ensure that subsequent runs don't bother
it('has a fixture that really works', function () {
rerequire('./fixtures/rerequirable')
expect(global._rerequirable_count).eql(1)
})
it('works 5x', function () {
rerequire('./fixtures/rerequirable')
rerequire('./fixtures/rerequirable')
rerequire('./fixtures/rerequirable')
rerequire('./fixtures/rerequirable')
rerequire('./fixtures/rerequirable')
expect(global._rerequirable_count).eql(5)
})
})
/* global it, before, window, describe, expect */
var jsdom = require('../index')
describe('robust', function () {
before(function () {
// User or another test framework redefines global.window
global.window = undefined
})
jsdom()
it('has window', function () {
expect(global.window).to.not.be.undefined // eslint-disable-line no-unused-expressions
})
})
global.expect = require('chai').expect
/* global it, history, describe, location, expect */
var jsdom = require('../index')
describe('simple', function () {
jsdom()
it('has document', function () {
var div = document.createElement('div')
expect(div.nodeName).eql('DIV')
})
it('has history', function () {
history.pushState({}, 'abc', '#/a/b/c')
expect(location.href).match(/\/a\/b\/c$/)
})
})
/* global describe, it, before, after, expect */
/* jshint expr: true */
var jsdom = require('../index')
describe('skipWindowCheck: true', function () {
before(function () {
global.window = {}
})
after(function () {
delete global.window
})
jsdom({ skipWindowCheck: true })
it('does not throw errors', function () {
var div = document.createElement('div')
expect(div.nodeName).eql('DIV')
})
})
/* global describe, it */
describe('standard', function () {
it('is conformed to', require('mocha-standard'))
})
/* global describe, it, expect */
/* jshint expr: true */
var jsdom = require('../index')
describe('check useEach false (default)', function () {
var someContent = '<div>hola</div>'
jsdom()
it('check that html body is empty', function () {
expect(document.body.innerHTML).to.be.empty // eslint-disable-line no-unused-expressions
})
it('accepts an html body', function () {
document.body.innerHTML = someContent
expect(document.body.innerHTML).eql(someContent)
})
it('has document persisting across tests', function () {
expect(document.body.innerHTML).eql(someContent)
})
})
describe('check useEach true', function () {
var someContent = '<div>hola</div>'
jsdom({ useEach: true })
it('check that html body is empty', function () {
expect(document.body.innerHTML).to.be.empty // eslint-disable-line no-unused-expressions
})
it('accepts an html body', function () {
document.body.innerHTML = someContent
expect(document.body.innerHTML).eql(someContent)
})
it('changes to the dom do not persist between tests', function () {
expect(document.body.innerHTML).to.be.empty // eslint-disable-line no-unused-expressions
})
})
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
abab@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e"
abbrev@1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
abbrev@1.0.x:
version "1.0.9"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135"
acorn-globals@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-4.1.0.tgz#ab716025dbe17c54d3ef81d32ece2b2d99fe2538"
dependencies:
acorn "^5.0.0"
acorn-jsx@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b"
dependencies:
acorn "^3.0.4"
acorn@^3.0.4:
version "3.3.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"
acorn@^5.0.0, acorn@^5.3.0, acorn@^5.5.0:
version "5.6.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.6.1.tgz#c9e50c3e3717cf897f1b071ceadbb543bbc0a8d4"
ajv-keywords@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762"
ajv@^5.1.0, ajv@^5.2.3, ajv@^5.3.0:
version "5.5.2"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965"
dependencies:
co "^4.6.0"
fast-deep-equal "^1.0.0"
fast-json-stable-stringify "^2.0.0"
json-schema-traverse "^0.3.0"
align-text@^0.1.1, align-text@^0.1.3:
version "0.1.4"
resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117"
dependencies:
kind-of "^3.0.2"
longest "^1.0.1"
repeat-string "^1.5.2"
amdefine@>=0.0.4:
version "1.0.1"
resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"
ansi-escapes@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.1.0.tgz#f73207bb81207d75fd6c83f125af26eea378ca30"
ansi-regex@^2.0.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
ansi-regex@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998"
ansi-styles@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
ansi-styles@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
dependencies:
color-convert "^1.9.0"
argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
dependencies:
sprintf-js "~1.0.2"
array-equal@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93"
array-includes@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.0.3.tgz#184b48f62d92d7452bb31b323165c7f8bd02266d"
dependencies:
define-properties "^1.1.2"
es-abstract "^1.7.0"
array-union@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39"
dependencies:
array-uniq "^1.0.1"
array-uniq@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6"
arrify@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
asap@~2.0.3:
version "2.0.6"
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
asn1@~0.2.3:
version "0.2.3"
resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86"
assert-plus@1.0.0, assert-plus@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525"
assertion-error@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"
async-limiter@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8"
async@1.x, async@^1.4.0:
version "1.5.2"
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
aws-sign2@~0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8"
aws4@^1.6.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.7.0.tgz#d4d0e9b9dbfca77bf08eeb0a8a471550fe39e289"
babel-code-frame@^6.22.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
dependencies:
chalk "^1.1.3"
esutils "^2.0.2"
js-tokens "^3.0.2"
balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
bcrypt-pbkdf@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d"
dependencies:
tweetnacl "^0.14.3"
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
browser-process-hrtime@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz#425d68a58d3447f02a04aa894187fce8af8b7b8e"
browser-stdout@1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60"
buffer-from@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.0.tgz#87fcaa3a298358e0ade6e442cfce840740d1ad04"
builtin-modules@^1.0.0, builtin-modules@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
caller-path@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f"
dependencies:
callsites "^0.2.0"
callsites@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca"
camelcase@^1.0.2:
version "1.2.1"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39"
caseless@~0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
center-align@^0.1.1:
version "0.1.3"
resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad"
dependencies:
align-text "^0.1.3"
lazy-cache "^1.0.3"
chai@4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.2.tgz#0f64584ba642f0f2ace2806279f4f06ca23ad73c"
dependencies:
assertion-error "^1.0.1"
check-error "^1.0.1"
deep-eql "^3.0.0"
get-func-name "^2.0.0"
pathval "^1.0.0"
type-detect "^4.0.0"
chalk@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
dependencies:
ansi-styles "^2.2.1"
escape-string-regexp "^1.0.2"
has-ansi "^2.0.0"
strip-ansi "^3.0.0"
supports-color "^2.0.0"
chalk@^2.0.0, chalk@^2.1.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e"
dependencies:
ansi-styles "^3.2.1"
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"
chardet@^0.4.0:
version "0.4.2"
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"
check-error@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82"
circular-json@^0.3.1:
version "0.3.3"
resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66"
cli-cursor@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
dependencies:
restore-cursor "^2.0.0"
cli-width@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
cliui@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1"
dependencies:
center-align "^0.1.1"
right-align "^0.1.1"
wordwrap "0.0.2"
co@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
color-convert@^1.9.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.1.tgz#c1261107aeb2f294ebffec9ed9ecad529a6097ed"
dependencies:
color-name "^1.1.1"
color-name@^1.1.1:
version "1.1.3"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
combined-stream@1.0.6, combined-stream@~1.0.5:
version "1.0.6"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818"
dependencies:
delayed-stream "~1.0.0"
commander@2.15.1:
version "2.15.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f"
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
concat-stream@^1.6.0:
version "1.6.2"
resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34"
dependencies:
buffer-from "^1.0.0"
inherits "^2.0.3"
readable-stream "^2.2.2"
typedarray "^0.0.6"
contains-path@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a"
core-js@^1.0.0:
version "1.2.7"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
core-util-is@1.0.2, core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
cross-spawn@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
dependencies:
lru-cache "^4.0.1"
shebang-command "^1.2.0"
which "^1.2.9"
cssom@0.3.x, "cssom@>= 0.3.2 < 0.4.0":
version "0.3.2"
resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.2.tgz#b8036170c79f07a90ff2f16e22284027a243848b"
"cssstyle@>= 0.3.1 < 0.4.0":
version "0.3.1"
resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-0.3.1.tgz#6da9b4cff1bc5d716e6e5fe8e04fcb1b50a49adf"
dependencies:
cssom "0.3.x"
dashdash@^1.12.0:
version "1.14.1"
resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"
dependencies:
assert-plus "^1.0.0"
data-urls@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-1.0.0.tgz#24802de4e81c298ea8a9388bb0d8e461c774684f"
dependencies:
abab "^1.0.4"
whatwg-mimetype "^2.0.0"
whatwg-url "^6.4.0"
debug-log@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/debug-log/-/debug-log-1.0.1.tgz#2307632d4c04382b8df8a32f70b895046d52745f"
debug@3.1.0, debug@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
dependencies:
ms "2.0.0"
debug@^2.6.8, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
dependencies:
ms "2.0.0"
decamelize@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
deep-eql@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df"
dependencies:
type-detect "^4.0.0"
deep-is@~0.1.3:
version "0.1.3"
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
define-properties@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
dependencies:
foreach "^2.0.5"
object-keys "^1.0.8"
deglob@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/deglob/-/deglob-2.1.0.tgz#4d44abe16ef32c779b4972bd141a80325029a14a"
dependencies:
find-root "^1.0.0"
glob "^7.0.5"
ignore "^3.0.9"
pkg-config "^1.1.0"
run-parallel "^1.1.2"
uniq "^1.0.1"
del@^2.0.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8"
dependencies:
globby "^5.0.0"
is-path-cwd "^1.0.0"
is-path-in-cwd "^1.0.0"
object-assign "^4.0.1"
pify "^2.0.0"
pinkie-promise "^2.0.0"
rimraf "^2.2.8"
delayed-stream@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
diff@3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
doctrine@1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa"
dependencies:
esutils "^2.0.2"
isarray "^1.0.0"
doctrine@^2.0.2, doctrine@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d"
dependencies:
esutils "^2.0.2"
domexception@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/domexception/-/domexception-1.0.1.tgz#937442644ca6a31261ef36e3ec677fe805582c90"
dependencies:
webidl-conversions "^4.0.2"
ecc-jsbn@~0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
dependencies:
jsbn "~0.1.0"
encoding@^0.1.11:
version "0.1.12"
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
dependencies:
iconv-lite "~0.4.13"
error-ex@^1.2.0, error-ex@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc"
dependencies:
is-arrayish "^0.2.1"
es-abstract@^1.7.0:
version "1.12.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.12.0.tgz#9dbbdd27c6856f0001421ca18782d786bf8a6165"
dependencies:
es-to-primitive "^1.1.1"
function-bind "^1.1.1"
has "^1.0.1"
is-callable "^1.1.3"
is-regex "^1.0.4"
es-to-primitive@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
dependencies:
is-callable "^1.1.1"
is-date-object "^1.0.1"
is-symbol "^1.0.1"
escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
escodegen@1.8.x:
version "1.8.1"
resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.8.1.tgz#5a5b53af4693110bebb0867aa3430dd3b70a1018"
dependencies:
esprima "^2.7.1"
estraverse "^1.9.1"
esutils "^2.0.2"
optionator "^0.8.1"
optionalDependencies:
source-map "~0.2.0"
escodegen@^1.9.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.9.1.tgz#dbae17ef96c8e4bedb1356f4504fa4cc2f7cb7e2"
dependencies:
esprima "^3.1.3"
estraverse "^4.2.0"
esutils "^2.0.2"
optionator "^0.8.1"
optionalDependencies:
source-map "~0.6.1"
eslint-config-standard-jsx@5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/eslint-config-standard-jsx/-/eslint-config-standard-jsx-5.0.0.tgz#4abfac554f38668e0078c664569e7b2384e5d2aa"
eslint-config-standard@11.0.0:
version "11.0.0"
resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-11.0.0.tgz#87ee0d3c9d95382dc761958cbb23da9eea31e0ba"
eslint-import-resolver-node@^0.3.1:
version "0.3.2"
resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz#58f15fb839b8d0576ca980413476aab2472db66a"
dependencies:
debug "^2.6.9"
resolve "^1.5.0"
eslint-module-utils@^2.1.1:
version "2.2.0"
resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.2.0.tgz#b270362cd88b1a48ad308976ce7fa54e98411746"
dependencies:
debug "^2.6.8"
pkg-dir "^1.0.0"
eslint-plugin-import@~2.9.0:
version "2.9.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.9.0.tgz#26002efbfca5989b7288ac047508bd24f217b169"
dependencies:
builtin-modules "^1.1.1"
contains-path "^0.1.0"
debug "^2.6.8"
doctrine "1.5.0"
eslint-import-resolver-node "^0.3.1"
eslint-module-utils "^2.1.1"
has "^1.0.1"
lodash "^4.17.4"
minimatch "^3.0.3"
read-pkg-up "^2.0.0"
eslint-plugin-node@~6.0.0:
version "6.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-6.0.1.tgz#bf19642298064379315d7a4b2a75937376fa05e4"
dependencies:
ignore "^3.3.6"
minimatch "^3.0.4"
resolve "^1.3.3"
semver "^5.4.1"
eslint-plugin-promise@~3.7.0:
version "3.7.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.7.0.tgz#f4bde5c2c77cdd69557a8f69a24d1ad3cfc9e67e"
eslint-plugin-react@~7.7.0:
version "7.7.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.7.0.tgz#f606c719dbd8a1a2b3d25c16299813878cca0160"
dependencies:
doctrine "^2.0.2"
has "^1.0.1"
jsx-ast-utils "^2.0.1"
prop-types "^15.6.0"
eslint-plugin-standard@~3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-standard/-/eslint-plugin-standard-3.0.1.tgz#34d0c915b45edc6f010393c7eef3823b08565cf2"
eslint-scope@^3.7.1:
version "3.7.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"
dependencies:
esrecurse "^4.1.0"
estraverse "^4.1.1"
eslint-visitor-keys@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d"
eslint@~4.18.0:
version "4.18.2"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.18.2.tgz#0f81267ad1012e7d2051e186a9004cc2267b8d45"
dependencies:
ajv "^5.3.0"
babel-code-frame "^6.22.0"
chalk "^2.1.0"
concat-stream "^1.6.0"
cross-spawn "^5.1.0"
debug "^3.1.0"
doctrine "^2.1.0"
eslint-scope "^3.7.1"
eslint-visitor-keys "^1.0.0"
espree "^3.5.2"
esquery "^1.0.0"
esutils "^2.0.2"
file-entry-cache "^2.0.0"
functional-red-black-tree "^1.0.1"
glob "^7.1.2"
globals "^11.0.1"
ignore "^3.3.3"
imurmurhash "^0.1.4"
inquirer "^3.0.6"
is-resolvable "^1.0.0"
js-yaml "^3.9.1"
json-stable-stringify-without-jsonify "^1.0.1"
levn "^0.3.0"
lodash "^4.17.4"
minimatch "^3.0.2"
mkdirp "^0.5.1"
natural-compare "^1.4.0"
optionator "^0.8.2"
path-is-inside "^1.0.2"
pluralize "^7.0.0"
progress "^2.0.0"
require-uncached "^1.0.3"
semver "^5.3.0"
strip-ansi "^4.0.0"
strip-json-comments "~2.0.1"
table "4.0.2"
text-table "~0.2.0"
espree@^3.5.2:
version "3.5.4"
resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7"
dependencies:
acorn "^5.5.0"
acorn-jsx "^3.0.0"
esprima@2.7.x, esprima@^2.7.1:
version "2.7.3"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581"
esprima@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633"
esprima@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804"
esquery@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.1.tgz#406c51658b1f5991a5f9b62b1dc25b00e3e5c708"
dependencies:
estraverse "^4.0.0"
esrecurse@^4.1.0:
version "4.2.1"
resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf"
dependencies:
estraverse "^4.1.0"
estraverse@^1.9.1:
version "1.9.3"
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44"
estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13"
esutils@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b"
extend@~3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444"
external-editor@^2.0.4:
version "2.2.0"
resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.2.0.tgz#045511cfd8d133f3846673d1047c154e214ad3d5"
dependencies:
chardet "^0.4.0"
iconv-lite "^0.4.17"
tmp "^0.0.33"
extsprintf@1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05"
extsprintf@^1.2.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f"
fast-deep-equal@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614"
fast-json-stable-stringify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2"
fast-levenshtein@~2.0.4:
version "2.0.6"
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
fbjs@^0.8.16:
version "0.8.16"
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db"
dependencies:
core-js "^1.0.0"
isomorphic-fetch "^2.1.1"
loose-envify "^1.0.0"
object-assign "^4.1.0"
promise "^7.1.1"
setimmediate "^1.0.5"
ua-parser-js "^0.7.9"
figures@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962"
dependencies:
escape-string-regexp "^1.0.5"
file-entry-cache@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361"
dependencies:
flat-cache "^1.2.1"
object-assign "^4.0.1"
find-root@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/find-root/-/find-root-1.1.0.tgz#abcfc8ba76f708c42a97b3d685b7e9450bfb9ce4"
find-up@^1.0.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f"
dependencies:
path-exists "^2.0.0"
pinkie-promise "^2.0.0"
find-up@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7"
dependencies:
locate-path "^2.0.0"
flat-cache@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481"
dependencies:
circular-json "^0.3.1"
del "^2.0.2"
graceful-fs "^4.1.2"
write "^0.2.1"
foreach@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
forever-agent@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
form-data@~2.3.1:
version "2.3.2"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.2.tgz#4970498be604c20c005d4f5c23aecd21d6b49099"
dependencies:
asynckit "^0.4.0"
combined-stream "1.0.6"
mime-types "^2.1.12"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
functional-red-black-tree@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
get-func-name@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41"
get-stdin@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b"
getpass@^0.1.1:
version "0.1.7"
resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa"
dependencies:
assert-plus "^1.0.0"
glob@7.1.2, glob@^7.0.3, glob@^7.0.5, glob@^7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
glob@^5.0.15:
version "5.0.15"
resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1"
dependencies:
inflight "^1.0.4"
inherits "2"
minimatch "2 || 3"
once "^1.3.0"
path-is-absolute "^1.0.0"
globals@^11.0.1:
version "11.5.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-11.5.0.tgz#6bc840de6771173b191f13d3a9c94d441ee92642"
globby@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d"
dependencies:
array-union "^1.0.1"
arrify "^1.0.0"
glob "^7.0.3"
object-assign "^4.0.1"
pify "^2.0.0"
pinkie-promise "^2.0.0"
graceful-fs@^4.1.2:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
growl@1.10.5:
version "1.10.5"
resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e"
handlebars@^4.0.1:
version "4.0.11"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc"
dependencies:
async "^1.4.0"
optimist "^0.6.1"
source-map "^0.4.4"
optionalDependencies:
uglify-js "^2.6"
har-schema@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92"
har-validator@~5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.0.3.tgz#ba402c266194f15956ef15e0fcf242993f6a7dfd"
dependencies:
ajv "^5.1.0"
har-schema "^2.0.0"
has-ansi@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
dependencies:
ansi-regex "^2.0.0"
has-flag@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa"
has-flag@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
has@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796"
dependencies:
function-bind "^1.1.1"
he@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd"
hosted-git-info@^2.1.4:
version "2.6.0"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.6.0.tgz#23235b29ab230c576aab0d4f13fc046b0b038222"
html-encoding-sniffer@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz#e70d84b94da53aa375e11fe3a351be6642ca46f8"
dependencies:
whatwg-encoding "^1.0.1"
http-signature@~1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1"
dependencies:
assert-plus "^1.0.0"
jsprim "^1.2.2"
sshpk "^1.7.0"
iconv-lite@0.4.19:
version "0.4.19"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
iconv-lite@^0.4.17, iconv-lite@~0.4.13:
version "0.4.23"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63"
dependencies:
safer-buffer ">= 2.1.2 < 3"
ignore@^3.0.9, ignore@^3.3.3, ignore@^3.3.6:
version "3.3.8"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.8.tgz#3f8e9c35d38708a3a7e0e9abb6c73e7ee7707b2b"
imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2, inherits@^2.0.3, inherits@~2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
inquirer@^3.0.6:
version "3.3.0"
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9"
dependencies:
ansi-escapes "^3.0.0"
chalk "^2.0.0"
cli-cursor "^2.1.0"
cli-width "^2.0.0"
external-editor "^2.0.4"
figures "^2.0.0"
lodash "^4.3.0"
mute-stream "0.0.7"
run-async "^2.2.0"
rx-lite "^4.0.8"
rx-lite-aggregates "^4.0.8"
string-width "^2.1.0"
strip-ansi "^4.0.0"
through "^2.3.6"
is-arrayish@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
is-buffer@^1.1.5:
version "1.1.6"
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
is-builtin-module@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe"
dependencies:
builtin-modules "^1.0.0"
is-callable@^1.1.1, is-callable@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
is-date-object@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
is-fullwidth-code-point@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
is-path-cwd@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d"
is-path-in-cwd@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz#5ac48b345ef675339bd6c7a48a912110b241cf52"
dependencies:
is-path-inside "^1.0.0"
is-path-inside@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036"
dependencies:
path-is-inside "^1.0.1"
is-promise@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa"
is-regex@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
dependencies:
has "^1.0.1"
is-resolvable@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.1.0.tgz#fb18f87ce1feb925169c9a407c19318a3206ed88"
is-stream@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
is-symbol@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
is-typedarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
isarray@^1.0.0, isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
isomorphic-fetch@^2.1.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
dependencies:
node-fetch "^1.0.1"
whatwg-fetch ">=0.10.0"
isstream@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
istanbul@0.4.5:
version "0.4.5"
resolved "https://registry.yarnpkg.com/istanbul/-/istanbul-0.4.5.tgz#65c7d73d4c4da84d4f3ac310b918fb0b8033733b"
dependencies:
abbrev "1.0.x"
async "1.x"
escodegen "1.8.x"
esprima "2.7.x"
glob "^5.0.15"
handlebars "^4.0.1"
js-yaml "3.x"
mkdirp "0.5.x"
nopt "3.x"
once "1.x"
resolve "1.1.x"
supports-color "^3.1.0"
which "^1.1.1"
wordwrap "^1.0.0"
jquery@3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca"
js-tokens@^3.0.0, js-tokens@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
js-yaml@3.x, js-yaml@^3.9.1:
version "3.12.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1"
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"
jsbn@~0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
jsdom@^11.11.0:
version "11.11.0"
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-11.11.0.tgz#df486efad41aee96c59ad7a190e2449c7eb1110e"
dependencies:
abab "^1.0.4"
acorn "^5.3.0"
acorn-globals "^4.1.0"
array-equal "^1.0.0"
cssom ">= 0.3.2 < 0.4.0"
cssstyle ">= 0.3.1 < 0.4.0"
data-urls "^1.0.0"
domexception "^1.0.0"
escodegen "^1.9.0"
html-encoding-sniffer "^1.0.2"
left-pad "^1.2.0"
nwsapi "^2.0.0"
parse5 "4.0.0"
pn "^1.1.0"
request "^2.83.0"
request-promise-native "^1.0.5"
sax "^1.2.4"
symbol-tree "^3.2.2"
tough-cookie "^2.3.3"
w3c-hr-time "^1.0.1"
webidl-conversions "^4.0.2"
whatwg-encoding "^1.0.3"
whatwg-mimetype "^2.1.0"
whatwg-url "^6.4.1"
ws "^4.0.0"
xml-name-validator "^3.0.0"
json-parse-better-errors@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"
json-schema-traverse@^0.3.0:
version "0.3.1"
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340"
json-schema@0.2.3:
version "0.2.3"
resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13"
json-stable-stringify-without-jsonify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
json-stringify-safe@~5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
jsprim@^1.2.2:
version "1.4.1"
resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2"
dependencies:
assert-plus "1.0.0"
extsprintf "1.3.0"
json-schema "0.2.3"
verror "1.10.0"
jsx-ast-utils@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz#e801b1b39985e20fffc87b40e3748080e2dcac7f"
dependencies:
array-includes "^3.0.3"
kind-of@^3.0.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
dependencies:
is-buffer "^1.1.5"
lazy-cache@^1.0.3:
version "1.0.4"
resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e"
left-pad@^1.2.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.3.0.tgz#5b8a3a7765dfe001261dde915589e782f8c94d1e"
levn@^0.3.0, levn@~0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee"
dependencies:
prelude-ls "~1.1.2"
type-check "~0.3.2"
load-json-file@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-2.0.0.tgz#7947e42149af80d696cbf797bcaabcfe1fe29ca8"
dependencies:
graceful-fs "^4.1.2"
parse-json "^2.2.0"
pify "^2.0.0"
strip-bom "^3.0.0"
load-json-file@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b"
dependencies:
graceful-fs "^4.1.2"
parse-json "^4.0.0"
pify "^3.0.0"
strip-bom "^3.0.0"
locate-path@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e"
dependencies:
p-locate "^2.0.0"
path-exists "^3.0.0"
lodash.sortby@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
lodash@^4.13.1, lodash@^4.17.4, lodash@^4.3.0:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
longest@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097"
loose-envify@^1.0.0, loose-envify@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
dependencies:
js-tokens "^3.0.0"
lru-cache@^4.0.1:
version "4.1.3"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c"
dependencies:
pseudomap "^1.0.2"
yallist "^2.1.2"
mime-db@~1.33.0:
version "1.33.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.33.0.tgz#a3492050a5cb9b63450541e39d9788d2272783db"
mime-types@^2.1.12, mime-types@~2.1.17:
version "2.1.18"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.18.tgz#6f323f60a83d11146f831ff11fd66e2fe5503bb8"
dependencies:
mime-db "~1.33.0"
mimic-fn@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
"minimatch@2 || 3", minimatch@3.0.4, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
dependencies:
brace-expansion "^1.1.7"
minimist@0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
minimist@^1.1.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
minimist@~0.0.1:
version "0.0.10"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"
mkdirp@0.5.1, mkdirp@0.5.x, mkdirp@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
dependencies:
minimist "0.0.8"
mocha-standard@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/mocha-standard/-/mocha-standard-1.0.0.tgz#12150cfdce405564068bac3f9e66661c3ccd15f8"
mocha@5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-5.2.0.tgz#6d8ae508f59167f940f2b5b3c4a612ae50c90ae6"
dependencies:
browser-stdout "1.3.1"
commander "2.15.1"
debug "3.1.0"
diff "3.5.0"
escape-string-regexp "1.0.5"
glob "7.1.2"
growl "1.10.5"
he "1.1.1"
minimatch "3.0.4"
mkdirp "0.5.1"
supports-color "5.4.0"
ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
mute-stream@0.0.7:
version "0.0.7"
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"
natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
node-fetch@^1.0.1:
version "1.7.3"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
dependencies:
encoding "^0.1.11"
is-stream "^1.0.1"
nopt@3.x:
version "3.0.6"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9"
dependencies:
abbrev "1"
normalize-package-data@^2.3.2:
version "2.4.0"
resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f"
dependencies:
hosted-git-info "^2.1.4"
is-builtin-module "^1.0.0"
semver "2 || 3 || 4 || 5"
validate-npm-package-license "^3.0.1"
nwsapi@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.0.1.tgz#a50d59a2dcb14b6931401171713ced2d0eb3468f"
oauth-sign@~0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43"
object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
object-keys@^1.0.8:
version "1.0.11"
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
once@1.x, once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
dependencies:
wrappy "1"
onetime@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4"
dependencies:
mimic-fn "^1.0.0"
optimist@^0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
dependencies:
minimist "~0.0.1"
wordwrap "~0.0.2"
optionator@^0.8.1, optionator@^0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64"
dependencies:
deep-is "~0.1.3"
fast-levenshtein "~2.0.4"
levn "~0.3.0"
prelude-ls "~1.1.2"
type-check "~0.3.2"
wordwrap "~1.0.0"
os-tmpdir@~1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
p-limit@^1.1.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.2.0.tgz#0e92b6bedcb59f022c13d0f1949dc82d15909f1c"
dependencies:
p-try "^1.0.0"
p-locate@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43"
dependencies:
p-limit "^1.1.0"
p-try@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"
parse-json@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9"
dependencies:
error-ex "^1.2.0"
parse-json@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0"
dependencies:
error-ex "^1.3.1"
json-parse-better-errors "^1.0.1"
parse5@4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/parse5/-/parse5-4.0.0.tgz#6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608"
path-exists@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b"
dependencies:
pinkie-promise "^2.0.0"
path-exists@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
path-is-inside@^1.0.1, path-is-inside@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"
path-parse@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"
path-type@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73"
dependencies:
pify "^2.0.0"
pathval@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0"
performance-now@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
pify@^2.0.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
pify@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176"
pinkie-promise@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa"
dependencies:
pinkie "^2.0.0"
pinkie@^2.0.0:
version "2.0.4"
resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870"
pkg-conf@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/pkg-conf/-/pkg-conf-2.1.0.tgz#2126514ca6f2abfebd168596df18ba57867f0058"
dependencies:
find-up "^2.0.0"
load-json-file "^4.0.0"
pkg-config@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/pkg-config/-/pkg-config-1.1.1.tgz#557ef22d73da3c8837107766c52eadabde298fe4"
dependencies:
debug-log "^1.0.0"
find-root "^1.0.0"
xtend "^4.0.1"
pkg-dir@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-1.0.0.tgz#7a4b508a8d5bb2d629d447056ff4e9c9314cf3d4"
dependencies:
find-up "^1.0.0"
pluralize@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777"
pn@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb"
prelude-ls@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
process-nextick-args@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa"
progress@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f"
promise@^7.1.1:
version "7.3.1"
resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
dependencies:
asap "~2.0.3"
prop-types@^15.6.0:
version "15.6.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.1.tgz#36644453564255ddda391191fb3a125cbdf654ca"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.3.1"
object-assign "^4.1.1"
pseudomap@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
punycode@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"
punycode@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
qs@~6.5.1:
version "6.5.2"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
read-pkg-up@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-2.0.0.tgz#6b72a8048984e0c41e79510fd5e9fa99b3b549be"
dependencies:
find-up "^2.0.0"
read-pkg "^2.0.0"
read-pkg@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-2.0.0.tgz#8ef1c0623c6a6db0dc6713c4bfac46332b2368f8"
dependencies:
load-json-file "^2.0.0"
normalize-package-data "^2.3.2"
path-type "^2.0.0"
readable-stream@^2.2.2:
version "2.3.6"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"
dependencies:
core-util-is "~1.0.0"
inherits "~2.0.3"
isarray "~1.0.0"
process-nextick-args "~2.0.0"
safe-buffer "~5.1.1"
string_decoder "~1.1.1"
util-deprecate "~1.0.1"
repeat-string@^1.5.2:
version "1.6.1"
resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637"
request-promise-core@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.1.tgz#3eee00b2c5aa83239cfb04c5700da36f81cd08b6"
dependencies:
lodash "^4.13.1"
request-promise-native@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.5.tgz#5281770f68e0c9719e5163fd3fab482215f4fda5"
dependencies:
request-promise-core "1.1.1"
stealthy-require "^1.1.0"
tough-cookie ">=2.3.3"
request@^2.83.0:
version "2.87.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.87.0.tgz#32f00235cd08d482b4d0d68db93a829c0ed5756e"
dependencies:
aws-sign2 "~0.7.0"
aws4 "^1.6.0"
caseless "~0.12.0"
combined-stream "~1.0.5"
extend "~3.0.1"
forever-agent "~0.6.1"
form-data "~2.3.1"
har-validator "~5.0.3"
http-signature "~1.2.0"
is-typedarray "~1.0.0"
isstream "~0.1.2"
json-stringify-safe "~5.0.1"
mime-types "~2.1.17"
oauth-sign "~0.8.2"
performance-now "^2.1.0"
qs "~6.5.1"
safe-buffer "^5.1.1"
tough-cookie "~2.3.3"
tunnel-agent "^0.6.0"
uuid "^3.1.0"
require-uncached@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3"
dependencies:
caller-path "^0.1.0"
resolve-from "^1.0.0"
resolve-from@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226"
resolve@1.1.x:
version "1.1.7"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
resolve@^1.3.3, resolve@^1.5.0:
version "1.7.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.7.1.tgz#aadd656374fd298aee895bc026b8297418677fd3"
dependencies:
path-parse "^1.0.5"
restore-cursor@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"
dependencies:
onetime "^2.0.0"
signal-exit "^3.0.2"
right-align@^0.1.1:
version "0.1.3"
resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef"
dependencies:
align-text "^0.1.1"
rimraf@^2.2.8:
version "2.6.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
dependencies:
glob "^7.0.5"
run-async@^2.2.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0"
dependencies:
is-promise "^2.1.0"
run-parallel@^1.1.2:
version "1.1.9"
resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.1.9.tgz#c9dd3a7cf9f4b2c4b6244e173a6ed866e61dd679"
rx-lite-aggregates@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be"
dependencies:
rx-lite "*"
rx-lite@*, rx-lite@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444"
safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.2"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
"safer-buffer@>= 2.1.2 < 3":
version "2.1.2"
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
sax@^1.2.4:
version "1.2.4"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1:
version "5.5.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
setimmediate@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
dependencies:
shebang-regex "^1.0.0"
shebang-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
signal-exit@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
slice-ansi@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d"
dependencies:
is-fullwidth-code-point "^2.0.0"
source-map@^0.4.4:
version "0.4.4"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b"
dependencies:
amdefine ">=0.0.4"
source-map@~0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.2.0.tgz#dab73fbcfc2ba819b4de03bd6f6eaa48164b3f9d"
dependencies:
amdefine ">=0.0.4"
source-map@~0.5.1:
version "0.5.7"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
source-map@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
spdx-correct@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.0.0.tgz#05a5b4d7153a195bc92c3c425b69f3b2a9524c82"
dependencies:
spdx-expression-parse "^3.0.0"
spdx-license-ids "^3.0.0"
spdx-exceptions@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz#2c7ae61056c714a5b9b9b2b2af7d311ef5c78fe9"
spdx-expression-parse@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz#99e119b7a5da00e05491c9fa338b7904823b41d0"
dependencies:
spdx-exceptions "^2.1.0"
spdx-license-ids "^3.0.0"
spdx-license-ids@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz#7a7cd28470cc6d3a1cfe6d66886f6bc430d3ac87"
sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
sshpk@^1.7.0:
version "1.14.1"
resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.14.1.tgz#130f5975eddad963f1d56f92b9ac6c51fa9f83eb"
dependencies:
asn1 "~0.2.3"
assert-plus "^1.0.0"
dashdash "^1.12.0"
getpass "^0.1.1"
optionalDependencies:
bcrypt-pbkdf "^1.0.0"
ecc-jsbn "~0.1.1"
jsbn "~0.1.0"
tweetnacl "~0.14.0"
standard-engine@~8.0.0:
version "8.0.1"
resolved "https://registry.yarnpkg.com/standard-engine/-/standard-engine-8.0.1.tgz#0b77be8d7ab963675717dbeac1ef1d6675fb62f0"
dependencies:
deglob "^2.1.0"
get-stdin "^6.0.0"
minimist "^1.1.0"
pkg-conf "^2.0.0"
standard@11.0.1:
version "11.0.1"
resolved "https://registry.yarnpkg.com/standard/-/standard-11.0.1.tgz#49be40c76f1d564964b22bbf7309929ad0335e29"
dependencies:
eslint "~4.18.0"
eslint-config-standard "11.0.0"
eslint-config-standard-jsx "5.0.0"
eslint-plugin-import "~2.9.0"
eslint-plugin-node "~6.0.0"
eslint-plugin-promise "~3.7.0"
eslint-plugin-react "~7.7.0"
eslint-plugin-standard "~3.0.1"
standard-engine "~8.0.0"
stealthy-require@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"
string-width@^2.1.0, string-width@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
dependencies:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^4.0.0"
string_decoder@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8"
dependencies:
safe-buffer "~5.1.0"
strip-ansi@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf"
dependencies:
ansi-regex "^2.0.0"
strip-ansi@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f"
dependencies:
ansi-regex "^3.0.0"
strip-bom@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
strip-json-comments@~2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
supports-color@5.4.0, supports-color@^5.3.0:
version "5.4.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.4.0.tgz#1c6b337402c2137605efe19f10fec390f6faab54"
dependencies:
has-flag "^3.0.0"
supports-color@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
supports-color@^3.1.0:
version "3.2.3"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6"
dependencies:
has-flag "^1.0.0"
symbol-tree@^3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6"
table@4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36"
dependencies:
ajv "^5.2.3"
ajv-keywords "^2.1.0"
chalk "^2.1.0"
lodash "^4.17.4"
slice-ansi "1.0.0"
string-width "^2.1.1"
text-table@~0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
through@^2.3.6:
version "2.3.8"
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
dependencies:
os-tmpdir "~1.0.2"
tough-cookie@>=2.3.3, tough-cookie@^2.3.3, tough-cookie@~2.3.3:
version "2.3.4"
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655"
dependencies:
punycode "^1.4.1"
tr46@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09"
dependencies:
punycode "^2.1.0"
tunnel-agent@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"
dependencies:
safe-buffer "^5.0.1"
tweetnacl@^0.14.3, tweetnacl@~0.14.0:
version "0.14.5"
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
type-check@~0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72"
dependencies:
prelude-ls "~1.1.2"
type-detect@^4.0.0:
version "4.0.8"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
ua-parser-js@^0.7.9:
version "0.7.18"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.18.tgz#a7bfd92f56edfb117083b69e31d2aa8882d4b1ed"
uglify-js@^2.6:
version "2.8.29"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd"
dependencies:
source-map "~0.5.1"
yargs "~3.10.0"
optionalDependencies:
uglify-to-browserify "~1.0.0"
uglify-to-browserify@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7"
uniq@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff"
util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
uuid@^3.1.0:
version "3.2.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14"
validate-npm-package-license@^3.0.1:
version "3.0.3"
resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz#81643bcbef1bdfecd4623793dc4648948ba98338"
dependencies:
spdx-correct "^3.0.0"
spdx-expression-parse "^3.0.0"
verror@1.10.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400"
dependencies:
assert-plus "^1.0.0"
core-util-is "1.0.2"
extsprintf "^1.2.0"
w3c-hr-time@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz#82ac2bff63d950ea9e3189a58a65625fedf19045"
dependencies:
browser-process-hrtime "^0.1.2"
webidl-conversions@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"
whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-1.0.3.tgz#57c235bc8657e914d24e1a397d3c82daee0a6ba3"
dependencies:
iconv-lite "0.4.19"
whatwg-fetch@>=0.10.0:
version "2.0.4"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f"
whatwg-mimetype@^2.0.0, whatwg-mimetype@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.1.0.tgz#f0f21d76cbba72362eb609dbed2a30cd17fcc7d4"
whatwg-url@^6.4.0, whatwg-url@^6.4.1:
version "6.4.1"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-6.4.1.tgz#fdb94b440fd4ad836202c16e9737d511f012fd67"
dependencies:
lodash.sortby "^4.7.0"
tr46 "^1.0.1"
webidl-conversions "^4.0.2"
which@^1.1.1, which@^1.2.9:
version "1.3.1"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
dependencies:
isexe "^2.0.0"
window-size@0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d"
wordwrap@0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f"
wordwrap@^1.0.0, wordwrap@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
wordwrap@~0.0.2:
version "0.0.3"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
write@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757"
dependencies:
mkdirp "^0.5.1"
ws@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-4.1.0.tgz#a979b5d7d4da68bf54efe0408967c324869a7289"
dependencies:
async-limiter "~1.0.0"
safe-buffer "~5.1.0"
xml-name-validator@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
xtend@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af"
yallist@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
yargs@~3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1"
dependencies:
camelcase "^1.0.2"
cliui "^2.1.0"
decamelize "^1.0.0"
window-size "0.1.0"
# Changes
This file is a manually maintained list of changes for each release. Feel free
to add your changes here when sending pull requests. Also send corrections if
you spot any mistakes.
## v2.18.1 (2020-01-23)
* Fix Amazon RDS profile for yaSSL MySQL servers with 2019 CA #2292
## v2.18.0 (2020-01-21)
* Add `localInfile` option to control `LOAD DATA LOCAL INFILE`
* Add new Amazon RDS Root 2019 CA to Amazon RDS SSL profile #2280
* Add new error codes up to MySQL 5.7.29
* Fix early detection of bad callback to `connection.query`
* Support Node.js 12.x #2211
* Support Node.js 13.x
* Support non-enumerable properties in object argument to `connection.query` #2253
* Update `bignumber.js` to 9.0.0
* Update `readable-stream` to 2.3.7
## v2.17.1 (2019-04-18)
* Update `bignumber.js` to 7.2.1 #2206
- Fix npm deprecation warning
## v2.17.0 (2019-04-17)
* Add reverse type lookup for small performance gain #2170
* Fix `connection.threadId` missing on handshake failure
* Fix duplicate packet name in debug output
* Fix no password support for old password protocol
* Remove special case for handshake in determine packet code
* Small performance improvement starting command sequence
* Support auth switch in change user flow #1776
* Support Node.js 11.x
* Update `bignumber.js` to 6.0.0
## v2.16.0 (2018-07-17)
* Add Amazon RDS GovCloud SSL certificates #1876
* Add new error codes up to MySQL 5.7.21
* Include connection ID in debug output
* Support Node.js 9.x
* Support Node.js 10.x #2003 #2024 #2026 #2034
* Update Amazon RDS SSL certificates
* Update `bignumber.js` to 4.1.0
* Update `readable-stream` to 2.3.6
* Update `sqlstring` to 2.3.1
- Fix incorrectly replacing non-placeholders in SQL
## v2.15.0 (2017-10-05)
* Add new Amazon RDS ca-central-1 certificate CA to Amazon RDS SSL profile #1809
* Add new error codes up to MySQL 5.7.19
* Add `mysql.raw()` to generate pre-escaped values #877 #1821
* Fix "changedRows" to work on non-English servers #1819
* Fix error when server sends RST on `QUIT` #1811
* Fix typo in insecure auth error message
* Support `mysql_native_password` auth switch request for Azure #1396 #1729 #1730
* Update `sqlstring` to 2.3.0
- Add `.toSqlString()` escape overriding
- Small performance improvement on `escapeId`
* Update `bignumber.js` to 4.0.4
## v2.14.1 (2017-08-01)
* Fix holding first closure for lifetime of connection #1785
## v2.14.0 (2017-07-25)
* Add new Amazon RDS ap-south-1 certificate CA to Amazon RDS SSL profile #1780
* Add new Amazon RDS eu-west-2 certificate CA to Amazon RDS SSL profile #1770
* Add `sql` property to query `Error` objects #1462 #1628 #1629
* Add `sqlMessage` property to `Error` objects #1714
* Fix the MySQL 5.7.17 error codes
* Support Node.js 8.x
* Update `bignumber.js` to 4.0.2
* Update `readable-stream` to 2.3.3
* Use `safe-buffer` for improved Buffer API
## v2.13.0 (2017-01-24)
* Accept regular expression as pool cluster pattern #1572
* Accept wildcard anywhere in pool cluster pattern #1570
* Add `acquire` and `release` events to `Pool` for tracking #1366 #1449 #1528 #1625
* Add new error codes up to MySQL 5.7.17
* Fix edge cases when determing Query result packets #1547
* Fix memory leak when using long-running domains #1619 #1620
* Remove unnecessary buffer copies when receiving large packets
* Update `bignumber.js` to 3.1.2
* Use a simple buffer list to improve performance #566 #1590
## v2.12.0 (2016-11-02)
* Accept array of type names to `dateStrings` option #605 #1481
* Add `query` method to `PoolNamespace` #1256 #1505 #1506
- Used as `cluster.of(...).query(...)`
* Add new error codes up to MySQL 5.7.16
* Fix edge cases writing certain length coded values
* Fix typo in `HANDSHAKE_NO_SSL_SUPPORT` error message #1534
* Support Node.js 7.x
* Update `bignumber.js` to 2.4.0
* Update `sqlstring` to 2.2.0
- Accept numbers and other value types in `escapeId`
- Escape invalid `Date` objects as `NULL`
- Run `buffer.toString()` through escaping
## v2.11.1 (2016-06-07)
* Fix writing truncated packets starting with large string/buffer #1438
## v2.11.0 (2016-06-06)
* Add `POOL_CLOSED` code to "Pool is closed." error
* Add `POOL_CONNLIMIT` code to "No connections available." error #1332
* Bind underlying connections in pool to same domain as pool #1242
* Bind underlying socket to same domain as connection #1243
* Fix allocation errors receiving many result rows #918 #1265 #1324 #1415
* Fix edge cases constructing long stack traces #1387
* Fix handshake inactivity timeout on Node.js v4.2.0 #1223 #1236 #1239 #1240 #1241 #1252
* Fix Query stream to emit close after ending #1349 #1350
* Fix type cast for BIGINT columns when number is negative #1376
* Performance improvements for array/object escaping in SqlString #1331
* Performance improvements for formatting in SqlString #1431
* Performance improvements for string escaping in SqlString #1390
* Performance improvements for writing packets to network
* Support Node.js 6.x
* Update `bignumber.js` to 2.3.0
* Update `readable-stream` to 1.1.14
* Use the `sqlstring` module for SQL escaping and formatting
## v2.10.2 (2016-01-12)
* Fix exception/hang from certain SSL connection errors #1153
* Update `bignumber.js` to 2.1.4
## v2.10.1 (2016-01-11)
* Add new Amazon RDS ap-northeast-2 certificate CA to Amazon RDS SSL profile #1329
## v2.10.0 (2015-12-15)
* Add new error codes up to MySQL 5.7.9 #1294
* Add new JSON type constant #1295
* Add types for fractional seconds support
* Fix `connection.destroy()` on pool connection creating sequences #1291
* Fix error code 139 `HA_ERR_TO_BIG_ROW` to be `HA_ERR_TOO_BIG_ROW`
* Fix error when call site error is missing stack #1179
* Fix reading password from MySQL URL that has bare colon #1278
* Handle MySQL servers not closing TCP connection after QUIT -> OK exchange #1277
* Minor SqlString Date to string performance improvement #1233
* Support Node.js 4.x
* Support Node.js 5.x
* Update `bignumber.js` to 2.1.2
## v2.9.0 (2015-08-19)
* Accept the `ciphers` property in connection `ssl` option #1185
* Fix bad timezone conversion from `Date` to string for certain times #1045 #1155
## v2.8.0 (2015-07-13)
* Add `connect` event to `Connection` #1129
* Default `timeout` for `connection.end` to 30 seconds #1057
* Fix a sync callback when sequence enqueue fails #1147
* Provide static require analysis
* Re-use connection from pool after `conn.changeUser` is used #837 #1088
## v2.7.0 (2015-05-27)
* Destroy/end connections removed from the pool on error
* Delay implied connect until after `.query` argument validation
* Do not remove connections with non-fatal errors from the pool
* Error early if `callback` argument to `.query` is not a function #1060
* Lazy-load modules from many entry point; reduced memory use
## v2.6.2 (2015-04-14)
* Fix `Connection.createQuery` for no SQL #1058
* Update `bignumber.js` to 2.0.7
## v2.6.1 (2015-03-26)
* Update `bignumber.js` to 2.0.5 #1037 #1038
## v2.6.0 (2015-03-24)
* Add `poolCluster.remove` to remove pools from the cluster #1006 #1007
* Add optional callback to `poolCluster.end`
* Add `restoreNodeTimeout` option to `PoolCluster` #880 #906
* Fix LOAD DATA INFILE handling in multiple statements #1036
* Fix `poolCluster.add` to throw if `PoolCluster` has been closed
* Fix `poolCluster.add` to throw if `id` already defined
* Fix un-catchable error from `PoolCluster` when MySQL server offline #1033
* Improve speed formatting SQL #1019
* Support io.js
## v2.5.5 (2015-02-23)
* Store SSL presets in JS instead of JSON #959
* Support Node.js 0.12
* Update Amazon RDS SSL certificates #1001
## v2.5.4 (2014-12-16)
* Fix error if falsy error thrown in callback handler #960
* Fix various error code strings #954
## v2.5.3 (2014-11-06)
* Fix `pool.query` streaming interface not emitting connection errors #941
## v2.5.2 (2014-10-10)
* Fix receiving large text fields #922
## v2.5.1 (2014-09-22)
* Fix `pool.end` race conditions #915
* Fix `pool.getConnection` race conditions
## v2.5.0 (2014-09-07)
* Add code `POOL_ENQUEUELIMIT` to error reaching `queueLimit`
* Add `enqueue` event to pool #716
* Add `enqueue` event to protocol and connection #381
* Blacklist unsupported connection flags #881
* Make only column names enumerable in `RowDataPacket` #549 #895
* Support Node.js 0.6 #718
## v2.4.3 (2014-08-25)
* Fix `pool.query` to use `typeCast` configuration
## v2.4.2 (2014-08-03)
* Fix incorrect sequence packet errors to be catchable #867
* Fix stray protocol packet errors to be catchable #867
* Fix timing of fatal protocol errors bubbling to user #879
## v2.4.1 (2014-07-17)
* Fix `pool.query` not invoking callback on connection error #872
## v2.4.0 (2014-07-13)
* Add code `POOL_NOEXIST` in PoolCluster error #846
* Add `acquireTimeout` pool option to specify a timeout for acquiring a connection #821 #854
* Add `connection.escapeId`
* Add `pool.escapeId`
* Add `timeout` option to all sequences #855 #863
* Default `connectTimeout` to 10 seconds
* Fix domain binding with `conn.connect`
* Fix `packet.default` to actually be a string
* Fix `PARSER_*` errors to be catchable
* Fix `PROTOCOL_PACKETS_OUT_OF_ORDER` error to be catchable #844
* Include packets that failed parsing under `debug`
* Return `Query` object from `pool.query` like `conn.query` #830
* Use `EventEmitter.listenerCount` when possible for faster counting
## v2.3.2 (2014-05-29)
* Fix pool leaking connections after `conn.changeUser` #833
## v2.3.1 (2014-05-26)
* Add database errors to error constants
* Add global errors to error constants
* Throw when calling `conn.release` multiple times #824 #827
* Update known error codes
## v2.3.0 (2014-05-16)
* Accept MySQL charset (like `UTF8` or `UTF8MB4`) in `charset` option #808
* Accept pool options in connection string to `mysql.createPool` #811
* Clone connection config for new pool connections
* Default `connectTimeout` to 2 minutes
* Reject unauthorized SSL connections (use `ssl.rejectUnauthorized` to override) #816
* Return last error when PoolCluster exhausts connection retries #818
* Remove connection from pool after `conn.changeUser` is released #806
* Throw on unknown SSL profile name #817
* User newer TLS functions when available #809
## v2.2.0 (2014-04-27)
* Use indexOf instead of for loops removing conn from pool #611
* Make callback to `pool.query` optional like `conn.query` #585
* Prevent enqueuing sequences after fatal error #400
* Fix geometry parser for empty fields #742
* Accept lower-case charset option
* Throw on unknown charset option #789
* Update known charsets
* Remove console.warn from PoolCluster #744
* Fix `pool.end` to handle queued connections #797
* Fix `pool.releaseConnection` to keep connection queue flowing #797
* Fix SSL handshake error to be catchable #800
* Add `connection.threadId` to get MySQL connection ID #602
* Ensure `pool.getConnection` retrieves good connections #434 #557 #778
* Fix pool cluster wildcard matching #627
* Pass query values through to `SqlString.format` #590
## v2.1.1 (2014-03-13)
* fix authentication w/password failure for node.js 0.10.5 #746 #752
* fix authentication w/password TypeError exception for node.js 0.10.0-0.10.4 #747
* fix specifying `values` in `conn.query({...}).on(...)` pattern #755
* fix long stack trace to include the `pool.query(...)` call #715
## v2.1.0 (2014-02-20)
* crypto.createHash fix for node.js < 11 #735
* Add `connectTimeout` option to specify a timeout for establishing a connection #726
* SSL support #481
## v2.0.1
* internal parser speed improvement #702
* domains support
* 'trace' connection option to control if long stack traces are generated #713 #710 #439
## v2.0.0 (2014-01-09)
* stream improvements:
- node 0.8 support #692
- Emit 'close' events from query streams #688
* encoding fix in streaming LOAD DATA LOCAL INFILE #670
* Doc improvements
## v2.0.0-rc2 (2013-12-07)
* Streaming LOAD DATA LOCAL INFILE #668
* Doc improvements
## v2.0.0-rc1 (2013-11-30)
* Transaction support
* Expose SqlString.format as mysql.format()
* Many bug fixes
* Better support for dates in local time zone
* Doc improvements
## v2.0.0-alpha9 (2013-08-27)
* Add query to pool to execute queries directly using the pool
* Add `sqlState` property to `Error` objects #556
* Pool option to set queue limit
* Pool sends 'connection' event when it opens a new connection
* Added stringifyObjects option to treat input as strings rather than objects (#501)
* Support for poolClusters
* Datetime improvements
* Bug fixes
## v2.0.0-alpha8 (2013-04-30)
* Switch to old mode for Streams 2 (Node.js v 0.10.x)
* Add stream method to Query Wraps events from the query object into a node v0.10.x Readable stream
* DECIMAL should also be treated as big number
* Removed slow unnecessary stack access
* Added charsets
* Added bigNumberStrings option for forcing BIGINT columns as strings
* Changes date parsing to return String if not a valid JS Date
* Adds support for ?? escape sequence to escape identifiers
* Changes Auth.token() to force password to be in binary, not utf8 (#378)
* Restrict debugging by packet types
* Add 'multipleStatements' option tracking to ConnectionConfig. Fixes GH-408
* Changes Pool to handle 'error' events and dispose connection
* Allows db.query({ sql: "..." }, [ val1, ... ], cb); (#390)
* Improved documentation
* Bug fixes
## v2.0.0-alpha7 (2013-02-03)
* Add connection pooling (#351)
## v2.0.0-alpha6 (2013-01-31)
* Add supportBigNumbers option (#381, #382)
* Accept prebuilt Query object in connection.query
* Bug fixes
## v2.0.0-alpha5 (2012-12-03)
* Add mysql.escapeId to escape identifiers (closes #342)
* Allow custom escaping mode (config.queryFormat)
* Convert DATE columns to configured timezone instead of UTC (#332)
* Convert LONGLONG and NEWDECIMAL to numbers (#333)
* Fix Connection.escape() (fixes #330)
* Changed Readme ambiguity about custom type cast fallback
* Change typeCast to receive Connection instead of Connection.config.timezone
* Fix drain event having useless err parameter
* Add Connection.statistics() back from v0.9
* Add Connection.ping() back from v0.9
## v2.0.0-alpha4 (2012-10-03)
* Fix some OOB errors on resume()
* Fix quick pause() / resume() usage
* Properly parse host denied / similar errors
* Add Connection.ChangeUser functionality
* Make sure changeUser errors are fatal
* Enable formatting nested arrays for bulk inserts
* Add Connection.escape functionality
* Renamed 'close' to 'end' event
* Return parsed object instead of Buffer for GEOMETRY types
* Allow nestTables inline (using a string instead of a boolean)
* Check for ZEROFILL_FLAG and format number accordingly
* Add timezone support (default: local)
* Add custom typeCast functionality
* Export mysql column types
* Add connection flags functionality (#237)
* Exports drain event when queue finishes processing (#272, #271, #306)
## v2.0.0-alpha3 (2012-06-12)
* Implement support for `LOAD DATA LOCAL INFILE` queries (#182).
* Support OLD\_PASSWORD() accounts like 0.9.x did. You should still upgrade any
user accounts in your your MySQL user table that has short (16 byte) Password
values. Connecting to those accounts is not secure. (#204)
* Ignore function values when escaping objects, allows to use RowDataPacket
objects as query arguments. (Alex Gorbatchev, #213)
* Handle initial error packets from server such as `ER_HOST_NOT_PRIVILEGED`.
* Treat `utf8\_bin` as a String, not Buffer. (#214)
* Handle empty strings in first row column value. (#222)
* Honor Connection#nestTables setting for queries. (#221)
* Remove `CLIENT_INTERACTIVE` flag from config. Improves #225.
* Improve docs for connections settings.
* Implement url string support for Connection configs.
## v2.0.0-alpha2 (2012-05-31)
* Specify escaping before for NaN / Infinity (they are as unquoted constants).
* Support for unix domain socket connections (use: {socketPath: '...'}).
* Fix type casting for NULL values for Date/Number fields
* Add `fields` argument to `query()` as well as `'fields'` event. This is
similar to what was available in 0.9.x.
* Support connecting to the sphinx searchd daemon as well as MariaDB (#199).
* Implement long stack trace support, will be removed / disabled if the node
core ever supports it natively.
* Implement `nestTables` option for queries, allows fetching JOIN result sets
with overlapping column names.
* Fix ? placeholder mechanism for values containing '?' characters (#205).
* Detect when `connect()` is called more than once on a connection and provide
the user with a good error message for it (#204).
* Switch to `UTF8_GENERAL_CI` (previously `UTF8_UNICODE_CI`) as the default
charset for all connections to avoid strange MySQL performance issues (#200),
and also make the charset user configurable.
* Fix BLOB type casting for `TINY_BLOB`, `MEDIUM_BLOB` and `LONG_BLOB`.
* Add support for sending and receiving large (> 16 MB) packets.
## v2.0.0-alpha (2012-05-15)
This release is a rewrite. You should carefully test your application after
upgrading to avoid problems. This release features many improvements, most
importantly:
* ~5x faster than v0.9.x for parsing query results
* Support for pause() / resume() (for streaming rows)
* Support for multiple statement queries
* Support for stored procedures
* Support for transactions
* Support for binary columns (as blobs)
* Consistent & well documented error handling
* A new Connection class that has well defined semantics (unlike the old Client class).
* Convenient escaping of objects / arrays that allows for simpler query construction
* A significantly simpler code base
* Many bug fixes & other small improvements (Closed 62 out of 66 GitHub issues)
Below are a few notes on the upgrade process itself:
The first thing you will run into is that the old `Client` class is gone and
has been replaced with a less ambitious `Connection` class. So instead of
`mysql.createClient()`, you now have to:
```js
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'me',
password : 'secret',
});
connection.query('SELECT 1', function(err, rows) {
if (err) throw err;
console.log('Query result: ', rows);
});
connection.end();
```
The new `Connection` class does not try to handle re-connects, please study the
`Server disconnects` section in the new Readme.
Other than that, the interface has stayed very similar. Here are a few things
to check out so:
* BIGINT's are now cast into strings
* Binary data is now cast to buffers
* The `'row'` event on the `Query` object is now called `'result'` and will
also be emitted for queries that produce an OK/Error response.
* Error handling is consistently defined now, check the Readme
* Escaping has become more powerful which may break your code if you are
currently using objects to fill query placeholders.
* Connections can now be established explicitly again, so you may wish to do so
if you want to handle connection errors specifically.
That should be most of it, if you run into anything else, please send a patch
or open an issue to improve this document.
## v0.9.6 (2012-03-12)
* Escape array values so they produce sql arrays (Roger Castells, Colin Smith)
* docs: mention mysql transaction stop gap solution (Blake Miner)
* docs: Mention affectedRows in FAQ (Michael Baldwin)
## v0.9.5 (2011-11-26)
* Fix #142 Driver stalls upon reconnect attempt that's immediately closed
* Add travis build
* Switch to urun as a test runner
* Switch to utest for unit tests
* Remove fast-or-slow dependency for tests
* Split integration tests into individual files again
## v0.9.4 (2011-08-31)
* Expose package.json as `mysql.PACKAGE` (#104)
## v0.9.3 (2011-08-22)
* Set default `client.user` to root
* Fix #91: Client#format should not mutate params array
* Fix #94: TypeError in client.js
* Parse decimals as string (vadimg)
## v0.9.2 (2011-08-07)
* The underlaying socket connection is now managed implicitly rather than explicitly.
* Check the [upgrading guide][] for a full list of changes.
## v0.9.1 (2011-02-20)
* Fix issue #49 / `client.escape()` throwing exceptions on objects. (Nick Payne)
* Drop < v0.4.x compatibility. From now on you need node v0.4.x to use this module.
## Older releases
These releases were done before maintaining this file:
* [v0.9.0](https://github.com/mysqljs/mysql/compare/v0.8.0...v0.9.0)
(2011-01-04)
* [v0.8.0](https://github.com/mysqljs/mysql/compare/v0.7.0...v0.8.0)
(2010-10-30)
* [v0.7.0](https://github.com/mysqljs/mysql/compare/v0.6.0...v0.7.0)
(2010-10-14)
* [v0.6.0](https://github.com/mysqljs/mysql/compare/v0.5.0...v0.6.0)
(2010-09-28)
* [v0.5.0](https://github.com/mysqljs/mysql/compare/v0.4.0...v0.5.0)
(2010-09-17)
* [v0.4.0](https://github.com/mysqljs/mysql/compare/v0.3.0...v0.4.0)
(2010-09-02)
* [v0.3.0](https://github.com/mysqljs/mysql/compare/v0.2.0...v0.3.0)
(2010-08-25)
* [v0.2.0](https://github.com/mysqljs/mysql/compare/v0.1.0...v0.2.0)
(2010-08-22)
* [v0.1.0](https://github.com/mysqljs/mysql/commits/v0.1.0)
(2010-08-22)
Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# mysql
[![NPM Version][npm-version-image]][npm-url]
[![NPM Downloads][npm-downloads-image]][npm-url]
[![Node.js Version][node-image]][node-url]
[![Linux Build][travis-image]][travis-url]
[![Windows Build][appveyor-image]][appveyor-url]
[![Test Coverage][coveralls-image]][coveralls-url]
## Table of Contents
- [Install](#install)
- [Introduction](#introduction)
- [Contributors](#contributors)
- [Sponsors](#sponsors)
- [Community](#community)
- [Establishing connections](#establishing-connections)
- [Connection options](#connection-options)
- [SSL options](#ssl-options)
- [Connection flags](#connection-flags)
- [Terminating connections](#terminating-connections)
- [Pooling connections](#pooling-connections)
- [Pool options](#pool-options)
- [Pool events](#pool-events)
- [acquire](#acquire)
- [connection](#connection)
- [enqueue](#enqueue)
- [release](#release)
- [Closing all the connections in a pool](#closing-all-the-connections-in-a-pool)
- [PoolCluster](#poolcluster)
- [PoolCluster options](#poolcluster-options)
- [Switching users and altering connection state](#switching-users-and-altering-connection-state)
- [Server disconnects](#server-disconnects)
- [Performing queries](#performing-queries)
- [Escaping query values](#escaping-query-values)
- [Escaping query identifiers](#escaping-query-identifiers)
- [Preparing Queries](#preparing-queries)
- [Custom format](#custom-format)
- [Getting the id of an inserted row](#getting-the-id-of-an-inserted-row)
- [Getting the number of affected rows](#getting-the-number-of-affected-rows)
- [Getting the number of changed rows](#getting-the-number-of-changed-rows)
- [Getting the connection ID](#getting-the-connection-id)
- [Executing queries in parallel](#executing-queries-in-parallel)
- [Streaming query rows](#streaming-query-rows)
- [Piping results with Streams](#piping-results-with-streams)
- [Multiple statement queries](#multiple-statement-queries)
- [Stored procedures](#stored-procedures)
- [Joins with overlapping column names](#joins-with-overlapping-column-names)
- [Transactions](#transactions)
- [Ping](#ping)
- [Timeouts](#timeouts)
- [Error handling](#error-handling)
- [Exception Safety](#exception-safety)
- [Type casting](#type-casting)
- [Number](#number)
- [Date](#date)
- [Buffer](#buffer)
- [String](#string)
- [Custom type casting](#custom-type-casting)
- [Debugging and reporting problems](#debugging-and-reporting-problems)
- [Security issues](#security-issues)
- [Contributing](#contributing)
- [Running tests](#running-tests)
- [Running unit tests](#running-unit-tests)
- [Running integration tests](#running-integration-tests)
- [Todo](#todo)
## Install
This is a [Node.js](https://nodejs.org/en/) module available through the
[npm registry](https://www.npmjs.com/).
Before installing, [download and install Node.js](https://nodejs.org/en/download/).
Node.js 0.6 or higher is required.
Installation is done using the
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
```sh
$ npm install mysql
```
For information about the previous 0.9.x releases, visit the [v0.9 branch][].
Sometimes I may also ask you to install the latest version from Github to check
if a bugfix is working. In this case, please do:
```sh
$ npm install mysqljs/mysql
```
[v0.9 branch]: https://github.com/mysqljs/mysql/tree/v0.9
## Introduction
This is a node.js driver for mysql. It is written in JavaScript, does not
require compiling, and is 100% MIT licensed.
Here is an example on how to use it:
```js
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'me',
password : 'secret',
database : 'my_db'
});
connection.connect();
connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
if (error) throw error;
console.log('The solution is: ', results[0].solution);
});
connection.end();
```
From this example, you can learn the following:
* Every method you invoke on a connection is queued and executed in sequence.
* Closing the connection is done using `end()` which makes sure all remaining
queries are executed before sending a quit packet to the mysql server.
## Contributors
Thanks goes to the people who have contributed code to this module, see the
[GitHub Contributors page][].
[GitHub Contributors page]: https://github.com/mysqljs/mysql/graphs/contributors
Additionally I'd like to thank the following people:
* [Andrey Hristov][] (Oracle) - for helping me with protocol questions.
* [Ulf Wendel][] (Oracle) - for helping me with protocol questions.
[Ulf Wendel]: http://blog.ulf-wendel.de/
[Andrey Hristov]: http://andrey.hristov.com/
## Sponsors
The following companies have supported this project financially, allowing me to
spend more time on it (ordered by time of contribution):
* [Transloadit](http://transloadit.com) (my startup, we do file uploading &
video encoding as a service, check it out)
* [Joyent](http://www.joyent.com/)
* [pinkbike.com](http://pinkbike.com/)
* [Holiday Extras](http://www.holidayextras.co.uk/) (they are [hiring](http://join.holidayextras.co.uk/))
* [Newscope](http://newscope.com/) (they are [hiring](https://newscope.com/unternehmen/jobs/))
## Community
If you'd like to discuss this module, or ask questions about it, please use one
of the following:
* **Mailing list**: https://groups.google.com/forum/#!forum/node-mysql
* **IRC Channel**: #node.js (on freenode.net, I pay attention to any message
including the term `mysql`)
## Establishing connections
The recommended way to establish a connection is this:
```js
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'example.org',
user : 'bob',
password : 'secret'
});
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
});
```
However, a connection can also be implicitly established by invoking a query:
```js
var mysql = require('mysql');
var connection = mysql.createConnection(...);
connection.query('SELECT 1', function (error, results, fields) {
if (error) throw error;
// connected!
});
```
Depending on how you like to handle your errors, either method may be
appropriate. Any type of connection error (handshake or network) is considered
a fatal error, see the [Error Handling](#error-handling) section for more
information.
## Connection options
When establishing a connection, you can set the following options:
* `host`: The hostname of the database you are connecting to. (Default:
`localhost`)
* `port`: The port number to connect to. (Default: `3306`)
* `localAddress`: The source IP address to use for TCP connection. (Optional)
* `socketPath`: The path to a unix domain socket to connect to. When used `host`
and `port` are ignored.
* `user`: The MySQL user to authenticate as.
* `password`: The password of that MySQL user.
* `database`: Name of the database to use for this connection (Optional).
* `charset`: The charset for the connection. This is called "collation" in the SQL-level
of MySQL (like `utf8_general_ci`). If a SQL-level charset is specified (like `utf8mb4`)
then the default collation for that charset is used. (Default: `'UTF8_GENERAL_CI'`)
* `timezone`: The timezone configured on the MySQL server. This is used to type cast server date/time values to JavaScript `Date` object and vice versa. This can be `'local'`, `'Z'`, or an offset in the form `+HH:MM` or `-HH:MM`. (Default: `'local'`)
* `connectTimeout`: The milliseconds before a timeout occurs during the initial connection
to the MySQL server. (Default: `10000`)
* `stringifyObjects`: Stringify objects instead of converting to values. See
issue [#501](https://github.com/mysqljs/mysql/issues/501). (Default: `false`)
* `insecureAuth`: Allow connecting to MySQL instances that ask for the old
(insecure) authentication method. (Default: `false`)
* `typeCast`: Determines if column values should be converted to native
JavaScript types. (Default: `true`)
* `queryFormat`: A custom query format function. See [Custom format](#custom-format).
* `supportBigNumbers`: When dealing with big numbers (BIGINT and DECIMAL columns) in the database,
you should enable this option (Default: `false`).
* `bigNumberStrings`: Enabling both `supportBigNumbers` and `bigNumberStrings` forces big numbers
(BIGINT and DECIMAL columns) to be always returned as JavaScript String objects (Default: `false`).
Enabling `supportBigNumbers` but leaving `bigNumberStrings` disabled will return big numbers as String
objects only when they cannot be accurately represented with [JavaScript Number objects] (http://ecma262-5.com/ELS5_HTML.htm#Section_8.5)
(which happens when they exceed the [-2^53, +2^53] range), otherwise they will be returned as
Number objects. This option is ignored if `supportBigNumbers` is disabled.
* `dateStrings`: Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather than
inflated into JavaScript Date objects. Can be `true`/`false` or an array of type names to keep as
strings. (Default: `false`)
* `debug`: Prints protocol details to stdout. Can be `true`/`false` or an array of packet type names
that should be printed. (Default: `false`)
* `trace`: Generates stack traces on `Error` to include call site of library
entrance ("long stack traces"). Slight performance penalty for most calls.
(Default: `true`)
* `localInfile`: Allow `LOAD DATA INFILE` to use the `LOCAL` modifier. (Default: `true`)
* `multipleStatements`: Allow multiple mysql statements per query. Be careful
with this, it could increase the scope of SQL injection attacks. (Default: `false`)
* `flags`: List of connection flags to use other than the default ones. It is
also possible to blacklist default ones. For more information, check
[Connection Flags](#connection-flags).
* `ssl`: object with ssl parameters or a string containing name of ssl profile. See [SSL options](#ssl-options).
In addition to passing these options as an object, you can also use a url
string. For example:
```js
var connection = mysql.createConnection('mysql://user:pass@host/db?debug=true&charset=BIG5_CHINESE_CI&timezone=-0700');
```
Note: The query values are first attempted to be parsed as JSON, and if that
fails assumed to be plaintext strings.
### SSL options
The `ssl` option in the connection options takes a string or an object. When given a string,
it uses one of the predefined SSL profiles included. The following profiles are included:
* `"Amazon RDS"`: this profile is for connecting to an Amazon RDS server and contains the
certificates from https://rds.amazonaws.com/doc/rds-ssl-ca-cert.pem and
https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
When connecting to other servers, you will need to provide an object of options, in the
same format as [tls.createSecureContext](https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options).
Please note the arguments expect a string of the certificate, not a file name to the
certificate. Here is a simple example:
```js
var connection = mysql.createConnection({
host : 'localhost',
ssl : {
ca : fs.readFileSync(__dirname + '/mysql-ca.crt')
}
});
```
You can also connect to a MySQL server without properly providing the appropriate
CA to trust. _You should not do this_.
```js
var connection = mysql.createConnection({
host : 'localhost',
ssl : {
// DO NOT DO THIS
// set up your ca correctly to trust the connection
rejectUnauthorized: false
}
});
```
### Connection flags
If, for any reason, you would like to change the default connection flags, you
can use the connection option `flags`. Pass a string with a comma separated list
of items to add to the default flags. If you don't want a default flag to be used
prepend the flag with a minus sign. To add a flag that is not in the default list,
just write the flag name, or prefix it with a plus (case insensitive).
```js
var connection = mysql.createConnection({
// disable FOUND_ROWS flag, enable IGNORE_SPACE flag
flags: '-FOUND_ROWS,IGNORE_SPACE'
});
```
The following flags are available:
- `COMPRESS` - Enable protocol compression. This feature is not currently supported
by the Node.js implementation so cannot be turned on. (Default off)
- `CONNECT_WITH_DB` - Ability to specify the database on connection. (Default on)
- `FOUND_ROWS` - Send the found rows instead of the affected rows as `affectedRows`.
(Default on)
- `IGNORE_SIGPIPE` - Don't issue SIGPIPE if network failures. This flag has no effect
on this Node.js implementation. (Default on)
- `IGNORE_SPACE` - Let the parser ignore spaces before the `(` in queries. (Default on)
- `INTERACTIVE` - Indicates to the MySQL server this is an "interactive" client. This
will use the interactive timeouts on the MySQL server and report as interactive in
the process list. (Default off)
- `LOCAL_FILES` - Can use `LOAD DATA LOCAL`. This flag is controlled by the connection
option `localInfile`. (Default on)
- `LONG_FLAG` - Longer flags in Protocol::ColumnDefinition320. (Default on)
- `LONG_PASSWORD` - Use the improved version of Old Password Authentication.
(Default on)
- `MULTI_RESULTS` - Can handle multiple resultsets for queries. (Default on)
- `MULTI_STATEMENTS` - The client may send multiple statement per query or
statement prepare (separated by `;`). This flag is controlled by the connection
option `multipleStatements`. (Default off)
- `NO_SCHEMA`
- `ODBC` Special handling of ODBC behaviour. This flag has no effect on this Node.js
implementation. (Default on)
- `PLUGIN_AUTH` - Uses the plugin authentication mechanism when connecting to the
MySQL server. This feature is not currently supported by the Node.js implementation
so cannot be turned on. (Default off)
- `PROTOCOL_41` - Uses the 4.1 protocol. (Default on)
- `PS_MULTI_RESULTS` - Can handle multiple resultsets for execute. (Default on)
- `REMEMBER_OPTIONS` - This is specific to the C client, and has no effect on this
Node.js implementation. (Default off)
- `RESERVED` - Old flag for the 4.1 protocol. (Default on)
- `SECURE_CONNECTION` - Support native 4.1 authentication. (Default on)
- `SSL` - Use SSL after handshake to encrypt data in transport. This feature is
controlled though the `ssl` connection option, so the flag has no effect.
(Default off)
- `SSL_VERIFY_SERVER_CERT` - Verify the server certificate during SSL set up. This
feature is controlled though the `ssl.rejectUnauthorized` connection option, so
the flag has no effect. (Default off)
- `TRANSACTIONS` - Asks for the transaction status flags. (Default on)
## Terminating connections
There are two ways to end a connection. Terminating a connection gracefully is
done by calling the `end()` method:
```js
connection.end(function(err) {
// The connection is terminated now
});
```
This will make sure all previously enqueued queries are still before sending a
`COM_QUIT` packet to the MySQL server. If a fatal error occurs before the
`COM_QUIT` packet can be sent, an `err` argument will be provided to the
callback, but the connection will be terminated regardless of that.
An alternative way to end the connection is to call the `destroy()` method.
This will cause an immediate termination of the underlying socket.
Additionally `destroy()` guarantees that no more events or callbacks will be
triggered for the connection.
```js
connection.destroy();
```
Unlike `end()` the `destroy()` method does not take a callback argument.
## Pooling connections
Rather than creating and managing connections one-by-one, this module also
provides built-in connection pooling using `mysql.createPool(config)`.
[Read more about connection pooling](https://en.wikipedia.org/wiki/Connection_pool).
Create a pool and use it directly:
```js
var mysql = require('mysql');
var pool = mysql.createPool({
connectionLimit : 10,
host : 'example.org',
user : 'bob',
password : 'secret',
database : 'my_db'
});
pool.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
if (error) throw error;
console.log('The solution is: ', results[0].solution);
});
```
This is a shortcut for the `pool.getConnection()` -> `connection.query()` ->
`connection.release()` code flow. Using `pool.getConnection()` is useful to
share connection state for subsequent queries. This is because two calls to
`pool.query()` may use two different connections and run in parallel. This is
the basic structure:
```js
var mysql = require('mysql');
var pool = mysql.createPool(...);
pool.getConnection(function(err, connection) {
if (err) throw err; // not connected!
// Use the connection
connection.query('SELECT something FROM sometable', function (error, results, fields) {
// When done with the connection, release it.
connection.release();
// Handle error after the release.
if (error) throw error;
// Don't use the connection here, it has been returned to the pool.
});
});
```
If you would like to close the connection and remove it from the pool, use
`connection.destroy()` instead. The pool will create a new connection the next
time one is needed.
Connections are lazily created by the pool. If you configure the pool to allow
up to 100 connections, but only ever use 5 simultaneously, only 5 connections
will be made. Connections are also cycled round-robin style, with connections
being taken from the top of the pool and returning to the bottom.
When a previous connection is retrieved from the pool, a ping packet is sent
to the server to check if the connection is still good.
## Pool options
Pools accept all the same [options as a connection](#connection-options).
When creating a new connection, the options are simply passed to the connection
constructor. In addition to those options pools accept a few extras:
* `acquireTimeout`: The milliseconds before a timeout occurs during the connection
acquisition. This is slightly different from `connectTimeout`, because acquiring
a pool connection does not always involve making a connection. If a connection
request is queued, the time the request spends in the queue does not count
towards this timeout. (Default: `10000`)
* `waitForConnections`: Determines the pool's action when no connections are
available and the limit has been reached. If `true`, the pool will queue the
connection request and call it when one becomes available. If `false`, the
pool will immediately call back with an error. (Default: `true`)
* `connectionLimit`: The maximum number of connections to create at once.
(Default: `10`)
* `queueLimit`: The maximum number of connection requests the pool will queue
before returning an error from `getConnection`. If set to `0`, there is no
limit to the number of queued connection requests. (Default: `0`)
## Pool events
### acquire
The pool will emit an `acquire` event when a connection is acquired from the pool.
This is called after all acquiring activity has been performed on the connection,
right before the connection is handed to the callback of the acquiring code.
```js
pool.on('acquire', function (connection) {
console.log('Connection %d acquired', connection.threadId);
});
```
### connection
The pool will emit a `connection` event when a new connection is made within the pool.
If you need to set session variables on the connection before it gets used, you can
listen to the `connection` event.
```js
pool.on('connection', function (connection) {
connection.query('SET SESSION auto_increment_increment=1')
});
```
### enqueue
The pool will emit an `enqueue` event when a callback has been queued to wait for
an available connection.
```js
pool.on('enqueue', function () {
console.log('Waiting for available connection slot');
});
```
### release
The pool will emit a `release` event when a connection is released back to the
pool. This is called after all release activity has been performed on the connection,
so the connection will be listed as free at the time of the event.
```js
pool.on('release', function (connection) {
console.log('Connection %d released', connection.threadId);
});
```
## Closing all the connections in a pool
When you are done using the pool, you have to end all the connections or the
Node.js event loop will stay active until the connections are closed by the
MySQL server. This is typically done if the pool is used in a script or when
trying to gracefully shutdown a server. To end all the connections in the
pool, use the `end` method on the pool:
```js
pool.end(function (err) {
// all connections in the pool have ended
});
```
The `end` method takes an _optional_ callback that you can use to know when
all the connections are ended.
**Once `pool.end` is called, `pool.getConnection` and other operations
can no longer be performed.** Wait until all connections in the pool are
released before calling `pool.end`. If you use the shortcut method
`pool.query`, in place of `pool.getConnection``connection.query`
`connection.release`, wait until it completes.
`pool.end` calls `connection.end` on every active connection in the pool.
This queues a `QUIT` packet on the connection and sets a flag to prevent
`pool.getConnection` from creating new connections. All commands / queries
already in progress will complete, but new commands won't execute.
## PoolCluster
PoolCluster provides multiple hosts connection. (group & retry & selector)
```js
// create
var poolCluster = mysql.createPoolCluster();
// add configurations (the config is a pool config object)
poolCluster.add(config); // add configuration with automatic name
poolCluster.add('MASTER', masterConfig); // add a named configuration
poolCluster.add('SLAVE1', slave1Config);
poolCluster.add('SLAVE2', slave2Config);
// remove configurations
poolCluster.remove('SLAVE2'); // By nodeId
poolCluster.remove('SLAVE*'); // By target group : SLAVE1-2
// Target Group : ALL(anonymous, MASTER, SLAVE1-2), Selector : round-robin(default)
poolCluster.getConnection(function (err, connection) {});
// Target Group : MASTER, Selector : round-robin
poolCluster.getConnection('MASTER', function (err, connection) {});
// Target Group : SLAVE1-2, Selector : order
// If can't connect to SLAVE1, return SLAVE2. (remove SLAVE1 in the cluster)
poolCluster.on('remove', function (nodeId) {
console.log('REMOVED NODE : ' + nodeId); // nodeId = SLAVE1
});
// A pattern can be passed with * as wildcard
poolCluster.getConnection('SLAVE*', 'ORDER', function (err, connection) {});
// The pattern can also be a regular expression
poolCluster.getConnection(/^SLAVE[12]$/, function (err, connection) {});
// of namespace : of(pattern, selector)
poolCluster.of('*').getConnection(function (err, connection) {});
var pool = poolCluster.of('SLAVE*', 'RANDOM');
pool.getConnection(function (err, connection) {});
pool.getConnection(function (err, connection) {});
pool.query(function (error, results, fields) {});
// close all connections
poolCluster.end(function (err) {
// all connections in the pool cluster have ended
});
```
### PoolCluster options
* `canRetry`: If `true`, `PoolCluster` will attempt to reconnect when connection fails. (Default: `true`)
* `removeNodeErrorCount`: If connection fails, node's `errorCount` increases.
When `errorCount` is greater than `removeNodeErrorCount`, remove a node in the `PoolCluster`. (Default: `5`)
* `restoreNodeTimeout`: If connection fails, specifies the number of milliseconds
before another connection attempt will be made. If set to `0`, then node will be
removed instead and never re-used. (Default: `0`)
* `defaultSelector`: The default selector. (Default: `RR`)
* `RR`: Select one alternately. (Round-Robin)
* `RANDOM`: Select the node by random function.
* `ORDER`: Select the first node available unconditionally.
```js
var clusterConfig = {
removeNodeErrorCount: 1, // Remove the node immediately when connection fails.
defaultSelector: 'ORDER'
};
var poolCluster = mysql.createPoolCluster(clusterConfig);
```
## Switching users and altering connection state
MySQL offers a changeUser command that allows you to alter the current user and
other aspects of the connection without shutting down the underlying socket:
```js
connection.changeUser({user : 'john'}, function(err) {
if (err) throw err;
});
```
The available options for this feature are:
* `user`: The name of the new user (defaults to the previous one).
* `password`: The password of the new user (defaults to the previous one).
* `charset`: The new charset (defaults to the previous one).
* `database`: The new database (defaults to the previous one).
A sometimes useful side effect of this functionality is that this function also
resets any connection state (variables, transactions, etc.).
Errors encountered during this operation are treated as fatal connection errors
by this module.
## Server disconnects
You may lose the connection to a MySQL server due to network problems, the
server timing you out, the server being restarted, or crashing. All of these
events are considered fatal errors, and will have the `err.code =
'PROTOCOL_CONNECTION_LOST'`. See the [Error Handling](#error-handling) section
for more information.
Re-connecting a connection is done by establishing a new connection. Once
terminated, an existing connection object cannot be re-connected by design.
With Pool, disconnected connections will be removed from the pool freeing up
space for a new connection to be created on the next getConnection call.
With PoolCluster, disconnected connections will count as errors against the
related node, incrementing the error code for that node. Once there are more than
`removeNodeErrorCount` errors on a given node, it is removed from the cluster.
When this occurs, the PoolCluster may emit a `POOL_NONEONLINE` error if there are
no longer any matching nodes for the pattern. The `restoreNodeTimeout` config can
be set to restore offline nodes after a given timeout.
## Performing queries
The most basic way to perform a query is to call the `.query()` method on an object
(like a `Connection`, `Pool`, or `PoolNamespace` instance).
The simplest form of .`query()` is `.query(sqlString, callback)`, where a SQL string
is the first argument and the second is a callback:
```js
connection.query('SELECT * FROM `books` WHERE `author` = "David"', function (error, results, fields) {
// error will be an Error if one occurred during the query
// results will contain the results of the query
// fields will contain information about the returned results fields (if any)
});
```
The second form `.query(sqlString, values, callback)` comes when using
placeholder values (see [escaping query values](#escaping-query-values)):
```js
connection.query('SELECT * FROM `books` WHERE `author` = ?', ['David'], function (error, results, fields) {
// error will be an Error if one occurred during the query
// results will contain the results of the query
// fields will contain information about the returned results fields (if any)
});
```
The third form `.query(options, callback)` comes when using various advanced
options on the query, like [escaping query values](#escaping-query-values),
[joins with overlapping column names](#joins-with-overlapping-column-names),
[timeouts](#timeout), and [type casting](#type-casting).
```js
connection.query({
sql: 'SELECT * FROM `books` WHERE `author` = ?',
timeout: 40000, // 40s
values: ['David']
}, function (error, results, fields) {
// error will be an Error if one occurred during the query
// results will contain the results of the query
// fields will contain information about the returned results fields (if any)
});
```
Note that a combination of the second and third forms can be used where the
placeholder values are passed as an argument and not in the options object.
The `values` argument will override the `values` in the option object.
```js
connection.query({
sql: 'SELECT * FROM `books` WHERE `author` = ?',
timeout: 40000, // 40s
},
['David'],
function (error, results, fields) {
// error will be an Error if one occurred during the query
// results will contain the results of the query
// fields will contain information about the returned results fields (if any)
}
);
```
If the query only has a single replacement character (`?`), and the value is
not `null`, `undefined`, or an array, it can be passed directly as the second
argument to `.query`:
```js
connection.query(
'SELECT * FROM `books` WHERE `author` = ?',
'David',
function (error, results, fields) {
// error will be an Error if one occurred during the query
// results will contain the results of the query
// fields will contain information about the returned results fields (if any)
}
);
```
## Escaping query values
**Caution** These methods of escaping values only works when the
[NO_BACKSLASH_ESCAPES](https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_no_backslash_escapes)
SQL mode is disabled (which is the default state for MySQL servers).
In order to avoid SQL Injection attacks, you should always escape any user
provided data before using it inside a SQL query. You can do so using the
`mysql.escape()`, `connection.escape()` or `pool.escape()` methods:
```js
var userId = 'some user provided value';
var sql = 'SELECT * FROM users WHERE id = ' + connection.escape(userId);
connection.query(sql, function (error, results, fields) {
if (error) throw error;
// ...
});
```
Alternatively, you can use `?` characters as placeholders for values you would
like to have escaped like this:
```js
connection.query('SELECT * FROM users WHERE id = ?', [userId], function (error, results, fields) {
if (error) throw error;
// ...
});
```
Multiple placeholders are mapped to values in the same order as passed. For example,
in the following query `foo` equals `a`, `bar` equals `b`, `baz` equals `c`, and
`id` will be `userId`:
```js
connection.query('UPDATE users SET foo = ?, bar = ?, baz = ? WHERE id = ?', ['a', 'b', 'c', userId], function (error, results, fields) {
if (error) throw error;
// ...
});
```
This looks similar to prepared statements in MySQL, however it really just uses
the same `connection.escape()` method internally.
**Caution** This also differs from prepared statements in that all `?` are
replaced, even those contained in comments and strings.
Different value types are escaped differently, here is how:
* Numbers are left untouched
* Booleans are converted to `true` / `false`
* Date objects are converted to `'YYYY-mm-dd HH:ii:ss'` strings
* Buffers are converted to hex strings, e.g. `X'0fa5'`
* Strings are safely escaped
* Arrays are turned into list, e.g. `['a', 'b']` turns into `'a', 'b'`
* Nested arrays are turned into grouped lists (for bulk inserts), e.g. `[['a',
'b'], ['c', 'd']]` turns into `('a', 'b'), ('c', 'd')`
* Objects that have a `toSqlString` method will have `.toSqlString()` called
and the returned value is used as the raw SQL.
* Objects are turned into `key = 'val'` pairs for each enumerable property on
the object. If the property's value is a function, it is skipped; if the
property's value is an object, toString() is called on it and the returned
value is used.
* `undefined` / `null` are converted to `NULL`
* `NaN` / `Infinity` are left as-is. MySQL does not support these, and trying
to insert them as values will trigger MySQL errors until they implement
support.
This escaping allows you to do neat things like this:
```js
var post = {id: 1, title: 'Hello MySQL'};
var query = connection.query('INSERT INTO posts SET ?', post, function (error, results, fields) {
if (error) throw error;
// Neat!
});
console.log(query.sql); // INSERT INTO posts SET `id` = 1, `title` = 'Hello MySQL'
```
And the `toSqlString` method allows you to form complex queries with functions:
```js
var CURRENT_TIMESTAMP = { toSqlString: function() { return 'CURRENT_TIMESTAMP()'; } };
var sql = mysql.format('UPDATE posts SET modified = ? WHERE id = ?', [CURRENT_TIMESTAMP, 42]);
console.log(sql); // UPDATE posts SET modified = CURRENT_TIMESTAMP() WHERE id = 42
```
To generate objects with a `toSqlString` method, the `mysql.raw()` method can
be used. This creates an object that will be left un-touched when using in a `?`
placeholder, useful for using functions as dynamic values:
**Caution** The string provided to `mysql.raw()` will skip all escaping
functions when used, so be careful when passing in unvalidated input.
```js
var CURRENT_TIMESTAMP = mysql.raw('CURRENT_TIMESTAMP()');
var sql = mysql.format('UPDATE posts SET modified = ? WHERE id = ?', [CURRENT_TIMESTAMP, 42]);
console.log(sql); // UPDATE posts SET modified = CURRENT_TIMESTAMP() WHERE id = 42
```
If you feel the need to escape queries by yourself, you can also use the escaping
function directly:
```js
var query = "SELECT * FROM posts WHERE title=" + mysql.escape("Hello MySQL");
console.log(query); // SELECT * FROM posts WHERE title='Hello MySQL'
```
## Escaping query identifiers
If you can't trust an SQL identifier (database / table / column name) because it is
provided by a user, you should escape it with `mysql.escapeId(identifier)`,
`connection.escapeId(identifier)` or `pool.escapeId(identifier)` like this:
```js
var sorter = 'date';
var sql = 'SELECT * FROM posts ORDER BY ' + connection.escapeId(sorter);
connection.query(sql, function (error, results, fields) {
if (error) throw error;
// ...
});
```
It also supports adding qualified identifiers. It will escape both parts.
```js
var sorter = 'date';
var sql = 'SELECT * FROM posts ORDER BY ' + connection.escapeId('posts.' + sorter);
// -> SELECT * FROM posts ORDER BY `posts`.`date`
```
If you do not want to treat `.` as qualified identifiers, you can set the second
argument to `true` in order to keep the string as a literal identifier:
```js
var sorter = 'date.2';
var sql = 'SELECT * FROM posts ORDER BY ' + connection.escapeId(sorter, true);
// -> SELECT * FROM posts ORDER BY `date.2`
```
Alternatively, you can use `??` characters as placeholders for identifiers you would
like to have escaped like this:
```js
var userId = 1;
var columns = ['username', 'email'];
var query = connection.query('SELECT ?? FROM ?? WHERE id = ?', [columns, 'users', userId], function (error, results, fields) {
if (error) throw error;
// ...
});
console.log(query.sql); // SELECT `username`, `email` FROM `users` WHERE id = 1
```
**Please note that this last character sequence is experimental and syntax might change**
When you pass an Object to `.escape()` or `.query()`, `.escapeId()` is used to avoid SQL injection in object keys.
### Preparing Queries
You can use mysql.format to prepare a query with multiple insertion points, utilizing the proper escaping for ids and values. A simple example of this follows:
```js
var sql = "SELECT * FROM ?? WHERE ?? = ?";
var inserts = ['users', 'id', userId];
sql = mysql.format(sql, inserts);
```
Following this you then have a valid, escaped query that you can then send to the database safely. This is useful if you are looking to prepare the query before actually sending it to the database. As mysql.format is exposed from SqlString.format you also have the option (but are not required) to pass in stringifyObject and timezone, allowing you provide a custom means of turning objects into strings, as well as a location-specific/timezone-aware Date.
### Custom format
If you prefer to have another type of query escape format, there's a connection configuration option you can use to define a custom format function. You can access the connection object if you want to use the built-in `.escape()` or any other connection function.
Here's an example of how to implement another format:
```js
connection.config.queryFormat = function (query, values) {
if (!values) return query;
return query.replace(/\:(\w+)/g, function (txt, key) {
if (values.hasOwnProperty(key)) {
return this.escape(values[key]);
}
return txt;
}.bind(this));
};
connection.query("UPDATE posts SET title = :title", { title: "Hello MySQL" });
```
## Getting the id of an inserted row
If you are inserting a row into a table with an auto increment primary key, you
can retrieve the insert id like this:
```js
connection.query('INSERT INTO posts SET ?', {title: 'test'}, function (error, results, fields) {
if (error) throw error;
console.log(results.insertId);
});
```
When dealing with big numbers (above JavaScript Number precision limit), you should
consider enabling `supportBigNumbers` option to be able to read the insert id as a
string, otherwise it will throw an error.
This option is also required when fetching big numbers from the database, otherwise
you will get values rounded to hundreds or thousands due to the precision limit.
## Getting the number of affected rows
You can get the number of affected rows from an insert, update or delete statement.
```js
connection.query('DELETE FROM posts WHERE title = "wrong"', function (error, results, fields) {
if (error) throw error;
console.log('deleted ' + results.affectedRows + ' rows');
})
```
## Getting the number of changed rows
You can get the number of changed rows from an update statement.
"changedRows" differs from "affectedRows" in that it does not count updated rows
whose values were not changed.
```js
connection.query('UPDATE posts SET ...', function (error, results, fields) {
if (error) throw error;
console.log('changed ' + results.changedRows + ' rows');
})
```
## Getting the connection ID
You can get the MySQL connection ID ("thread ID") of a given connection using the `threadId`
property.
```js
connection.connect(function(err) {
if (err) throw err;
console.log('connected as id ' + connection.threadId);
});
```
## Executing queries in parallel
The MySQL protocol is sequential, this means that you need multiple connections
to execute queries in parallel. You can use a Pool to manage connections, one
simple approach is to create one connection per incoming http request.
## Streaming query rows
Sometimes you may want to select large quantities of rows and process each of
them as they are received. This can be done like this:
```js
var query = connection.query('SELECT * FROM posts');
query
.on('error', function(err) {
// Handle error, an 'end' event will be emitted after this as well
})
.on('fields', function(fields) {
// the field packets for the rows to follow
})
.on('result', function(row) {
// Pausing the connnection is useful if your processing involves I/O
connection.pause();
processRow(row, function() {
connection.resume();
});
})
.on('end', function() {
// all rows have been received
});
```
Please note a few things about the example above:
* Usually you will want to receive a certain amount of rows before starting to
throttle the connection using `pause()`. This number will depend on the
amount and size of your rows.
* `pause()` / `resume()` operate on the underlying socket and parser. You are
guaranteed that no more `'result'` events will fire after calling `pause()`.
* You MUST NOT provide a callback to the `query()` method when streaming rows.
* The `'result'` event will fire for both rows as well as OK packets
confirming the success of a INSERT/UPDATE query.
* It is very important not to leave the result paused too long, or you may
encounter `Error: Connection lost: The server closed the connection.`
The time limit for this is determined by the
[net_write_timeout setting](https://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_net_write_timeout)
on your MySQL server.
Additionally you may be interested to know that it is currently not possible to
stream individual row columns, they will always be buffered up entirely. If you
have a good use case for streaming large fields to and from MySQL, I'd love to
get your thoughts and contributions on this.
### Piping results with Streams
The query object provides a convenience method `.stream([options])` that wraps
query events into a [Readable Stream](http://nodejs.org/api/stream.html#stream_class_stream_readable)
object. This stream can easily be piped downstream and provides automatic
pause/resume, based on downstream congestion and the optional `highWaterMark`.
The `objectMode` parameter of the stream is set to `true` and cannot be changed
(if you need a byte stream, you will need to use a transform stream, like
[objstream](https://www.npmjs.com/package/objstream) for example).
For example, piping query results into another stream (with a max buffer of 5
objects) is simply:
```js
connection.query('SELECT * FROM posts')
.stream({highWaterMark: 5})
.pipe(...);
```
## Multiple statement queries
Support for multiple statements is disabled for security reasons (it allows for
SQL injection attacks if values are not properly escaped). To use this feature
you have to enable it for your connection:
```js
var connection = mysql.createConnection({multipleStatements: true});
```
Once enabled, you can execute multiple statement queries like any other query:
```js
connection.query('SELECT 1; SELECT 2', function (error, results, fields) {
if (error) throw error;
// `results` is an array with one element for every statement in the query:
console.log(results[0]); // [{1: 1}]
console.log(results[1]); // [{2: 2}]
});
```
Additionally you can also stream the results of multiple statement queries:
```js
var query = connection.query('SELECT 1; SELECT 2');
query
.on('fields', function(fields, index) {
// the fields for the result rows that follow
})
.on('result', function(row, index) {
// index refers to the statement this result belongs to (starts at 0)
});
```
If one of the statements in your query causes an error, the resulting Error
object contains a `err.index` property which tells you which statement caused
it. MySQL will also stop executing any remaining statements when an error
occurs.
Please note that the interface for streaming multiple statement queries is
experimental and I am looking forward to feedback on it.
## Stored procedures
You can call stored procedures from your queries as with any other mysql driver.
If the stored procedure produces several result sets, they are exposed to you
the same way as the results for multiple statement queries.
## Joins with overlapping column names
When executing joins, you are likely to get result sets with overlapping column
names.
By default, node-mysql will overwrite colliding column names in the
order the columns are received from MySQL, causing some of the received values
to be unavailable.
However, you can also specify that you want your columns to be nested below
the table name like this:
```js
var options = {sql: '...', nestTables: true};
connection.query(options, function (error, results, fields) {
if (error) throw error;
/* results will be an array like this now:
[{
table1: {
fieldA: '...',
fieldB: '...',
},
table2: {
fieldA: '...',
fieldB: '...',
},
}, ...]
*/
});
```
Or use a string separator to have your results merged.
```js
var options = {sql: '...', nestTables: '_'};
connection.query(options, function (error, results, fields) {
if (error) throw error;
/* results will be an array like this now:
[{
table1_fieldA: '...',
table1_fieldB: '...',
table2_fieldA: '...',
table2_fieldB: '...',
}, ...]
*/
});
```
## Transactions
Simple transaction support is available at the connection level:
```js
connection.beginTransaction(function(err) {
if (err) { throw err; }
connection.query('INSERT INTO posts SET title=?', title, function (error, results, fields) {
if (error) {
return connection.rollback(function() {
throw error;
});
}
var log = 'Post ' + results.insertId + ' added';
connection.query('INSERT INTO log SET data=?', log, function (error, results, fields) {
if (error) {
return connection.rollback(function() {
throw error;
});
}
connection.commit(function(err) {
if (err) {
return connection.rollback(function() {
throw err;
});
}
console.log('success!');
});
});
});
});
```
Please note that beginTransaction(), commit() and rollback() are simply convenience
functions that execute the START TRANSACTION, COMMIT, and ROLLBACK commands respectively.
It is important to understand that many commands in MySQL can cause an implicit commit,
as described [in the MySQL documentation](http://dev.mysql.com/doc/refman/5.5/en/implicit-commit.html)
## Ping
A ping packet can be sent over a connection using the `connection.ping` method. This
method will send a ping packet to the server and when the server responds, the callback
will fire. If an error occurred, the callback will fire with an error argument.
```js
connection.ping(function (err) {
if (err) throw err;
console.log('Server responded to ping');
})
```
## Timeouts
Every operation takes an optional inactivity timeout option. This allows you to
specify appropriate timeouts for operations. It is important to note that these
timeouts are not part of the MySQL protocol, and rather timeout operations through
the client. This means that when a timeout is reached, the connection it occurred
on will be destroyed and no further operations can be performed.
```js
// Kill query after 60s
connection.query({sql: 'SELECT COUNT(*) AS count FROM big_table', timeout: 60000}, function (error, results, fields) {
if (error && error.code === 'PROTOCOL_SEQUENCE_TIMEOUT') {
throw new Error('too long to count table rows!');
}
if (error) {
throw error;
}
console.log(results[0].count + ' rows');
});
```
## Error handling
This module comes with a consistent approach to error handling that you should
review carefully in order to write solid applications.
Most errors created by this module are instances of the JavaScript [Error][]
object. Additionally they typically come with two extra properties:
* `err.code`: String, contains the MySQL server error symbol if the error is
a [MySQL server error][] (e.g. `'ER_ACCESS_DENIED_ERROR'`), a Node.js error
code if it is a Node.js error (e.g. `'ECONNREFUSED'`), or an internal error
code (e.g. `'PROTOCOL_CONNECTION_LOST'`).
* `err.errno`: Number, contains the MySQL server error number. Only populated
from [MySQL server error][].
* `err.fatal`: Boolean, indicating if this error is terminal to the connection
object. If the error is not from a MySQL protocol operation, this property
will not be defined.
* `err.sql`: String, contains the full SQL of the failed query. This can be
useful when using a higher level interface like an ORM that is generating
the queries.
* `err.sqlState`: String, contains the five-character SQLSTATE value. Only populated from [MySQL server error][].
* `err.sqlMessage`: String, contains the message string that provides a
textual description of the error. Only populated from [MySQL server error][].
[Error]: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error
[MySQL server error]: https://dev.mysql.com/doc/refman/5.5/en/server-error-reference.html
Fatal errors are propagated to *all* pending callbacks. In the example below, a
fatal error is triggered by trying to connect to an invalid port. Therefore the
error object is propagated to both pending callbacks:
```js
var connection = require('mysql').createConnection({
port: 84943, // WRONG PORT
});
connection.connect(function(err) {
console.log(err.code); // 'ECONNREFUSED'
console.log(err.fatal); // true
});
connection.query('SELECT 1', function (error, results, fields) {
console.log(error.code); // 'ECONNREFUSED'
console.log(error.fatal); // true
});
```
Normal errors however are only delegated to the callback they belong to. So in
the example below, only the first callback receives an error, the second query
works as expected:
```js
connection.query('USE name_of_db_that_does_not_exist', function (error, results, fields) {
console.log(error.code); // 'ER_BAD_DB_ERROR'
});
connection.query('SELECT 1', function (error, results, fields) {
console.log(error); // null
console.log(results.length); // 1
});
```
Last but not least: If a fatal errors occurs and there are no pending
callbacks, or a normal error occurs which has no callback belonging to it, the
error is emitted as an `'error'` event on the connection object. This is
demonstrated in the example below:
```js
connection.on('error', function(err) {
console.log(err.code); // 'ER_BAD_DB_ERROR'
});
connection.query('USE name_of_db_that_does_not_exist');
```
Note: `'error'` events are special in node. If they occur without an attached
listener, a stack trace is printed and your process is killed.
**tl;dr:** This module does not want you to deal with silent failures. You
should always provide callbacks to your method calls. If you want to ignore
this advice and suppress unhandled errors, you can do this:
```js
// I am Chuck Norris:
connection.on('error', function() {});
```
## Exception Safety
This module is exception safe. That means you can continue to use it, even if
one of your callback functions throws an error which you're catching using
'uncaughtException' or a domain.
## Type casting
For your convenience, this driver will cast mysql types into native JavaScript
types by default. The following mappings exist:
### Number
* TINYINT
* SMALLINT
* INT
* MEDIUMINT
* YEAR
* FLOAT
* DOUBLE
### Date
* TIMESTAMP
* DATE
* DATETIME
### Buffer
* TINYBLOB
* MEDIUMBLOB
* LONGBLOB
* BLOB
* BINARY
* VARBINARY
* BIT (last byte will be filled with 0 bits as necessary)
### String
**Note** text in the binary character set is returned as `Buffer`, rather
than a string.
* CHAR
* VARCHAR
* TINYTEXT
* MEDIUMTEXT
* LONGTEXT
* TEXT
* ENUM
* SET
* DECIMAL (may exceed float precision)
* BIGINT (may exceed float precision)
* TIME (could be mapped to Date, but what date would be set?)
* GEOMETRY (never used those, get in touch if you do)
It is not recommended (and may go away / change in the future) to disable type
casting, but you can currently do so on either the connection:
```js
var connection = require('mysql').createConnection({typeCast: false});
```
Or on the query level:
```js
var options = {sql: '...', typeCast: false};
var query = connection.query(options, function (error, results, fields) {
if (error) throw error;
// ...
});
```
### Custom type casting
You can also pass a function and handle type casting yourself. You're given some
column information like database, table and name and also type and length. If you
just want to apply a custom type casting to a specific type you can do it and then
fallback to the default.
The function is provided two arguments `field` and `next` and is expected to
return the value for the given field by invoking the parser functions through
the `field` object.
The `field` argument is a `Field` object and contains data about the field that
need to be parsed. The following are some of the properties on a `Field` object:
* `db` - a string of the database the field came from.
* `table` - a string of the table the field came from.
* `name` - a string of the field name.
* `type` - a string of the field type in all caps.
* `length` - a number of the field length, as given by the database.
The `next` argument is a `function` that, when called, will return the default
type conversion for the given field.
When getting the field data, the following helper methods are present on the
`field` object:
* `.string()` - parse the field into a string.
* `.buffer()` - parse the field into a `Buffer`.
* `.geometry()` - parse the field as a geometry value.
The MySQL protocol is a text-based protocol. This means that over the wire, all
field types are represented as a string, which is why only string-like functions
are available on the `field` object. Based on the type information (like `INT`),
the type cast should convert the string field into a different JavaScript type
(like a `number`).
Here's an example of converting `TINYINT(1)` to boolean:
```js
connection = mysql.createConnection({
typeCast: function (field, next) {
if (field.type === 'TINY' && field.length === 1) {
return (field.string() === '1'); // 1 = true, 0 = false
} else {
return next();
}
}
});
```
__WARNING: YOU MUST INVOKE the parser using one of these three field functions
in your custom typeCast callback. They can only be called once.__
## Debugging and reporting problems
If you are running into problems, one thing that may help is enabling the
`debug` mode for the connection:
```js
var connection = mysql.createConnection({debug: true});
```
This will print all incoming and outgoing packets on stdout. You can also restrict debugging to
packet types by passing an array of types to debug:
```js
var connection = mysql.createConnection({debug: ['ComQueryPacket', 'RowDataPacket']});
```
to restrict debugging to the query and data packets.
If that does not help, feel free to open a GitHub issue. A good GitHub issue
will have:
* The minimal amount of code required to reproduce the problem (if possible)
* As much debugging output and information about your environment (mysql
version, node version, os, etc.) as you can gather.
## Security issues
Security issues should not be first reported through GitHub or another public
forum, but kept private in order for the collaborators to assess the report
and either (a) devise a fix and plan a release date or (b) assert that it is
not a security issue (in which case it can be posted in a public forum, like
a GitHub issue).
The primary private forum is email, either by emailing the module's author or
opening a GitHub issue simply asking to whom a security issues should be
addressed to without disclosing the issue or type of issue.
An ideal report would include a clear indication of what the security issue is
and how it would be exploited, ideally with an accompanying proof of concept
("PoC") for collaborators to work against and validate potentional fixes against.
## Contributing
This project welcomes contributions from the community. Contributions are
accepted using GitHub pull requests. If you're not familiar with making
GitHub pull requests, please refer to the
[GitHub documentation "Creating a pull request"](https://help.github.com/articles/creating-a-pull-request/).
For a good pull request, we ask you provide the following:
1. Try to include a clear description of your pull request in the description.
It should include the basic "what" and "why"s for the request.
2. The tests should pass as best as you can. See the [Running tests](#running-tests)
section on how to run the different tests. GitHub will automatically run
the tests as well, to act as a safety net.
3. The pull request should include tests for the change. A new feature should
have tests for the new feature and bug fixes should include a test that fails
without the corresponding code change and passes after they are applied.
The command `npm run test-cov` will generate a `coverage/` folder that
contains HTML pages of the code coverage, to better understand if everything
you're adding is being tested.
4. If the pull request is a new feature, please be sure to include all
appropriate documentation additions in the `Readme.md` file as well.
5. To help ensure that your code is similar in style to the existing code,
run the command `npm run lint` and fix any displayed issues.
## Running tests
The test suite is split into two parts: unit tests and integration tests.
The unit tests run on any machine while the integration tests require a
MySQL server instance to be setup.
### Running unit tests
```sh
$ FILTER=unit npm test
```
### Running integration tests
Set the environment variables `MYSQL_DATABASE`, `MYSQL_HOST`, `MYSQL_PORT`,
`MYSQL_USER` and `MYSQL_PASSWORD`. `MYSQL_SOCKET` can also be used in place
of `MYSQL_HOST` and `MYSQL_PORT` to connect over a UNIX socket. Then run
`npm test`.
For example, if you have an installation of mysql running on localhost:3306
and no password set for the `root` user, run:
```sh
$ mysql -u root -e "CREATE DATABASE IF NOT EXISTS node_mysql_test"
$ MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_DATABASE=node_mysql_test MYSQL_USER=root MYSQL_PASSWORD= FILTER=integration npm test
```
## Todo
* Prepared statements
* Support for encodings other than UTF-8 / ASCII
[appveyor-image]: https://badgen.net/appveyor/ci/dougwilson/node-mysql/master?label=windows
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/node-mysql
[coveralls-image]: https://badgen.net/coveralls/c/github/mysqljs/mysql/master
[coveralls-url]: https://coveralls.io/r/mysqljs/mysql?branch=master
[node-image]: https://badgen.net/npm/node/mysql
[node-url]: https://nodejs.org/en/download
[npm-downloads-image]: https://badgen.net/npm/dm/mysql
[npm-url]: https://npmjs.org/package/mysql
[npm-version-image]: https://badgen.net/npm/v/mysql
[travis-image]: https://badgen.net/travis/mysqljs/mysql/master
[travis-url]: https://travis-ci.org/mysqljs/mysql
var Classes = Object.create(null);
/**
* Create a new Connection instance.
* @param {object|string} config Configuration or connection string for new MySQL connection
* @return {Connection} A new MySQL connection
* @public
*/
exports.createConnection = function createConnection(config) {
var Connection = loadClass('Connection');
var ConnectionConfig = loadClass('ConnectionConfig');
return new Connection({config: new ConnectionConfig(config)});
};
/**
* Create a new Pool instance.
* @param {object|string} config Configuration or connection string for new MySQL connections
* @return {Pool} A new MySQL pool
* @public
*/
exports.createPool = function createPool(config) {
var Pool = loadClass('Pool');
var PoolConfig = loadClass('PoolConfig');
return new Pool({config: new PoolConfig(config)});
};
/**
* Create a new PoolCluster instance.
* @param {object} [config] Configuration for pool cluster
* @return {PoolCluster} New MySQL pool cluster
* @public
*/
exports.createPoolCluster = function createPoolCluster(config) {
var PoolCluster = loadClass('PoolCluster');
return new PoolCluster(config);
};
/**
* Create a new Query instance.
* @param {string} sql The SQL for the query
* @param {array} [values] Any values to insert into placeholders in sql
* @param {function} [callback] The callback to use when query is complete
* @return {Query} New query object
* @public
*/
exports.createQuery = function createQuery(sql, values, callback) {
var Connection = loadClass('Connection');
return Connection.createQuery(sql, values, callback);
};
/**
* Escape a value for SQL.
* @param {*} value The value to escape
* @param {boolean} [stringifyObjects=false] Setting if objects should be stringified
* @param {string} [timeZone=local] Setting for time zone to use for Date conversion
* @return {string} Escaped string value
* @public
*/
exports.escape = function escape(value, stringifyObjects, timeZone) {
var SqlString = loadClass('SqlString');
return SqlString.escape(value, stringifyObjects, timeZone);
};
/**
* Escape an identifier for SQL.
* @param {*} value The value to escape
* @param {boolean} [forbidQualified=false] Setting to treat '.' as part of identifier
* @return {string} Escaped string value
* @public
*/
exports.escapeId = function escapeId(value, forbidQualified) {
var SqlString = loadClass('SqlString');
return SqlString.escapeId(value, forbidQualified);
};
/**
* Format SQL and replacement values into a SQL string.
* @param {string} sql The SQL for the query
* @param {array} [values] Any values to insert into placeholders in sql
* @param {boolean} [stringifyObjects=false] Setting if objects should be stringified
* @param {string} [timeZone=local] Setting for time zone to use for Date conversion
* @return {string} Formatted SQL string
* @public
*/
exports.format = function format(sql, values, stringifyObjects, timeZone) {
var SqlString = loadClass('SqlString');
return SqlString.format(sql, values, stringifyObjects, timeZone);
};
/**
* Wrap raw SQL strings from escape overriding.
* @param {string} sql The raw SQL
* @return {object} Wrapped object
* @public
*/
exports.raw = function raw(sql) {
var SqlString = loadClass('SqlString');
return SqlString.raw(sql);
};
/**
* The type constants.
* @public
*/
Object.defineProperty(exports, 'Types', {
get: loadClass.bind(null, 'Types')
});
/**
* Load the given class.
* @param {string} className Name of class to default
* @return {function|object} Class constructor or exports
* @private
*/
function loadClass(className) {
var Class = Classes[className];
if (Class !== undefined) {
return Class;
}
// This uses a switch for static require analysis
switch (className) {
case 'Connection':
Class = require('./lib/Connection');
break;
case 'ConnectionConfig':
Class = require('./lib/ConnectionConfig');
break;
case 'Pool':
Class = require('./lib/Pool');
break;
case 'PoolCluster':
Class = require('./lib/PoolCluster');
break;
case 'PoolConfig':
Class = require('./lib/PoolConfig');
break;
case 'SqlString':
Class = require('./lib/protocol/SqlString');
break;
case 'Types':
Class = require('./lib/protocol/constants/types');
break;
default:
throw new Error('Cannot find class \'' + className + '\'');
}
// Store to prevent invoking require()
Classes[className] = Class;
return Class;
}
var Crypto = require('crypto');
var Events = require('events');
var Net = require('net');
var tls = require('tls');
var ConnectionConfig = require('./ConnectionConfig');
var Protocol = require('./protocol/Protocol');
var SqlString = require('./protocol/SqlString');
var Query = require('./protocol/sequences/Query');
var Util = require('util');
module.exports = Connection;
Util.inherits(Connection, Events.EventEmitter);
function Connection(options) {
Events.EventEmitter.call(this);
this.config = options.config;
this._socket = options.socket;
this._protocol = new Protocol({config: this.config, connection: this});
this._connectCalled = false;
this.state = 'disconnected';
this.threadId = null;
}
Connection.createQuery = function createQuery(sql, values, callback) {
if (sql instanceof Query) {
return sql;
}
var cb = callback;
var options = {};
if (typeof sql === 'function') {
cb = sql;
} else if (typeof sql === 'object') {
options = Object.create(sql);
if (typeof values === 'function') {
cb = values;
} else if (values !== undefined) {
Object.defineProperty(options, 'values', { value: values });
}
} else {
options.sql = sql;
if (typeof values === 'function') {
cb = values;
} else if (values !== undefined) {
options.values = values;
}
}
if (cb !== undefined) {
cb = wrapCallbackInDomain(null, cb);
if (cb === undefined) {
throw new TypeError('argument callback must be a function when provided');
}
}
return new Query(options, cb);
};
Connection.prototype.connect = function connect(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
if (!this._connectCalled) {
this._connectCalled = true;
// Connect either via a UNIX domain socket or a TCP socket.
this._socket = (this.config.socketPath)
? Net.createConnection(this.config.socketPath)
: Net.createConnection(this.config.port, this.config.host);
// Connect socket to connection domain
if (Events.usingDomains) {
this._socket.domain = this.domain;
}
var connection = this;
this._protocol.on('data', function(data) {
connection._socket.write(data);
});
this._socket.on('data', wrapToDomain(connection, function (data) {
connection._protocol.write(data);
}));
this._protocol.on('end', function() {
connection._socket.end();
});
this._socket.on('end', wrapToDomain(connection, function () {
connection._protocol.end();
}));
this._socket.on('error', this._handleNetworkError.bind(this));
this._socket.on('connect', this._handleProtocolConnect.bind(this));
this._protocol.on('handshake', this._handleProtocolHandshake.bind(this));
this._protocol.on('initialize', this._handleProtocolInitialize.bind(this));
this._protocol.on('unhandledError', this._handleProtocolError.bind(this));
this._protocol.on('drain', this._handleProtocolDrain.bind(this));
this._protocol.on('end', this._handleProtocolEnd.bind(this));
this._protocol.on('enqueue', this._handleProtocolEnqueue.bind(this));
if (this.config.connectTimeout) {
var handleConnectTimeout = this._handleConnectTimeout.bind(this);
this._socket.setTimeout(this.config.connectTimeout, handleConnectTimeout);
this._socket.once('connect', function() {
this.setTimeout(0, handleConnectTimeout);
});
}
}
this._protocol.handshake(options, wrapCallbackInDomain(this, callback));
};
Connection.prototype.changeUser = function changeUser(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
this._implyConnect();
var charsetNumber = (options.charset)
? ConnectionConfig.getCharsetNumber(options.charset)
: this.config.charsetNumber;
return this._protocol.changeUser({
user : options.user || this.config.user,
password : options.password || this.config.password,
database : options.database || this.config.database,
timeout : options.timeout,
charsetNumber : charsetNumber,
currentConfig : this.config
}, wrapCallbackInDomain(this, callback));
};
Connection.prototype.beginTransaction = function beginTransaction(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
options = options || {};
options.sql = 'START TRANSACTION';
options.values = null;
return this.query(options, callback);
};
Connection.prototype.commit = function commit(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
options = options || {};
options.sql = 'COMMIT';
options.values = null;
return this.query(options, callback);
};
Connection.prototype.rollback = function rollback(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
options = options || {};
options.sql = 'ROLLBACK';
options.values = null;
return this.query(options, callback);
};
Connection.prototype.query = function query(sql, values, cb) {
var query = Connection.createQuery(sql, values, cb);
query._connection = this;
if (!(typeof sql === 'object' && 'typeCast' in sql)) {
query.typeCast = this.config.typeCast;
}
if (query.sql) {
query.sql = this.format(query.sql, query.values);
}
if (query._callback) {
query._callback = wrapCallbackInDomain(this, query._callback);
}
this._implyConnect();
return this._protocol._enqueue(query);
};
Connection.prototype.ping = function ping(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
this._implyConnect();
this._protocol.ping(options, wrapCallbackInDomain(this, callback));
};
Connection.prototype.statistics = function statistics(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
this._implyConnect();
this._protocol.stats(options, wrapCallbackInDomain(this, callback));
};
Connection.prototype.end = function end(options, callback) {
var cb = callback;
var opts = options;
if (!callback && typeof options === 'function') {
cb = options;
opts = null;
}
// create custom options reference
opts = Object.create(opts || null);
if (opts.timeout === undefined) {
// default timeout of 30 seconds
opts.timeout = 30000;
}
this._implyConnect();
this._protocol.quit(opts, wrapCallbackInDomain(this, cb));
};
Connection.prototype.destroy = function() {
this.state = 'disconnected';
this._implyConnect();
this._socket.destroy();
this._protocol.destroy();
};
Connection.prototype.pause = function() {
this._socket.pause();
this._protocol.pause();
};
Connection.prototype.resume = function() {
this._socket.resume();
this._protocol.resume();
};
Connection.prototype.escape = function(value) {
return SqlString.escape(value, false, this.config.timezone);
};
Connection.prototype.escapeId = function escapeId(value) {
return SqlString.escapeId(value, false);
};
Connection.prototype.format = function(sql, values) {
if (typeof this.config.queryFormat === 'function') {
return this.config.queryFormat.call(this, sql, values, this.config.timezone);
}
return SqlString.format(sql, values, this.config.stringifyObjects, this.config.timezone);
};
if (tls.TLSSocket) {
// 0.11+ environment
Connection.prototype._startTLS = function _startTLS(onSecure) {
var connection = this;
createSecureContext(this.config, function (err, secureContext) {
if (err) {
onSecure(err);
return;
}
// "unpipe"
connection._socket.removeAllListeners('data');
connection._protocol.removeAllListeners('data');
// socket <-> encrypted
var rejectUnauthorized = connection.config.ssl.rejectUnauthorized;
var secureEstablished = false;
var secureSocket = new tls.TLSSocket(connection._socket, {
rejectUnauthorized : rejectUnauthorized,
requestCert : true,
secureContext : secureContext,
isServer : false
});
// error handler for secure socket
secureSocket.on('_tlsError', function(err) {
if (secureEstablished) {
connection._handleNetworkError(err);
} else {
onSecure(err);
}
});
// cleartext <-> protocol
secureSocket.pipe(connection._protocol);
connection._protocol.on('data', function(data) {
secureSocket.write(data);
});
secureSocket.on('secure', function() {
secureEstablished = true;
onSecure(rejectUnauthorized ? this.ssl.verifyError() : null);
});
// start TLS communications
secureSocket._start();
});
};
} else {
// pre-0.11 environment
Connection.prototype._startTLS = function _startTLS(onSecure) {
// before TLS:
// _socket <-> _protocol
// after:
// _socket <-> securePair.encrypted <-> securePair.cleartext <-> _protocol
var connection = this;
var credentials = Crypto.createCredentials({
ca : this.config.ssl.ca,
cert : this.config.ssl.cert,
ciphers : this.config.ssl.ciphers,
key : this.config.ssl.key,
passphrase : this.config.ssl.passphrase
});
var rejectUnauthorized = this.config.ssl.rejectUnauthorized;
var secureEstablished = false;
var securePair = tls.createSecurePair(credentials, false, true, rejectUnauthorized);
// error handler for secure pair
securePair.on('error', function(err) {
if (secureEstablished) {
connection._handleNetworkError(err);
} else {
onSecure(err);
}
});
// "unpipe"
this._socket.removeAllListeners('data');
this._protocol.removeAllListeners('data');
// socket <-> encrypted
securePair.encrypted.pipe(this._socket);
this._socket.on('data', function(data) {
securePair.encrypted.write(data);
});
// cleartext <-> protocol
securePair.cleartext.pipe(this._protocol);
this._protocol.on('data', function(data) {
securePair.cleartext.write(data);
});
// secure established
securePair.on('secure', function() {
secureEstablished = true;
if (!rejectUnauthorized) {
onSecure();
return;
}
var verifyError = this.ssl.verifyError();
var err = verifyError;
// node.js 0.6 support
if (typeof err === 'string') {
err = new Error(verifyError);
err.code = verifyError;
}
onSecure(err);
});
// node.js 0.8 bug
securePair._cycle = securePair.cycle;
securePair.cycle = function cycle() {
if (this.ssl && this.ssl.error) {
this.error();
}
return this._cycle.apply(this, arguments);
};
};
}
Connection.prototype._handleConnectTimeout = function() {
if (this._socket) {
this._socket.setTimeout(0);
this._socket.destroy();
}
var err = new Error('connect ETIMEDOUT');
err.errorno = 'ETIMEDOUT';
err.code = 'ETIMEDOUT';
err.syscall = 'connect';
this._handleNetworkError(err);
};
Connection.prototype._handleNetworkError = function(err) {
this._protocol.handleNetworkError(err);
};
Connection.prototype._handleProtocolError = function(err) {
this.state = 'protocol_error';
this.emit('error', err);
};
Connection.prototype._handleProtocolDrain = function() {
this.emit('drain');
};
Connection.prototype._handleProtocolConnect = function() {
this.state = 'connected';
this.emit('connect');
};
Connection.prototype._handleProtocolHandshake = function _handleProtocolHandshake() {
this.state = 'authenticated';
};
Connection.prototype._handleProtocolInitialize = function _handleProtocolInitialize(packet) {
this.threadId = packet.threadId;
};
Connection.prototype._handleProtocolEnd = function(err) {
this.state = 'disconnected';
this.emit('end', err);
};
Connection.prototype._handleProtocolEnqueue = function _handleProtocolEnqueue(sequence) {
this.emit('enqueue', sequence);
};
Connection.prototype._implyConnect = function() {
if (!this._connectCalled) {
this.connect();
}
};
function createSecureContext (config, cb) {
var context = null;
var error = null;
try {
context = tls.createSecureContext({
ca : config.ssl.ca,
cert : config.ssl.cert,
ciphers : config.ssl.ciphers,
key : config.ssl.key,
passphrase : config.ssl.passphrase
});
} catch (err) {
error = err;
}
cb(error, context);
}
function unwrapFromDomain(fn) {
return function () {
var domains = [];
var ret;
while (process.domain) {
domains.shift(process.domain);
process.domain.exit();
}
try {
ret = fn.apply(this, arguments);
} finally {
for (var i = 0; i < domains.length; i++) {
domains[i].enter();
}
}
return ret;
};
}
function wrapCallbackInDomain(ee, fn) {
if (typeof fn !== 'function') {
return undefined;
}
if (fn.domain) {
return fn;
}
var domain = process.domain;
if (domain) {
return domain.bind(fn);
} else if (ee) {
return unwrapFromDomain(wrapToDomain(ee, fn));
} else {
return fn;
}
}
function wrapToDomain(ee, fn) {
return function () {
if (Events.usingDomains && ee.domain) {
ee.domain.enter();
fn.apply(this, arguments);
ee.domain.exit();
} else {
fn.apply(this, arguments);
}
};
}
var urlParse = require('url').parse;
var ClientConstants = require('./protocol/constants/client');
var Charsets = require('./protocol/constants/charsets');
var SSLProfiles = null;
module.exports = ConnectionConfig;
function ConnectionConfig(options) {
if (typeof options === 'string') {
options = ConnectionConfig.parseUrl(options);
}
this.host = options.host || 'localhost';
this.port = options.port || 3306;
this.localAddress = options.localAddress;
this.socketPath = options.socketPath;
this.user = options.user || undefined;
this.password = options.password || undefined;
this.database = options.database;
this.connectTimeout = (options.connectTimeout === undefined)
? (10 * 1000)
: options.connectTimeout;
this.insecureAuth = options.insecureAuth || false;
this.supportBigNumbers = options.supportBigNumbers || false;
this.bigNumberStrings = options.bigNumberStrings || false;
this.dateStrings = options.dateStrings || false;
this.debug = options.debug;
this.trace = options.trace !== false;
this.stringifyObjects = options.stringifyObjects || false;
this.timezone = options.timezone || 'local';
this.flags = options.flags || '';
this.queryFormat = options.queryFormat;
this.pool = options.pool || undefined;
this.ssl = (typeof options.ssl === 'string')
? ConnectionConfig.getSSLProfile(options.ssl)
: (options.ssl || false);
this.localInfile = (options.localInfile === undefined)
? true
: options.localInfile;
this.multipleStatements = options.multipleStatements || false;
this.typeCast = (options.typeCast === undefined)
? true
: options.typeCast;
if (this.timezone[0] === ' ') {
// "+" is a url encoded char for space so it
// gets translated to space when giving a
// connection string..
this.timezone = '+' + this.timezone.substr(1);
}
if (this.ssl) {
// Default rejectUnauthorized to true
this.ssl.rejectUnauthorized = this.ssl.rejectUnauthorized !== false;
}
this.maxPacketSize = 0;
this.charsetNumber = (options.charset)
? ConnectionConfig.getCharsetNumber(options.charset)
: options.charsetNumber || Charsets.UTF8_GENERAL_CI;
// Set the client flags
var defaultFlags = ConnectionConfig.getDefaultFlags(options);
this.clientFlags = ConnectionConfig.mergeFlags(defaultFlags, options.flags);
}
ConnectionConfig.mergeFlags = function mergeFlags(defaultFlags, userFlags) {
var allFlags = ConnectionConfig.parseFlagList(defaultFlags);
var newFlags = ConnectionConfig.parseFlagList(userFlags);
// Merge the new flags
for (var flag in newFlags) {
if (allFlags[flag] !== false) {
allFlags[flag] = newFlags[flag];
}
}
// Build flags
var flags = 0x0;
for (var flag in allFlags) {
if (allFlags[flag]) {
// TODO: Throw here on some future release
flags |= ClientConstants['CLIENT_' + flag] || 0x0;
}
}
return flags;
};
ConnectionConfig.getCharsetNumber = function getCharsetNumber(charset) {
var num = Charsets[charset.toUpperCase()];
if (num === undefined) {
throw new TypeError('Unknown charset \'' + charset + '\'');
}
return num;
};
ConnectionConfig.getDefaultFlags = function getDefaultFlags(options) {
var defaultFlags = [
'-COMPRESS', // Compression protocol *NOT* supported
'-CONNECT_ATTRS', // Does *NOT* send connection attributes in Protocol::HandshakeResponse41
'+CONNECT_WITH_DB', // One can specify db on connect in Handshake Response Packet
'+FOUND_ROWS', // Send found rows instead of affected rows
'+IGNORE_SIGPIPE', // Don't issue SIGPIPE if network failures
'+IGNORE_SPACE', // Let the parser ignore spaces before '('
'+LOCAL_FILES', // Can use LOAD DATA LOCAL
'+LONG_FLAG', // Longer flags in Protocol::ColumnDefinition320
'+LONG_PASSWORD', // Use the improved version of Old Password Authentication
'+MULTI_RESULTS', // Can handle multiple resultsets for COM_QUERY
'+ODBC', // Special handling of ODBC behaviour
'-PLUGIN_AUTH', // Does *NOT* support auth plugins
'+PROTOCOL_41', // Uses the 4.1 protocol
'+PS_MULTI_RESULTS', // Can handle multiple resultsets for COM_STMT_EXECUTE
'+RESERVED', // Unused
'+SECURE_CONNECTION', // Supports Authentication::Native41
'+TRANSACTIONS' // Expects status flags
];
if (options && options.localInfile !== undefined && !options.localInfile) {
// Disable LOCAL modifier for LOAD DATA INFILE
defaultFlags.push('-LOCAL_FILES');
}
if (options && options.multipleStatements) {
// May send multiple statements per COM_QUERY and COM_STMT_PREPARE
defaultFlags.push('+MULTI_STATEMENTS');
}
return defaultFlags;
};
ConnectionConfig.getSSLProfile = function getSSLProfile(name) {
if (!SSLProfiles) {
SSLProfiles = require('./protocol/constants/ssl_profiles');
}
var ssl = SSLProfiles[name];
if (ssl === undefined) {
throw new TypeError('Unknown SSL profile \'' + name + '\'');
}
return ssl;
};
ConnectionConfig.parseFlagList = function parseFlagList(flagList) {
var allFlags = Object.create(null);
if (!flagList) {
return allFlags;
}
var flags = !Array.isArray(flagList)
? String(flagList || '').toUpperCase().split(/\s*,+\s*/)
: flagList;
for (var i = 0; i < flags.length; i++) {
var flag = flags[i];
var offset = 1;
var state = flag[0];
if (state === undefined) {
// TODO: throw here on some future release
continue;
}
if (state !== '-' && state !== '+') {
offset = 0;
state = '+';
}
allFlags[flag.substr(offset)] = state === '+';
}
return allFlags;
};
ConnectionConfig.parseUrl = function(url) {
url = urlParse(url, true);
var options = {
host : url.hostname,
port : url.port,
database : url.pathname.substr(1)
};
if (url.auth) {
var auth = url.auth.split(':');
options.user = auth.shift();
options.password = auth.join(':');
}
if (url.query) {
for (var key in url.query) {
var value = url.query[key];
try {
// Try to parse this as a JSON expression first
options[key] = JSON.parse(value);
} catch (err) {
// Otherwise assume it is a plain string
options[key] = value;
}
}
}
return options;
};
var mysql = require('../');
var Connection = require('./Connection');
var EventEmitter = require('events').EventEmitter;
var Util = require('util');
var PoolConnection = require('./PoolConnection');
module.exports = Pool;
Util.inherits(Pool, EventEmitter);
function Pool(options) {
EventEmitter.call(this);
this.config = options.config;
this.config.connectionConfig.pool = this;
this._acquiringConnections = [];
this._allConnections = [];
this._freeConnections = [];
this._connectionQueue = [];
this._closed = false;
}
Pool.prototype.getConnection = function (cb) {
if (this._closed) {
var err = new Error('Pool is closed.');
err.code = 'POOL_CLOSED';
process.nextTick(function () {
cb(err);
});
return;
}
var connection;
var pool = this;
if (this._freeConnections.length > 0) {
connection = this._freeConnections.shift();
this.acquireConnection(connection, cb);
return;
}
if (this.config.connectionLimit === 0 || this._allConnections.length < this.config.connectionLimit) {
connection = new PoolConnection(this, { config: this.config.newConnectionConfig() });
this._acquiringConnections.push(connection);
this._allConnections.push(connection);
connection.connect({timeout: this.config.acquireTimeout}, function onConnect(err) {
spliceConnection(pool._acquiringConnections, connection);
if (pool._closed) {
err = new Error('Pool is closed.');
err.code = 'POOL_CLOSED';
}
if (err) {
pool._purgeConnection(connection);
cb(err);
return;
}
pool.emit('connection', connection);
pool.emit('acquire', connection);
cb(null, connection);
});
return;
}
if (!this.config.waitForConnections) {
process.nextTick(function(){
var err = new Error('No connections available.');
err.code = 'POOL_CONNLIMIT';
cb(err);
});
return;
}
this._enqueueCallback(cb);
};
Pool.prototype.acquireConnection = function acquireConnection(connection, cb) {
if (connection._pool !== this) {
throw new Error('Connection acquired from wrong pool.');
}
var changeUser = this._needsChangeUser(connection);
var pool = this;
this._acquiringConnections.push(connection);
function onOperationComplete(err) {
spliceConnection(pool._acquiringConnections, connection);
if (pool._closed) {
err = new Error('Pool is closed.');
err.code = 'POOL_CLOSED';
}
if (err) {
pool._connectionQueue.unshift(cb);
pool._purgeConnection(connection);
return;
}
if (changeUser) {
pool.emit('connection', connection);
}
pool.emit('acquire', connection);
cb(null, connection);
}
if (changeUser) {
// restore user back to pool configuration
connection.config = this.config.newConnectionConfig();
connection.changeUser({timeout: this.config.acquireTimeout}, onOperationComplete);
} else {
// ping connection
connection.ping({timeout: this.config.acquireTimeout}, onOperationComplete);
}
};
Pool.prototype.releaseConnection = function releaseConnection(connection) {
if (this._acquiringConnections.indexOf(connection) !== -1) {
// connection is being acquired
return;
}
if (connection._pool) {
if (connection._pool !== this) {
throw new Error('Connection released to wrong pool');
}
if (this._freeConnections.indexOf(connection) !== -1) {
// connection already in free connection pool
// this won't catch all double-release cases
throw new Error('Connection already released');
} else {
// add connection to end of free queue
this._freeConnections.push(connection);
this.emit('release', connection);
}
}
if (this._closed) {
// empty the connection queue
this._connectionQueue.splice(0).forEach(function (cb) {
var err = new Error('Pool is closed.');
err.code = 'POOL_CLOSED';
process.nextTick(function () {
cb(err);
});
});
} else if (this._connectionQueue.length) {
// get connection with next waiting callback
this.getConnection(this._connectionQueue.shift());
}
};
Pool.prototype.end = function (cb) {
this._closed = true;
if (typeof cb !== 'function') {
cb = function (err) {
if (err) throw err;
};
}
var calledBack = false;
var waitingClose = 0;
function onEnd(err) {
if (!calledBack && (err || --waitingClose <= 0)) {
calledBack = true;
cb(err);
}
}
while (this._allConnections.length !== 0) {
waitingClose++;
this._purgeConnection(this._allConnections[0], onEnd);
}
if (waitingClose === 0) {
process.nextTick(onEnd);
}
};
Pool.prototype.query = function (sql, values, cb) {
var query = Connection.createQuery(sql, values, cb);
if (!(typeof sql === 'object' && 'typeCast' in sql)) {
query.typeCast = this.config.connectionConfig.typeCast;
}
if (this.config.connectionConfig.trace) {
// Long stack trace support
query._callSite = new Error();
}
this.getConnection(function (err, conn) {
if (err) {
query.on('error', function () {});
query.end(err);
return;
}
// Release connection based off event
query.once('end', function() {
conn.release();
});
conn.query(query);
});
return query;
};
Pool.prototype._enqueueCallback = function _enqueueCallback(callback) {
if (this.config.queueLimit && this._connectionQueue.length >= this.config.queueLimit) {
process.nextTick(function () {
var err = new Error('Queue limit reached.');
err.code = 'POOL_ENQUEUELIMIT';
callback(err);
});
return;
}
// Bind to domain, as dequeue will likely occur in a different domain
var cb = process.domain
? process.domain.bind(callback)
: callback;
this._connectionQueue.push(cb);
this.emit('enqueue');
};
Pool.prototype._needsChangeUser = function _needsChangeUser(connection) {
var connConfig = connection.config;
var poolConfig = this.config.connectionConfig;
// check if changeUser values are different
return connConfig.user !== poolConfig.user
|| connConfig.database !== poolConfig.database
|| connConfig.password !== poolConfig.password
|| connConfig.charsetNumber !== poolConfig.charsetNumber;
};
Pool.prototype._purgeConnection = function _purgeConnection(connection, callback) {
var cb = callback || function () {};
if (connection.state === 'disconnected') {
connection.destroy();
}
this._removeConnection(connection);
if (connection.state !== 'disconnected' && !connection._protocol._quitSequence) {
connection._realEnd(cb);
return;
}
process.nextTick(cb);
};
Pool.prototype._removeConnection = function(connection) {
connection._pool = null;
// Remove connection from all connections
spliceConnection(this._allConnections, connection);
// Remove connection from free connections
spliceConnection(this._freeConnections, connection);
this.releaseConnection(connection);
};
Pool.prototype.escape = function(value) {
return mysql.escape(value, this.config.connectionConfig.stringifyObjects, this.config.connectionConfig.timezone);
};
Pool.prototype.escapeId = function escapeId(value) {
return mysql.escapeId(value, false);
};
function spliceConnection(array, connection) {
var index;
if ((index = array.indexOf(connection)) !== -1) {
// Remove connection from all connections
array.splice(index, 1);
}
}
var Pool = require('./Pool');
var PoolConfig = require('./PoolConfig');
var PoolNamespace = require('./PoolNamespace');
var PoolSelector = require('./PoolSelector');
var Util = require('util');
var EventEmitter = require('events').EventEmitter;
module.exports = PoolCluster;
/**
* PoolCluster
* @constructor
* @param {object} [config] The pool cluster configuration
* @public
*/
function PoolCluster(config) {
EventEmitter.call(this);
config = config || {};
this._canRetry = typeof config.canRetry === 'undefined' ? true : config.canRetry;
this._defaultSelector = config.defaultSelector || 'RR';
this._removeNodeErrorCount = config.removeNodeErrorCount || 5;
this._restoreNodeTimeout = config.restoreNodeTimeout || 0;
this._closed = false;
this._findCaches = Object.create(null);
this._lastId = 0;
this._namespaces = Object.create(null);
this._nodes = Object.create(null);
}
Util.inherits(PoolCluster, EventEmitter);
PoolCluster.prototype.add = function add(id, config) {
if (this._closed) {
throw new Error('PoolCluster is closed.');
}
var nodeId = typeof id === 'object'
? 'CLUSTER::' + (++this._lastId)
: String(id);
if (this._nodes[nodeId] !== undefined) {
throw new Error('Node ID "' + nodeId + '" is already defined in PoolCluster.');
}
var poolConfig = typeof id !== 'object'
? new PoolConfig(config)
: new PoolConfig(id);
this._nodes[nodeId] = {
id : nodeId,
errorCount : 0,
pool : new Pool({config: poolConfig}),
_offlineUntil : 0
};
this._clearFindCaches();
};
PoolCluster.prototype.end = function end(callback) {
var cb = callback !== undefined
? callback
: _cb;
if (typeof cb !== 'function') {
throw TypeError('callback argument must be a function');
}
if (this._closed) {
process.nextTick(cb);
return;
}
this._closed = true;
var calledBack = false;
var nodeIds = Object.keys(this._nodes);
var waitingClose = 0;
function onEnd(err) {
if (!calledBack && (err || --waitingClose <= 0)) {
calledBack = true;
cb(err);
}
}
for (var i = 0; i < nodeIds.length; i++) {
var nodeId = nodeIds[i];
var node = this._nodes[nodeId];
waitingClose++;
node.pool.end(onEnd);
}
if (waitingClose === 0) {
process.nextTick(onEnd);
}
};
PoolCluster.prototype.of = function(pattern, selector) {
pattern = pattern || '*';
selector = selector || this._defaultSelector;
selector = selector.toUpperCase();
if (typeof PoolSelector[selector] === 'undefined') {
selector = this._defaultSelector;
}
var key = pattern + selector;
if (typeof this._namespaces[key] === 'undefined') {
this._namespaces[key] = new PoolNamespace(this, pattern, selector);
}
return this._namespaces[key];
};
PoolCluster.prototype.remove = function remove(pattern) {
var foundNodeIds = this._findNodeIds(pattern, true);
for (var i = 0; i < foundNodeIds.length; i++) {
var node = this._getNode(foundNodeIds[i]);
if (node) {
this._removeNode(node);
}
}
};
PoolCluster.prototype.getConnection = function(pattern, selector, cb) {
var namespace;
if (typeof pattern === 'function') {
cb = pattern;
namespace = this.of();
} else {
if (typeof selector === 'function') {
cb = selector;
selector = this._defaultSelector;
}
namespace = this.of(pattern, selector);
}
namespace.getConnection(cb);
};
PoolCluster.prototype._clearFindCaches = function _clearFindCaches() {
this._findCaches = Object.create(null);
};
PoolCluster.prototype._decreaseErrorCount = function _decreaseErrorCount(node) {
var errorCount = node.errorCount;
if (errorCount > this._removeNodeErrorCount) {
errorCount = this._removeNodeErrorCount;
}
if (errorCount < 1) {
errorCount = 1;
}
node.errorCount = errorCount - 1;
if (node._offlineUntil) {
node._offlineUntil = 0;
this.emit('online', node.id);
}
};
PoolCluster.prototype._findNodeIds = function _findNodeIds(pattern, includeOffline) {
var currentTime = 0;
var foundNodeIds = this._findCaches[pattern];
if (foundNodeIds === undefined) {
var expression = patternRegExp(pattern);
var nodeIds = Object.keys(this._nodes);
foundNodeIds = nodeIds.filter(function (id) {
return id.match(expression);
});
this._findCaches[pattern] = foundNodeIds;
}
if (includeOffline) {
return foundNodeIds;
}
return foundNodeIds.filter(function (nodeId) {
var node = this._getNode(nodeId);
if (!node._offlineUntil) {
return true;
}
if (!currentTime) {
currentTime = getMonotonicMilliseconds();
}
return node._offlineUntil <= currentTime;
}, this);
};
PoolCluster.prototype._getNode = function _getNode(id) {
return this._nodes[id] || null;
};
PoolCluster.prototype._increaseErrorCount = function _increaseErrorCount(node) {
var errorCount = ++node.errorCount;
if (this._removeNodeErrorCount > errorCount) {
return;
}
if (this._restoreNodeTimeout > 0) {
node._offlineUntil = getMonotonicMilliseconds() + this._restoreNodeTimeout;
this.emit('offline', node.id);
return;
}
this._removeNode(node);
this.emit('remove', node.id);
};
PoolCluster.prototype._getConnection = function(node, cb) {
var self = this;
node.pool.getConnection(function (err, connection) {
if (err) {
self._increaseErrorCount(node);
cb(err);
return;
} else {
self._decreaseErrorCount(node);
}
connection._clusterId = node.id;
cb(null, connection);
});
};
PoolCluster.prototype._removeNode = function _removeNode(node) {
delete this._nodes[node.id];
this._clearFindCaches();
node.pool.end(_noop);
};
function getMonotonicMilliseconds() {
var ms;
if (typeof process.hrtime === 'function') {
ms = process.hrtime();
ms = ms[0] * 1e3 + ms[1] * 1e-6;
} else {
ms = process.uptime() * 1000;
}
return Math.floor(ms);
}
function isRegExp(val) {
return typeof val === 'object'
&& Object.prototype.toString.call(val) === '[object RegExp]';
}
function patternRegExp(pattern) {
if (isRegExp(pattern)) {
return pattern;
}
var source = pattern
.replace(/([.+?^=!:${}()|\[\]\/\\])/g, '\\$1')
.replace(/\*/g, '.*');
return new RegExp('^' + source + '$');
}
function _cb(err) {
if (err) {
throw err;
}
}
function _noop() {}
var ConnectionConfig = require('./ConnectionConfig');
module.exports = PoolConfig;
function PoolConfig(options) {
if (typeof options === 'string') {
options = ConnectionConfig.parseUrl(options);
}
this.acquireTimeout = (options.acquireTimeout === undefined)
? 10 * 1000
: Number(options.acquireTimeout);
this.connectionConfig = new ConnectionConfig(options);
this.waitForConnections = (options.waitForConnections === undefined)
? true
: Boolean(options.waitForConnections);
this.connectionLimit = (options.connectionLimit === undefined)
? 10
: Number(options.connectionLimit);
this.queueLimit = (options.queueLimit === undefined)
? 0
: Number(options.queueLimit);
}
PoolConfig.prototype.newConnectionConfig = function newConnectionConfig() {
var connectionConfig = new ConnectionConfig(this.connectionConfig);
connectionConfig.clientFlags = this.connectionConfig.clientFlags;
connectionConfig.maxPacketSize = this.connectionConfig.maxPacketSize;
return connectionConfig;
};
var inherits = require('util').inherits;
var Connection = require('./Connection');
var Events = require('events');
module.exports = PoolConnection;
inherits(PoolConnection, Connection);
function PoolConnection(pool, options) {
Connection.call(this, options);
this._pool = pool;
// Bind connection to pool domain
if (Events.usingDomains) {
this.domain = pool.domain;
}
// When a fatal error occurs the connection's protocol ends, which will cause
// the connection to end as well, thus we only need to watch for the end event
// and we will be notified of disconnects.
this.on('end', this._removeFromPool);
this.on('error', function (err) {
if (err.fatal) {
this._removeFromPool();
}
});
}
PoolConnection.prototype.release = function release() {
var pool = this._pool;
if (!pool || pool._closed) {
return undefined;
}
return pool.releaseConnection(this);
};
// TODO: Remove this when we are removing PoolConnection#end
PoolConnection.prototype._realEnd = Connection.prototype.end;
PoolConnection.prototype.end = function () {
console.warn(
'Calling conn.end() to release a pooled connection is ' +
'deprecated. In next version calling conn.end() will be ' +
'restored to default conn.end() behavior. Use ' +
'conn.release() instead.'
);
this.release();
};
PoolConnection.prototype.destroy = function () {
Connection.prototype.destroy.apply(this, arguments);
this._removeFromPool(this);
};
PoolConnection.prototype._removeFromPool = function _removeFromPool() {
if (!this._pool || this._pool._closed) {
return;
}
var pool = this._pool;
this._pool = null;
pool._purgeConnection(this);
};
var Connection = require('./Connection');
var PoolSelector = require('./PoolSelector');
module.exports = PoolNamespace;
/**
* PoolNamespace
* @constructor
* @param {PoolCluster} cluster The parent cluster for the namespace
* @param {string} pattern The selection pattern to use
* @param {string} selector The selector name to use
* @public
*/
function PoolNamespace(cluster, pattern, selector) {
this._cluster = cluster;
this._pattern = pattern;
this._selector = new PoolSelector[selector]();
}
PoolNamespace.prototype.getConnection = function(cb) {
var clusterNode = this._getClusterNode();
var cluster = this._cluster;
var namespace = this;
if (clusterNode === null) {
var err = null;
if (this._cluster._findNodeIds(this._pattern, true).length !== 0) {
err = new Error('Pool does not have online node.');
err.code = 'POOL_NONEONLINE';
} else {
err = new Error('Pool does not exist.');
err.code = 'POOL_NOEXIST';
}
cb(err);
return;
}
cluster._getConnection(clusterNode, function(err, connection) {
var retry = err && cluster._canRetry
&& cluster._findNodeIds(namespace._pattern).length !== 0;
if (retry) {
namespace.getConnection(cb);
return;
}
if (err) {
cb(err);
return;
}
cb(null, connection);
});
};
PoolNamespace.prototype.query = function (sql, values, cb) {
var cluster = this._cluster;
var clusterNode = this._getClusterNode();
var query = Connection.createQuery(sql, values, cb);
var namespace = this;
if (clusterNode === null) {
var err = null;
if (this._cluster._findNodeIds(this._pattern, true).length !== 0) {
err = new Error('Pool does not have online node.');
err.code = 'POOL_NONEONLINE';
} else {
err = new Error('Pool does not exist.');
err.code = 'POOL_NOEXIST';
}
process.nextTick(function () {
query.on('error', function () {});
query.end(err);
});
return query;
}
if (!(typeof sql === 'object' && 'typeCast' in sql)) {
query.typeCast = clusterNode.pool.config.connectionConfig.typeCast;
}
if (clusterNode.pool.config.connectionConfig.trace) {
// Long stack trace support
query._callSite = new Error();
}
cluster._getConnection(clusterNode, function (err, conn) {
var retry = err && cluster._canRetry
&& cluster._findNodeIds(namespace._pattern).length !== 0;
if (retry) {
namespace.query(query);
return;
}
if (err) {
query.on('error', function () {});
query.end(err);
return;
}
// Release connection based off event
query.once('end', function() {
conn.release();
});
conn.query(query);
});
return query;
};
PoolNamespace.prototype._getClusterNode = function _getClusterNode() {
var foundNodeIds = this._cluster._findNodeIds(this._pattern);
var nodeId;
switch (foundNodeIds.length) {
case 0:
nodeId = null;
break;
case 1:
nodeId = foundNodeIds[0];
break;
default:
nodeId = this._selector(foundNodeIds);
break;
}
return nodeId !== null
? this._cluster._getNode(nodeId)
: null;
};
/**
* PoolSelector
*/
var PoolSelector = module.exports = {};
PoolSelector.RR = function PoolSelectorRoundRobin() {
var index = 0;
return function(clusterIds) {
if (index >= clusterIds.length) {
index = 0;
}
var clusterId = clusterIds[index++];
return clusterId;
};
};
PoolSelector.RANDOM = function PoolSelectorRandom() {
return function(clusterIds) {
return clusterIds[Math.floor(Math.random() * clusterIds.length)];
};
};
PoolSelector.ORDER = function PoolSelectorOrder() {
return function(clusterIds) {
return clusterIds[0];
};
};
var Buffer = require('safe-buffer').Buffer;
var Crypto = require('crypto');
var Auth = exports;
function auth(name, data, options) {
options = options || {};
switch (name) {
case 'mysql_native_password':
return Auth.token(options.password, data.slice(0, 20));
default:
return undefined;
}
}
Auth.auth = auth;
function sha1(msg) {
var hash = Crypto.createHash('sha1');
hash.update(msg, 'binary');
return hash.digest('binary');
}
Auth.sha1 = sha1;
function xor(a, b) {
a = Buffer.from(a, 'binary');
b = Buffer.from(b, 'binary');
var result = Buffer.allocUnsafe(a.length);
for (var i = 0; i < a.length; i++) {
result[i] = (a[i] ^ b[i]);
}
return result;
}
Auth.xor = xor;
Auth.token = function(password, scramble) {
if (!password) {
return Buffer.alloc(0);
}
// password must be in binary format, not utf8
var stage1 = sha1((Buffer.from(password, 'utf8')).toString('binary'));
var stage2 = sha1(stage1);
var stage3 = sha1(scramble.toString('binary') + stage2);
return xor(stage3, stage1);
};
// This is a port of sql/password.c:hash_password which needs to be used for
// pre-4.1 passwords.
Auth.hashPassword = function(password) {
var nr = [0x5030, 0x5735];
var add = 7;
var nr2 = [0x1234, 0x5671];
var result = Buffer.alloc(8);
if (typeof password === 'string'){
password = Buffer.from(password);
}
for (var i = 0; i < password.length; i++) {
var c = password[i];
if (c === 32 || c === 9) {
// skip space in password
continue;
}
// nr^= (((nr & 63)+add)*c)+ (nr << 8);
// nr = xor(nr, add(mul(add(and(nr, 63), add), c), shl(nr, 8)))
nr = this.xor32(nr, this.add32(this.mul32(this.add32(this.and32(nr, [0, 63]), [0, add]), [0, c]), this.shl32(nr, 8)));
// nr2+=(nr2 << 8) ^ nr;
// nr2 = add(nr2, xor(shl(nr2, 8), nr))
nr2 = this.add32(nr2, this.xor32(this.shl32(nr2, 8), nr));
// add+=tmp;
add += c;
}
this.int31Write(result, nr, 0);
this.int31Write(result, nr2, 4);
return result;
};
Auth.randomInit = function(seed1, seed2) {
return {
max_value : 0x3FFFFFFF,
max_value_dbl : 0x3FFFFFFF,
seed1 : seed1 % 0x3FFFFFFF,
seed2 : seed2 % 0x3FFFFFFF
};
};
Auth.myRnd = function(r){
r.seed1 = (r.seed1 * 3 + r.seed2) % r.max_value;
r.seed2 = (r.seed1 + r.seed2 + 33) % r.max_value;
return r.seed1 / r.max_value_dbl;
};
Auth.scramble323 = function(message, password) {
if (!password) {
return Buffer.alloc(0);
}
var to = Buffer.allocUnsafe(8);
var hashPass = this.hashPassword(password);
var hashMessage = this.hashPassword(message.slice(0, 8));
var seed1 = this.int32Read(hashPass, 0) ^ this.int32Read(hashMessage, 0);
var seed2 = this.int32Read(hashPass, 4) ^ this.int32Read(hashMessage, 4);
var r = this.randomInit(seed1, seed2);
for (var i = 0; i < 8; i++){
to[i] = Math.floor(this.myRnd(r) * 31) + 64;
}
var extra = (Math.floor(this.myRnd(r) * 31));
for (var i = 0; i < 8; i++){
to[i] ^= extra;
}
return to;
};
Auth.xor32 = function(a, b){
return [a[0] ^ b[0], a[1] ^ b[1]];
};
Auth.add32 = function(a, b){
var w1 = a[1] + b[1];
var w2 = a[0] + b[0] + ((w1 & 0xFFFF0000) >> 16);
return [w2 & 0xFFFF, w1 & 0xFFFF];
};
Auth.mul32 = function(a, b){
// based on this example of multiplying 32b ints using 16b
// http://www.dsprelated.com/showmessage/89790/1.php
var w1 = a[1] * b[1];
var w2 = (((a[1] * b[1]) >> 16) & 0xFFFF) + ((a[0] * b[1]) & 0xFFFF) + (a[1] * b[0] & 0xFFFF);
return [w2 & 0xFFFF, w1 & 0xFFFF];
};
Auth.and32 = function(a, b){
return [a[0] & b[0], a[1] & b[1]];
};
Auth.shl32 = function(a, b){
// assume b is 16 or less
var w1 = a[1] << b;
var w2 = (a[0] << b) | ((w1 & 0xFFFF0000) >> 16);
return [w2 & 0xFFFF, w1 & 0xFFFF];
};
Auth.int31Write = function(buffer, number, offset) {
buffer[offset] = (number[0] >> 8) & 0x7F;
buffer[offset + 1] = (number[0]) & 0xFF;
buffer[offset + 2] = (number[1] >> 8) & 0xFF;
buffer[offset + 3] = (number[1]) & 0xFF;
};
Auth.int32Read = function(buffer, offset){
return (buffer[offset] << 24)
+ (buffer[offset + 1] << 16)
+ (buffer[offset + 2] << 8)
+ (buffer[offset + 3]);
};
module.exports = BufferList;
function BufferList() {
this.bufs = [];
this.size = 0;
}
BufferList.prototype.shift = function shift() {
var buf = this.bufs.shift();
if (buf) {
this.size -= buf.length;
}
return buf;
};
BufferList.prototype.push = function push(buf) {
if (!buf || !buf.length) {
return;
}
this.bufs.push(buf);
this.size += buf.length;
};
module.exports = PacketHeader;
function PacketHeader(length, number) {
this.length = length;
this.number = number;
}
var BIT_16 = Math.pow(2, 16);
var BIT_24 = Math.pow(2, 24);
var BUFFER_ALLOC_SIZE = Math.pow(2, 8);
// The maximum precision JS Numbers can hold precisely
// Don't panic: Good enough to represent byte values up to 8192 TB
var IEEE_754_BINARY_64_PRECISION = Math.pow(2, 53);
var MAX_PACKET_LENGTH = Math.pow(2, 24) - 1;
var Buffer = require('safe-buffer').Buffer;
module.exports = PacketWriter;
function PacketWriter() {
this._buffer = null;
this._offset = 0;
}
PacketWriter.prototype.toBuffer = function toBuffer(parser) {
if (!this._buffer) {
this._buffer = Buffer.alloc(0);
this._offset = 0;
}
var buffer = this._buffer;
var length = this._offset;
var packets = Math.floor(length / MAX_PACKET_LENGTH) + 1;
this._buffer = Buffer.allocUnsafe(length + packets * 4);
this._offset = 0;
for (var packet = 0; packet < packets; packet++) {
var isLast = (packet + 1 === packets);
var packetLength = (isLast)
? length % MAX_PACKET_LENGTH
: MAX_PACKET_LENGTH;
var packetNumber = parser.incrementPacketNumber();
this.writeUnsignedNumber(3, packetLength);
this.writeUnsignedNumber(1, packetNumber);
var start = packet * MAX_PACKET_LENGTH;
var end = start + packetLength;
this.writeBuffer(buffer.slice(start, end));
}
return this._buffer;
};
PacketWriter.prototype.writeUnsignedNumber = function(bytes, value) {
this._allocate(bytes);
for (var i = 0; i < bytes; i++) {
this._buffer[this._offset++] = (value >> (i * 8)) & 0xff;
}
};
PacketWriter.prototype.writeFiller = function(bytes) {
this._allocate(bytes);
for (var i = 0; i < bytes; i++) {
this._buffer[this._offset++] = 0x00;
}
};
PacketWriter.prototype.writeNullTerminatedString = function(value, encoding) {
// Typecast undefined into '' and numbers into strings
value = value || '';
value = value + '';
var bytes = Buffer.byteLength(value, encoding || 'utf-8') + 1;
this._allocate(bytes);
this._buffer.write(value, this._offset, encoding);
this._buffer[this._offset + bytes - 1] = 0x00;
this._offset += bytes;
};
PacketWriter.prototype.writeString = function(value) {
// Typecast undefined into '' and numbers into strings
value = value || '';
value = value + '';
var bytes = Buffer.byteLength(value, 'utf-8');
this._allocate(bytes);
this._buffer.write(value, this._offset, 'utf-8');
this._offset += bytes;
};
PacketWriter.prototype.writeBuffer = function(value) {
var bytes = value.length;
this._allocate(bytes);
value.copy(this._buffer, this._offset);
this._offset += bytes;
};
PacketWriter.prototype.writeLengthCodedNumber = function(value) {
if (value === null) {
this._allocate(1);
this._buffer[this._offset++] = 251;
return;
}
if (value <= 250) {
this._allocate(1);
this._buffer[this._offset++] = value;
return;
}
if (value > IEEE_754_BINARY_64_PRECISION) {
throw new Error(
'writeLengthCodedNumber: JS precision range exceeded, your ' +
'number is > 53 bit: "' + value + '"'
);
}
if (value < BIT_16) {
this._allocate(3);
this._buffer[this._offset++] = 252;
} else if (value < BIT_24) {
this._allocate(4);
this._buffer[this._offset++] = 253;
} else {
this._allocate(9);
this._buffer[this._offset++] = 254;
}
// 16 Bit
this._buffer[this._offset++] = value & 0xff;
this._buffer[this._offset++] = (value >> 8) & 0xff;
if (value < BIT_16) {
return;
}
// 24 Bit
this._buffer[this._offset++] = (value >> 16) & 0xff;
if (value < BIT_24) {
return;
}
this._buffer[this._offset++] = (value >> 24) & 0xff;
// Hack: Get the most significant 32 bit (JS bitwise operators are 32 bit)
value = value.toString(2);
value = value.substr(0, value.length - 32);
value = parseInt(value, 2);
this._buffer[this._offset++] = value & 0xff;
this._buffer[this._offset++] = (value >> 8) & 0xff;
this._buffer[this._offset++] = (value >> 16) & 0xff;
// Set last byte to 0, as we can only support 53 bits in JS (see above)
this._buffer[this._offset++] = 0;
};
PacketWriter.prototype.writeLengthCodedBuffer = function(value) {
var bytes = value.length;
this.writeLengthCodedNumber(bytes);
this.writeBuffer(value);
};
PacketWriter.prototype.writeNullTerminatedBuffer = function(value) {
this.writeBuffer(value);
this.writeFiller(1); // 0x00 terminator
};
PacketWriter.prototype.writeLengthCodedString = function(value) {
if (value === null) {
this.writeLengthCodedNumber(null);
return;
}
value = (value === undefined)
? ''
: String(value);
var bytes = Buffer.byteLength(value, 'utf-8');
this.writeLengthCodedNumber(bytes);
if (!bytes) {
return;
}
this._allocate(bytes);
this._buffer.write(value, this._offset, 'utf-8');
this._offset += bytes;
};
PacketWriter.prototype._allocate = function _allocate(bytes) {
if (!this._buffer) {
this._buffer = Buffer.alloc(Math.max(BUFFER_ALLOC_SIZE, bytes));
this._offset = 0;
return;
}
var bytesRemaining = this._buffer.length - this._offset;
if (bytesRemaining >= bytes) {
return;
}
var newSize = this._buffer.length + Math.max(BUFFER_ALLOC_SIZE, bytes);
var oldBuffer = this._buffer;
this._buffer = Buffer.alloc(newSize);
oldBuffer.copy(this._buffer);
};
var PacketHeader = require('./PacketHeader');
var BigNumber = require('bignumber.js');
var Buffer = require('safe-buffer').Buffer;
var BufferList = require('./BufferList');
var MAX_PACKET_LENGTH = Math.pow(2, 24) - 1;
var MUL_32BIT = Math.pow(2, 32);
var PACKET_HEADER_LENGTH = 4;
module.exports = Parser;
function Parser(options) {
options = options || {};
this._supportBigNumbers = options.config && options.config.supportBigNumbers;
this._buffer = Buffer.alloc(0);
this._nextBuffers = new BufferList();
this._longPacketBuffers = new BufferList();
this._offset = 0;
this._packetEnd = null;
this._packetHeader = null;
this._packetOffset = null;
this._onError = options.onError || function(err) { throw err; };
this._onPacket = options.onPacket || function() {};
this._nextPacketNumber = 0;
this._encoding = 'utf-8';
this._paused = false;
}
Parser.prototype.write = function write(chunk) {
this._nextBuffers.push(chunk);
while (!this._paused) {
var packetHeader = this._tryReadPacketHeader();
if (!packetHeader) {
break;
}
if (!this._combineNextBuffers(packetHeader.length)) {
break;
}
this._parsePacket(packetHeader);
}
};
Parser.prototype.append = function append(chunk) {
if (!chunk || chunk.length === 0) {
return;
}
// Calculate slice ranges
var sliceEnd = this._buffer.length;
var sliceStart = this._packetOffset === null
? this._offset
: this._packetOffset;
var sliceLength = sliceEnd - sliceStart;
// Get chunk data
var buffer = null;
var chunks = !(chunk instanceof Array || Array.isArray(chunk)) ? [chunk] : chunk;
var length = 0;
var offset = 0;
for (var i = 0; i < chunks.length; i++) {
length += chunks[i].length;
}
if (sliceLength !== 0) {
// Create a new Buffer
buffer = Buffer.allocUnsafe(sliceLength + length);
offset = 0;
// Copy data slice
offset += this._buffer.copy(buffer, 0, sliceStart, sliceEnd);
// Copy chunks
for (var i = 0; i < chunks.length; i++) {
offset += chunks[i].copy(buffer, offset);
}
} else if (chunks.length > 1) {
// Create a new Buffer
buffer = Buffer.allocUnsafe(length);
offset = 0;
// Copy chunks
for (var i = 0; i < chunks.length; i++) {
offset += chunks[i].copy(buffer, offset);
}
} else {
// Buffer is the only chunk
buffer = chunks[0];
}
// Adjust data-tracking pointers
this._buffer = buffer;
this._offset = this._offset - sliceStart;
this._packetEnd = this._packetEnd !== null
? this._packetEnd - sliceStart
: null;
this._packetOffset = this._packetOffset !== null
? this._packetOffset - sliceStart
: null;
};
Parser.prototype.pause = function() {
this._paused = true;
};
Parser.prototype.resume = function() {
this._paused = false;
// nextTick() to avoid entering write() multiple times within the same stack
// which would cause problems as write manipulates the state of the object.
process.nextTick(this.write.bind(this));
};
Parser.prototype.peak = function peak(offset) {
return this._buffer[this._offset + (offset >>> 0)];
};
Parser.prototype.parseUnsignedNumber = function parseUnsignedNumber(bytes) {
if (bytes === 1) {
return this._buffer[this._offset++];
}
var buffer = this._buffer;
var offset = this._offset + bytes - 1;
var value = 0;
if (bytes > 4) {
var err = new Error('parseUnsignedNumber: Supports only up to 4 bytes');
err.offset = (this._offset - this._packetOffset - 1);
err.code = 'PARSER_UNSIGNED_TOO_LONG';
throw err;
}
while (offset >= this._offset) {
value = ((value << 8) | buffer[offset]) >>> 0;
offset--;
}
this._offset += bytes;
return value;
};
Parser.prototype.parseLengthCodedString = function() {
var length = this.parseLengthCodedNumber();
if (length === null) {
return null;
}
return this.parseString(length);
};
Parser.prototype.parseLengthCodedBuffer = function() {
var length = this.parseLengthCodedNumber();
if (length === null) {
return null;
}
return this.parseBuffer(length);
};
Parser.prototype.parseLengthCodedNumber = function parseLengthCodedNumber() {
if (this._offset >= this._buffer.length) {
var err = new Error('Parser: read past end');
err.offset = (this._offset - this._packetOffset);
err.code = 'PARSER_READ_PAST_END';
throw err;
}
var bits = this._buffer[this._offset++];
if (bits <= 250) {
return bits;
}
switch (bits) {
case 251:
return null;
case 252:
return this.parseUnsignedNumber(2);
case 253:
return this.parseUnsignedNumber(3);
case 254:
break;
default:
var err = new Error('Unexpected first byte' + (bits ? ': 0x' + bits.toString(16) : ''));
err.offset = (this._offset - this._packetOffset - 1);
err.code = 'PARSER_BAD_LENGTH_BYTE';
throw err;
}
var low = this.parseUnsignedNumber(4);
var high = this.parseUnsignedNumber(4);
var value;
if (high >>> 21) {
value = BigNumber(MUL_32BIT).times(high).plus(low).toString();
if (this._supportBigNumbers) {
return value;
}
var err = new Error(
'parseLengthCodedNumber: JS precision range exceeded, ' +
'number is >= 53 bit: "' + value + '"'
);
err.offset = (this._offset - this._packetOffset - 8);
err.code = 'PARSER_JS_PRECISION_RANGE_EXCEEDED';
throw err;
}
value = low + (MUL_32BIT * high);
return value;
};
Parser.prototype.parseFiller = function(length) {
return this.parseBuffer(length);
};
Parser.prototype.parseNullTerminatedBuffer = function() {
var end = this._nullByteOffset();
var value = this._buffer.slice(this._offset, end);
this._offset = end + 1;
return value;
};
Parser.prototype.parseNullTerminatedString = function() {
var end = this._nullByteOffset();
var value = this._buffer.toString(this._encoding, this._offset, end);
this._offset = end + 1;
return value;
};
Parser.prototype._nullByteOffset = function() {
var offset = this._offset;
while (this._buffer[offset] !== 0x00) {
offset++;
if (offset >= this._buffer.length) {
var err = new Error('Offset of null terminated string not found.');
err.offset = (this._offset - this._packetOffset);
err.code = 'PARSER_MISSING_NULL_BYTE';
throw err;
}
}
return offset;
};
Parser.prototype.parsePacketTerminatedBuffer = function parsePacketTerminatedBuffer() {
var length = this._packetEnd - this._offset;
return this.parseBuffer(length);
};
Parser.prototype.parsePacketTerminatedString = function() {
var length = this._packetEnd - this._offset;
return this.parseString(length);
};
Parser.prototype.parseBuffer = function(length) {
var response = Buffer.alloc(length);
this._buffer.copy(response, 0, this._offset, this._offset + length);
this._offset += length;
return response;
};
Parser.prototype.parseString = function(length) {
var offset = this._offset;
var end = offset + length;
var value = this._buffer.toString(this._encoding, offset, end);
this._offset = end;
return value;
};
Parser.prototype.parseGeometryValue = function() {
var buffer = this.parseLengthCodedBuffer();
var offset = 4;
if (buffer === null || !buffer.length) {
return null;
}
function parseGeometry() {
var result = null;
var byteOrder = buffer.readUInt8(offset); offset += 1;
var wkbType = byteOrder ? buffer.readUInt32LE(offset) : buffer.readUInt32BE(offset); offset += 4;
switch (wkbType) {
case 1: // WKBPoint
var x = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset); offset += 8;
var y = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset); offset += 8;
result = {x: x, y: y};
break;
case 2: // WKBLineString
var numPoints = byteOrder ? buffer.readUInt32LE(offset) : buffer.readUInt32BE(offset); offset += 4;
result = [];
for (var i = numPoints; i > 0; i--) {
var x = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset); offset += 8;
var y = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset); offset += 8;
result.push({x: x, y: y});
}
break;
case 3: // WKBPolygon
var numRings = byteOrder ? buffer.readUInt32LE(offset) : buffer.readUInt32BE(offset); offset += 4;
result = [];
for (var i = numRings; i > 0; i--) {
var numPoints = byteOrder ? buffer.readUInt32LE(offset) : buffer.readUInt32BE(offset); offset += 4;
var line = [];
for (var j = numPoints; j > 0; j--) {
var x = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset); offset += 8;
var y = byteOrder ? buffer.readDoubleLE(offset) : buffer.readDoubleBE(offset); offset += 8;
line.push({x: x, y: y});
}
result.push(line);
}
break;
case 4: // WKBMultiPoint
case 5: // WKBMultiLineString
case 6: // WKBMultiPolygon
case 7: // WKBGeometryCollection
var num = byteOrder ? buffer.readUInt32LE(offset) : buffer.readUInt32BE(offset); offset += 4;
var result = [];
for (var i = num; i > 0; i--) {
result.push(parseGeometry());
}
break;
}
return result;
}
return parseGeometry();
};
Parser.prototype.reachedPacketEnd = function() {
return this._offset === this._packetEnd;
};
Parser.prototype.incrementPacketNumber = function() {
var currentPacketNumber = this._nextPacketNumber;
this._nextPacketNumber = (this._nextPacketNumber + 1) % 256;
return currentPacketNumber;
};
Parser.prototype.resetPacketNumber = function() {
this._nextPacketNumber = 0;
};
Parser.prototype.packetLength = function packetLength() {
if (!this._packetHeader) {
return null;
}
return this._packetHeader.length + this._longPacketBuffers.size;
};
Parser.prototype._combineNextBuffers = function _combineNextBuffers(bytes) {
var length = this._buffer.length - this._offset;
if (length >= bytes) {
return true;
}
if ((length + this._nextBuffers.size) < bytes) {
return false;
}
var buffers = [];
var bytesNeeded = bytes - length;
while (bytesNeeded > 0) {
var buffer = this._nextBuffers.shift();
buffers.push(buffer);
bytesNeeded -= buffer.length;
}
this.append(buffers);
return true;
};
Parser.prototype._combineLongPacketBuffers = function _combineLongPacketBuffers() {
if (!this._longPacketBuffers.size) {
return;
}
// Calculate bytes
var remainingBytes = this._buffer.length - this._offset;
var trailingPacketBytes = this._buffer.length - this._packetEnd;
// Create buffer
var buf = null;
var buffer = Buffer.allocUnsafe(remainingBytes + this._longPacketBuffers.size);
var offset = 0;
// Copy long buffers
while ((buf = this._longPacketBuffers.shift())) {
offset += buf.copy(buffer, offset);
}
// Copy remaining bytes
this._buffer.copy(buffer, offset, this._offset);
this._buffer = buffer;
this._offset = 0;
this._packetEnd = this._buffer.length - trailingPacketBytes;
this._packetOffset = 0;
};
Parser.prototype._parsePacket = function _parsePacket(packetHeader) {
this._packetEnd = this._offset + packetHeader.length;
this._packetOffset = this._offset;
if (packetHeader.length === MAX_PACKET_LENGTH) {
this._longPacketBuffers.push(this._buffer.slice(this._packetOffset, this._packetEnd));
this._advanceToNextPacket();
return;
}
this._combineLongPacketBuffers();
var hadException = true;
try {
this._onPacket(packetHeader);
hadException = false;
} catch (err) {
if (!err || typeof err.code !== 'string' || err.code.substr(0, 7) !== 'PARSER_') {
throw err; // Rethrow non-MySQL errors
}
// Pass down parser errors
this._onError(err);
hadException = false;
} finally {
this._advanceToNextPacket();
// If there was an exception, the parser while loop will be broken out
// of after the finally block. So schedule a blank write to re-enter it
// to continue parsing any bytes that may already have been received.
if (hadException) {
process.nextTick(this.write.bind(this));
}
}
};
Parser.prototype._tryReadPacketHeader = function _tryReadPacketHeader() {
if (this._packetHeader) {
return this._packetHeader;
}
if (!this._combineNextBuffers(PACKET_HEADER_LENGTH)) {
return null;
}
this._packetHeader = new PacketHeader(
this.parseUnsignedNumber(3),
this.parseUnsignedNumber(1)
);
if (this._packetHeader.number !== this._nextPacketNumber) {
var err = new Error(
'Packets out of order. Got: ' + this._packetHeader.number + ' ' +
'Expected: ' + this._nextPacketNumber
);
err.code = 'PROTOCOL_PACKETS_OUT_OF_ORDER';
err.fatal = true;
this._onError(err);
}
this.incrementPacketNumber();
return this._packetHeader;
};
Parser.prototype._advanceToNextPacket = function() {
this._offset = this._packetEnd;
this._packetHeader = null;
this._packetEnd = null;
this._packetOffset = null;
};
var Parser = require('./Parser');
var Sequences = require('./sequences');
var Packets = require('./packets');
var Stream = require('stream').Stream;
var Util = require('util');
var PacketWriter = require('./PacketWriter');
module.exports = Protocol;
Util.inherits(Protocol, Stream);
function Protocol(options) {
Stream.call(this);
options = options || {};
this.readable = true;
this.writable = true;
this._config = options.config || {};
this._connection = options.connection;
this._callback = null;
this._fatalError = null;
this._quitSequence = null;
this._handshake = false;
this._handshaked = false;
this._ended = false;
this._destroyed = false;
this._queue = [];
this._handshakeInitializationPacket = null;
this._parser = new Parser({
onError : this.handleParserError.bind(this),
onPacket : this._parsePacket.bind(this),
config : this._config
});
}
Protocol.prototype.write = function(buffer) {
this._parser.write(buffer);
return true;
};
Protocol.prototype.handshake = function handshake(options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
options = options || {};
options.config = this._config;
var sequence = this._enqueue(new Sequences.Handshake(options, callback));
this._handshake = true;
return sequence;
};
Protocol.prototype.query = function query(options, callback) {
return this._enqueue(new Sequences.Query(options, callback));
};
Protocol.prototype.changeUser = function changeUser(options, callback) {
return this._enqueue(new Sequences.ChangeUser(options, callback));
};
Protocol.prototype.ping = function ping(options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
return this._enqueue(new Sequences.Ping(options, callback));
};
Protocol.prototype.stats = function stats(options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
return this._enqueue(new Sequences.Statistics(options, callback));
};
Protocol.prototype.quit = function quit(options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
var self = this;
var sequence = this._enqueue(new Sequences.Quit(options, callback));
sequence.on('end', function () {
self.end();
});
return this._quitSequence = sequence;
};
Protocol.prototype.end = function() {
if (this._ended) {
return;
}
this._ended = true;
if (this._quitSequence && (this._quitSequence._ended || this._queue[0] === this._quitSequence)) {
this._quitSequence.end();
this.emit('end');
return;
}
var err = new Error('Connection lost: The server closed the connection.');
err.fatal = true;
err.code = 'PROTOCOL_CONNECTION_LOST';
this._delegateError(err);
};
Protocol.prototype.pause = function() {
this._parser.pause();
// Since there is a file stream in query, we must transmit pause/resume event to current sequence.
var seq = this._queue[0];
if (seq && seq.emit) {
seq.emit('pause');
}
};
Protocol.prototype.resume = function() {
this._parser.resume();
// Since there is a file stream in query, we must transmit pause/resume event to current sequence.
var seq = this._queue[0];
if (seq && seq.emit) {
seq.emit('resume');
}
};
Protocol.prototype._enqueue = function(sequence) {
if (!this._validateEnqueue(sequence)) {
return sequence;
}
if (this._config.trace) {
// Long stack trace support
sequence._callSite = sequence._callSite || new Error();
}
this._queue.push(sequence);
this.emit('enqueue', sequence);
var self = this;
sequence
.on('error', function(err) {
self._delegateError(err, sequence);
})
.on('packet', function(packet) {
sequence._timer.active();
self._emitPacket(packet);
})
.on('timeout', function() {
var err = new Error(sequence.constructor.name + ' inactivity timeout');
err.code = 'PROTOCOL_SEQUENCE_TIMEOUT';
err.fatal = true;
err.timeout = sequence._timeout;
self._delegateError(err, sequence);
});
if (sequence.constructor === Sequences.Handshake) {
sequence.on('start-tls', function () {
sequence._timer.active();
self._connection._startTLS(function(err) {
if (err) {
// SSL negotiation error are fatal
err.code = 'HANDSHAKE_SSL_ERROR';
err.fatal = true;
sequence.end(err);
return;
}
sequence._timer.active();
sequence._tlsUpgradeCompleteHandler();
});
});
sequence.on('end', function () {
self._handshaked = true;
if (!self._fatalError) {
self.emit('handshake', self._handshakeInitializationPacket);
}
});
}
sequence.on('end', function () {
self._dequeue(sequence);
});
if (this._queue.length === 1) {
this._parser.resetPacketNumber();
this._startSequence(sequence);
}
return sequence;
};
Protocol.prototype._validateEnqueue = function _validateEnqueue(sequence) {
var err;
var prefix = 'Cannot enqueue ' + sequence.constructor.name;
if (this._fatalError) {
err = new Error(prefix + ' after fatal error.');
err.code = 'PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR';
} else if (this._quitSequence) {
err = new Error(prefix + ' after invoking quit.');
err.code = 'PROTOCOL_ENQUEUE_AFTER_QUIT';
} else if (this._destroyed) {
err = new Error(prefix + ' after being destroyed.');
err.code = 'PROTOCOL_ENQUEUE_AFTER_DESTROY';
} else if ((this._handshake || this._handshaked) && sequence.constructor === Sequences.Handshake) {
err = new Error(prefix + ' after already enqueuing a Handshake.');
err.code = 'PROTOCOL_ENQUEUE_HANDSHAKE_TWICE';
} else {
return true;
}
var self = this;
err.fatal = false;
// add error handler
sequence.on('error', function (err) {
self._delegateError(err, sequence);
});
process.nextTick(function () {
sequence.end(err);
});
return false;
};
Protocol.prototype._parsePacket = function() {
var sequence = this._queue[0];
if (!sequence) {
var err = new Error('Received packet with no active sequence.');
err.code = 'PROTOCOL_STRAY_PACKET';
err.fatal = true;
this._delegateError(err);
return;
}
var Packet = this._determinePacket(sequence);
var packet = new Packet({protocol41: this._config.protocol41});
var packetName = Packet.name;
// Special case: Faster dispatch, and parsing done inside sequence
if (Packet === Packets.RowDataPacket) {
sequence.RowDataPacket(packet, this._parser, this._connection);
if (this._config.debug) {
this._debugPacket(true, packet);
}
return;
}
if (this._config.debug) {
this._parsePacketDebug(packet);
} else {
packet.parse(this._parser);
}
if (Packet === Packets.HandshakeInitializationPacket) {
this._handshakeInitializationPacket = packet;
this.emit('initialize', packet);
}
sequence._timer.active();
if (!sequence[packetName]) {
var err = new Error('Received packet in the wrong sequence.');
err.code = 'PROTOCOL_INCORRECT_PACKET_SEQUENCE';
err.fatal = true;
this._delegateError(err);
return;
}
sequence[packetName](packet);
};
Protocol.prototype._parsePacketDebug = function _parsePacketDebug(packet) {
try {
packet.parse(this._parser);
} finally {
this._debugPacket(true, packet);
}
};
Protocol.prototype._emitPacket = function(packet) {
var packetWriter = new PacketWriter();
packet.write(packetWriter);
this.emit('data', packetWriter.toBuffer(this._parser));
if (this._config.debug) {
this._debugPacket(false, packet);
}
};
Protocol.prototype._determinePacket = function(sequence) {
var firstByte = this._parser.peak();
if (sequence.determinePacket) {
var Packet = sequence.determinePacket(firstByte, this._parser);
if (Packet) {
return Packet;
}
}
switch (firstByte) {
case 0x00: return Packets.OkPacket;
case 0xfe: return Packets.EofPacket;
case 0xff: return Packets.ErrorPacket;
}
throw new Error('Could not determine packet, firstByte = ' + firstByte);
};
Protocol.prototype._dequeue = function(sequence) {
sequence._timer.stop();
// No point in advancing the queue, we are dead
if (this._fatalError) {
return;
}
this._queue.shift();
var sequence = this._queue[0];
if (!sequence) {
this.emit('drain');
return;
}
this._parser.resetPacketNumber();
this._startSequence(sequence);
};
Protocol.prototype._startSequence = function(sequence) {
if (sequence._timeout > 0 && isFinite(sequence._timeout)) {
sequence._timer.start(sequence._timeout);
}
if (sequence.constructor === Sequences.ChangeUser) {
sequence.start(this._handshakeInitializationPacket);
} else {
sequence.start();
}
};
Protocol.prototype.handleNetworkError = function(err) {
err.fatal = true;
var sequence = this._queue[0];
if (sequence) {
sequence.end(err);
} else {
this._delegateError(err);
}
};
Protocol.prototype.handleParserError = function handleParserError(err) {
var sequence = this._queue[0];
if (sequence) {
sequence.end(err);
} else {
this._delegateError(err);
}
};
Protocol.prototype._delegateError = function(err, sequence) {
// Stop delegating errors after the first fatal error
if (this._fatalError) {
return;
}
if (err.fatal) {
this._fatalError = err;
}
if (this._shouldErrorBubbleUp(err, sequence)) {
// Can't use regular 'error' event here as that always destroys the pipe
// between socket and protocol which is not what we want (unless the
// exception was fatal).
this.emit('unhandledError', err);
} else if (err.fatal) {
// Send fatal error to all sequences in the queue
var queue = this._queue;
process.nextTick(function () {
queue.forEach(function (sequence) {
sequence.end(err);
});
queue.length = 0;
});
}
// Make sure the stream we are piping to is getting closed
if (err.fatal) {
this.emit('end', err);
}
};
Protocol.prototype._shouldErrorBubbleUp = function(err, sequence) {
if (sequence) {
if (sequence.hasErrorHandler()) {
return false;
} else if (!err.fatal) {
return true;
}
}
return (err.fatal && !this._hasPendingErrorHandlers());
};
Protocol.prototype._hasPendingErrorHandlers = function() {
return this._queue.some(function(sequence) {
return sequence.hasErrorHandler();
});
};
Protocol.prototype.destroy = function() {
this._destroyed = true;
this._parser.pause();
if (this._connection.state !== 'disconnected') {
if (!this._ended) {
this.end();
}
}
};
Protocol.prototype._debugPacket = function(incoming, packet) {
var connection = this._connection;
var direction = incoming
? '<--'
: '-->';
var packetName = packet.constructor.name;
var threadId = connection && connection.threadId !== null
? ' (' + connection.threadId + ')'
: '';
// check for debug packet restriction
if (Array.isArray(this._config.debug) && this._config.debug.indexOf(packetName) === -1) {
return;
}
var packetPayload = Util.inspect(packet).replace(/^[^{]+/, '');
console.log('%s%s %s %s\n', direction, threadId, packetName, packetPayload);
};
module.exports = ResultSet;
function ResultSet(resultSetHeaderPacket) {
this.resultSetHeaderPacket = resultSetHeaderPacket;
this.fieldPackets = [];
this.eofPackets = [];
this.rows = [];
}
module.exports = require('sqlstring');
var Timers = require('timers');
module.exports = Timer;
function Timer(object) {
this._object = object;
this._timeout = null;
}
Timer.prototype.active = function active() {
if (this._timeout) {
if (this._timeout.refresh) {
this._timeout.refresh();
} else {
Timers.active(this._timeout);
}
}
};
Timer.prototype.start = function start(msecs) {
this.stop();
this._timeout = Timers.setTimeout(this._onTimeout.bind(this), msecs);
};
Timer.prototype.stop = function stop() {
if (this._timeout) {
Timers.clearTimeout(this._timeout);
this._timeout = null;
}
};
Timer.prototype._onTimeout = function _onTimeout() {
return this._object._onTimeout();
};
exports.BIG5_CHINESE_CI = 1;
exports.LATIN2_CZECH_CS = 2;
exports.DEC8_SWEDISH_CI = 3;
exports.CP850_GENERAL_CI = 4;
exports.LATIN1_GERMAN1_CI = 5;
exports.HP8_ENGLISH_CI = 6;
exports.KOI8R_GENERAL_CI = 7;
exports.LATIN1_SWEDISH_CI = 8;
exports.LATIN2_GENERAL_CI = 9;
exports.SWE7_SWEDISH_CI = 10;
exports.ASCII_GENERAL_CI = 11;
exports.UJIS_JAPANESE_CI = 12;
exports.SJIS_JAPANESE_CI = 13;
exports.CP1251_BULGARIAN_CI = 14;
exports.LATIN1_DANISH_CI = 15;
exports.HEBREW_GENERAL_CI = 16;
exports.TIS620_THAI_CI = 18;
exports.EUCKR_KOREAN_CI = 19;
exports.LATIN7_ESTONIAN_CS = 20;
exports.LATIN2_HUNGARIAN_CI = 21;
exports.KOI8U_GENERAL_CI = 22;
exports.CP1251_UKRAINIAN_CI = 23;
exports.GB2312_CHINESE_CI = 24;
exports.GREEK_GENERAL_CI = 25;
exports.CP1250_GENERAL_CI = 26;
exports.LATIN2_CROATIAN_CI = 27;
exports.GBK_CHINESE_CI = 28;
exports.CP1257_LITHUANIAN_CI = 29;
exports.LATIN5_TURKISH_CI = 30;
exports.LATIN1_GERMAN2_CI = 31;
exports.ARMSCII8_GENERAL_CI = 32;
exports.UTF8_GENERAL_CI = 33;
exports.CP1250_CZECH_CS = 34;
exports.UCS2_GENERAL_CI = 35;
exports.CP866_GENERAL_CI = 36;
exports.KEYBCS2_GENERAL_CI = 37;
exports.MACCE_GENERAL_CI = 38;
exports.MACROMAN_GENERAL_CI = 39;
exports.CP852_GENERAL_CI = 40;
exports.LATIN7_GENERAL_CI = 41;
exports.LATIN7_GENERAL_CS = 42;
exports.MACCE_BIN = 43;
exports.CP1250_CROATIAN_CI = 44;
exports.UTF8MB4_GENERAL_CI = 45;
exports.UTF8MB4_BIN = 46;
exports.LATIN1_BIN = 47;
exports.LATIN1_GENERAL_CI = 48;
exports.LATIN1_GENERAL_CS = 49;
exports.CP1251_BIN = 50;
exports.CP1251_GENERAL_CI = 51;
exports.CP1251_GENERAL_CS = 52;
exports.MACROMAN_BIN = 53;
exports.UTF16_GENERAL_CI = 54;
exports.UTF16_BIN = 55;
exports.UTF16LE_GENERAL_CI = 56;
exports.CP1256_GENERAL_CI = 57;
exports.CP1257_BIN = 58;
exports.CP1257_GENERAL_CI = 59;
exports.UTF32_GENERAL_CI = 60;
exports.UTF32_BIN = 61;
exports.UTF16LE_BIN = 62;
exports.BINARY = 63;
exports.ARMSCII8_BIN = 64;
exports.ASCII_BIN = 65;
exports.CP1250_BIN = 66;
exports.CP1256_BIN = 67;
exports.CP866_BIN = 68;
exports.DEC8_BIN = 69;
exports.GREEK_BIN = 70;
exports.HEBREW_BIN = 71;
exports.HP8_BIN = 72;
exports.KEYBCS2_BIN = 73;
exports.KOI8R_BIN = 74;
exports.KOI8U_BIN = 75;
exports.LATIN2_BIN = 77;
exports.LATIN5_BIN = 78;
exports.LATIN7_BIN = 79;
exports.CP850_BIN = 80;
exports.CP852_BIN = 81;
exports.SWE7_BIN = 82;
exports.UTF8_BIN = 83;
exports.BIG5_BIN = 84;
exports.EUCKR_BIN = 85;
exports.GB2312_BIN = 86;
exports.GBK_BIN = 87;
exports.SJIS_BIN = 88;
exports.TIS620_BIN = 89;
exports.UCS2_BIN = 90;
exports.UJIS_BIN = 91;
exports.GEOSTD8_GENERAL_CI = 92;
exports.GEOSTD8_BIN = 93;
exports.LATIN1_SPANISH_CI = 94;
exports.CP932_JAPANESE_CI = 95;
exports.CP932_BIN = 96;
exports.EUCJPMS_JAPANESE_CI = 97;
exports.EUCJPMS_BIN = 98;
exports.CP1250_POLISH_CI = 99;
exports.UTF16_UNICODE_CI = 101;
exports.UTF16_ICELANDIC_CI = 102;
exports.UTF16_LATVIAN_CI = 103;
exports.UTF16_ROMANIAN_CI = 104;
exports.UTF16_SLOVENIAN_CI = 105;
exports.UTF16_POLISH_CI = 106;
exports.UTF16_ESTONIAN_CI = 107;
exports.UTF16_SPANISH_CI = 108;
exports.UTF16_SWEDISH_CI = 109;
exports.UTF16_TURKISH_CI = 110;
exports.UTF16_CZECH_CI = 111;
exports.UTF16_DANISH_CI = 112;
exports.UTF16_LITHUANIAN_CI = 113;
exports.UTF16_SLOVAK_CI = 114;
exports.UTF16_SPANISH2_CI = 115;
exports.UTF16_ROMAN_CI = 116;
exports.UTF16_PERSIAN_CI = 117;
exports.UTF16_ESPERANTO_CI = 118;
exports.UTF16_HUNGARIAN_CI = 119;
exports.UTF16_SINHALA_CI = 120;
exports.UTF16_GERMAN2_CI = 121;
exports.UTF16_CROATIAN_MYSQL561_CI = 122;
exports.UTF16_UNICODE_520_CI = 123;
exports.UTF16_VIETNAMESE_CI = 124;
exports.UCS2_UNICODE_CI = 128;
exports.UCS2_ICELANDIC_CI = 129;
exports.UCS2_LATVIAN_CI = 130;
exports.UCS2_ROMANIAN_CI = 131;
exports.UCS2_SLOVENIAN_CI = 132;
exports.UCS2_POLISH_CI = 133;
exports.UCS2_ESTONIAN_CI = 134;
exports.UCS2_SPANISH_CI = 135;
exports.UCS2_SWEDISH_CI = 136;
exports.UCS2_TURKISH_CI = 137;
exports.UCS2_CZECH_CI = 138;
exports.UCS2_DANISH_CI = 139;
exports.UCS2_LITHUANIAN_CI = 140;
exports.UCS2_SLOVAK_CI = 141;
exports.UCS2_SPANISH2_CI = 142;
exports.UCS2_ROMAN_CI = 143;
exports.UCS2_PERSIAN_CI = 144;
exports.UCS2_ESPERANTO_CI = 145;
exports.UCS2_HUNGARIAN_CI = 146;
exports.UCS2_SINHALA_CI = 147;
exports.UCS2_GERMAN2_CI = 148;
exports.UCS2_CROATIAN_MYSQL561_CI = 149;
exports.UCS2_UNICODE_520_CI = 150;
exports.UCS2_VIETNAMESE_CI = 151;
exports.UCS2_GENERAL_MYSQL500_CI = 159;
exports.UTF32_UNICODE_CI = 160;
exports.UTF32_ICELANDIC_CI = 161;
exports.UTF32_LATVIAN_CI = 162;
exports.UTF32_ROMANIAN_CI = 163;
exports.UTF32_SLOVENIAN_CI = 164;
exports.UTF32_POLISH_CI = 165;
exports.UTF32_ESTONIAN_CI = 166;
exports.UTF32_SPANISH_CI = 167;
exports.UTF32_SWEDISH_CI = 168;
exports.UTF32_TURKISH_CI = 169;
exports.UTF32_CZECH_CI = 170;
exports.UTF32_DANISH_CI = 171;
exports.UTF32_LITHUANIAN_CI = 172;
exports.UTF32_SLOVAK_CI = 173;
exports.UTF32_SPANISH2_CI = 174;
exports.UTF32_ROMAN_CI = 175;
exports.UTF32_PERSIAN_CI = 176;
exports.UTF32_ESPERANTO_CI = 177;
exports.UTF32_HUNGARIAN_CI = 178;
exports.UTF32_SINHALA_CI = 179;
exports.UTF32_GERMAN2_CI = 180;
exports.UTF32_CROATIAN_MYSQL561_CI = 181;
exports.UTF32_UNICODE_520_CI = 182;
exports.UTF32_VIETNAMESE_CI = 183;
exports.UTF8_UNICODE_CI = 192;
exports.UTF8_ICELANDIC_CI = 193;
exports.UTF8_LATVIAN_CI = 194;
exports.UTF8_ROMANIAN_CI = 195;
exports.UTF8_SLOVENIAN_CI = 196;
exports.UTF8_POLISH_CI = 197;
exports.UTF8_ESTONIAN_CI = 198;
exports.UTF8_SPANISH_CI = 199;
exports.UTF8_SWEDISH_CI = 200;
exports.UTF8_TURKISH_CI = 201;
exports.UTF8_CZECH_CI = 202;
exports.UTF8_DANISH_CI = 203;
exports.UTF8_LITHUANIAN_CI = 204;
exports.UTF8_SLOVAK_CI = 205;
exports.UTF8_SPANISH2_CI = 206;
exports.UTF8_ROMAN_CI = 207;
exports.UTF8_PERSIAN_CI = 208;
exports.UTF8_ESPERANTO_CI = 209;
exports.UTF8_HUNGARIAN_CI = 210;
exports.UTF8_SINHALA_CI = 211;
exports.UTF8_GERMAN2_CI = 212;
exports.UTF8_CROATIAN_MYSQL561_CI = 213;
exports.UTF8_UNICODE_520_CI = 214;
exports.UTF8_VIETNAMESE_CI = 215;
exports.UTF8_GENERAL_MYSQL500_CI = 223;
exports.UTF8MB4_UNICODE_CI = 224;
exports.UTF8MB4_ICELANDIC_CI = 225;
exports.UTF8MB4_LATVIAN_CI = 226;
exports.UTF8MB4_ROMANIAN_CI = 227;
exports.UTF8MB4_SLOVENIAN_CI = 228;
exports.UTF8MB4_POLISH_CI = 229;
exports.UTF8MB4_ESTONIAN_CI = 230;
exports.UTF8MB4_SPANISH_CI = 231;
exports.UTF8MB4_SWEDISH_CI = 232;
exports.UTF8MB4_TURKISH_CI = 233;
exports.UTF8MB4_CZECH_CI = 234;
exports.UTF8MB4_DANISH_CI = 235;
exports.UTF8MB4_LITHUANIAN_CI = 236;
exports.UTF8MB4_SLOVAK_CI = 237;
exports.UTF8MB4_SPANISH2_CI = 238;
exports.UTF8MB4_ROMAN_CI = 239;
exports.UTF8MB4_PERSIAN_CI = 240;
exports.UTF8MB4_ESPERANTO_CI = 241;
exports.UTF8MB4_HUNGARIAN_CI = 242;
exports.UTF8MB4_SINHALA_CI = 243;
exports.UTF8MB4_GERMAN2_CI = 244;
exports.UTF8MB4_CROATIAN_MYSQL561_CI = 245;
exports.UTF8MB4_UNICODE_520_CI = 246;
exports.UTF8MB4_VIETNAMESE_CI = 247;
exports.UTF8_GENERAL50_CI = 253;
// short aliases
exports.ARMSCII8 = exports.ARMSCII8_GENERAL_CI;
exports.ASCII = exports.ASCII_GENERAL_CI;
exports.BIG5 = exports.BIG5_CHINESE_CI;
exports.BINARY = exports.BINARY;
exports.CP1250 = exports.CP1250_GENERAL_CI;
exports.CP1251 = exports.CP1251_GENERAL_CI;
exports.CP1256 = exports.CP1256_GENERAL_CI;
exports.CP1257 = exports.CP1257_GENERAL_CI;
exports.CP866 = exports.CP866_GENERAL_CI;
exports.CP850 = exports.CP850_GENERAL_CI;
exports.CP852 = exports.CP852_GENERAL_CI;
exports.CP932 = exports.CP932_JAPANESE_CI;
exports.DEC8 = exports.DEC8_SWEDISH_CI;
exports.EUCJPMS = exports.EUCJPMS_JAPANESE_CI;
exports.EUCKR = exports.EUCKR_KOREAN_CI;
exports.GB2312 = exports.GB2312_CHINESE_CI;
exports.GBK = exports.GBK_CHINESE_CI;
exports.GEOSTD8 = exports.GEOSTD8_GENERAL_CI;
exports.GREEK = exports.GREEK_GENERAL_CI;
exports.HEBREW = exports.HEBREW_GENERAL_CI;
exports.HP8 = exports.HP8_ENGLISH_CI;
exports.KEYBCS2 = exports.KEYBCS2_GENERAL_CI;
exports.KOI8R = exports.KOI8R_GENERAL_CI;
exports.KOI8U = exports.KOI8U_GENERAL_CI;
exports.LATIN1 = exports.LATIN1_SWEDISH_CI;
exports.LATIN2 = exports.LATIN2_GENERAL_CI;
exports.LATIN5 = exports.LATIN5_TURKISH_CI;
exports.LATIN7 = exports.LATIN7_GENERAL_CI;
exports.MACCE = exports.MACCE_GENERAL_CI;
exports.MACROMAN = exports.MACROMAN_GENERAL_CI;
exports.SJIS = exports.SJIS_JAPANESE_CI;
exports.SWE7 = exports.SWE7_SWEDISH_CI;
exports.TIS620 = exports.TIS620_THAI_CI;
exports.UCS2 = exports.UCS2_GENERAL_CI;
exports.UJIS = exports.UJIS_JAPANESE_CI;
exports.UTF16 = exports.UTF16_GENERAL_CI;
exports.UTF16LE = exports.UTF16LE_GENERAL_CI;
exports.UTF8 = exports.UTF8_GENERAL_CI;
exports.UTF8MB4 = exports.UTF8MB4_GENERAL_CI;
exports.UTF32 = exports.UTF32_GENERAL_CI;
// Manually extracted from mysql-5.5.23/include/mysql_com.h
exports.CLIENT_LONG_PASSWORD = 1; /* new more secure passwords */
exports.CLIENT_FOUND_ROWS = 2; /* Found instead of affected rows */
exports.CLIENT_LONG_FLAG = 4; /* Get all column flags */
exports.CLIENT_CONNECT_WITH_DB = 8; /* One can specify db on connect */
exports.CLIENT_NO_SCHEMA = 16; /* Don't allow database.table.column */
exports.CLIENT_COMPRESS = 32; /* Can use compression protocol */
exports.CLIENT_ODBC = 64; /* Odbc client */
exports.CLIENT_LOCAL_FILES = 128; /* Can use LOAD DATA LOCAL */
exports.CLIENT_IGNORE_SPACE = 256; /* Ignore spaces before '(' */
exports.CLIENT_PROTOCOL_41 = 512; /* New 4.1 protocol */
exports.CLIENT_INTERACTIVE = 1024; /* This is an interactive client */
exports.CLIENT_SSL = 2048; /* Switch to SSL after handshake */
exports.CLIENT_IGNORE_SIGPIPE = 4096; /* IGNORE sigpipes */
exports.CLIENT_TRANSACTIONS = 8192; /* Client knows about transactions */
exports.CLIENT_RESERVED = 16384; /* Old flag for 4.1 protocol */
exports.CLIENT_SECURE_CONNECTION = 32768; /* New 4.1 authentication */
exports.CLIENT_MULTI_STATEMENTS = 65536; /* Enable/disable multi-stmt support */
exports.CLIENT_MULTI_RESULTS = 131072; /* Enable/disable multi-results */
exports.CLIENT_PS_MULTI_RESULTS = 262144; /* Multi-results in PS-protocol */
exports.CLIENT_PLUGIN_AUTH = 524288; /* Client supports plugin authentication */
exports.CLIENT_SSL_VERIFY_SERVER_CERT = 1073741824;
exports.CLIENT_REMEMBER_OPTIONS = 2147483648;
This diff could not be displayed because it is too large.
// Manually extracted from mysql-5.5.23/include/mysql_com.h
exports.NOT_NULL_FLAG = 1; /* Field can't be NULL */
exports.PRI_KEY_FLAG = 2; /* Field is part of a primary key */
exports.UNIQUE_KEY_FLAG = 4; /* Field is part of a unique key */
exports.MULTIPLE_KEY_FLAG = 8; /* Field is part of a key */
exports.BLOB_FLAG = 16; /* Field is a blob */
exports.UNSIGNED_FLAG = 32; /* Field is unsigned */
exports.ZEROFILL_FLAG = 64; /* Field is zerofill */
exports.BINARY_FLAG = 128; /* Field is binary */
/* The following are only sent to new clients */
exports.ENUM_FLAG = 256; /* field is an enum */
exports.AUTO_INCREMENT_FLAG = 512; /* field is a autoincrement field */
exports.TIMESTAMP_FLAG = 1024; /* Field is a timestamp */
exports.SET_FLAG = 2048; /* field is a set */
exports.NO_DEFAULT_VALUE_FLAG = 4096; /* Field doesn't have default value */
exports.ON_UPDATE_NOW_FLAG = 8192; /* Field is set to NOW on UPDATE */
exports.NUM_FLAG = 32768; /* Field is num (for clients) */
// Manually extracted from mysql-5.5.23/include/mysql_com.h
/**
Is raised when a multi-statement transaction
has been started, either explicitly, by means
of BEGIN or COMMIT AND CHAIN, or
implicitly, by the first transactional
statement, when autocommit=off.
*/
exports.SERVER_STATUS_IN_TRANS = 1;
exports.SERVER_STATUS_AUTOCOMMIT = 2; /* Server in auto_commit mode */
exports.SERVER_MORE_RESULTS_EXISTS = 8; /* Multi query - next query exists */
exports.SERVER_QUERY_NO_GOOD_INDEX_USED = 16;
exports.SERVER_QUERY_NO_INDEX_USED = 32;
/**
The server was able to fulfill the clients request and opened a
read-only non-scrollable cursor for a query. This flag comes
in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands.
*/
exports.SERVER_STATUS_CURSOR_EXISTS = 64;
/**
This flag is sent when a read-only cursor is exhausted, in reply to
COM_STMT_FETCH command.
*/
exports.SERVER_STATUS_LAST_ROW_SENT = 128;
exports.SERVER_STATUS_DB_DROPPED = 256; /* A database was dropped */
exports.SERVER_STATUS_NO_BACKSLASH_ESCAPES = 512;
/**
Sent to the client if after a prepared statement reprepare
we discovered that the new statement returns a different
number of result set columns.
*/
exports.SERVER_STATUS_METADATA_CHANGED = 1024;
exports.SERVER_QUERY_WAS_SLOW = 2048;
/**
To mark ResultSet containing output parameter values.
*/
exports.SERVER_PS_OUT_PARAMS = 4096;
// Certificates for Amazon RDS
exports['Amazon RDS'] = {
ca: [
/**
* Amazon RDS global certificate 2010 to 2015
*
* CN = aws.amazon.com/rds/
* OU = RDS
* O = Amazon.com
* L = Seattle
* ST = Washington
* C = US
* P = 2010-04-05T22:44:31Z/2015-04-04T22:41:31Z
* F = 7F:09:8D:A5:7D:BB:A6:EF:7C:70:D8:CA:4E:49:11:55:7E:89:A7:D3
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIDQzCCAqygAwIBAgIJAOd1tlfiGoEoMA0GCSqGSIb3DQEBBQUAMHUxCzAJBgNV\n'
+ 'BAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdTZWF0dGxlMRMw\n'
+ 'EQYDVQQKEwpBbWF6b24uY29tMQwwCgYDVQQLEwNSRFMxHDAaBgNVBAMTE2F3cy5h\n'
+ 'bWF6b24uY29tL3Jkcy8wHhcNMTAwNDA1MjI0NDMxWhcNMTUwNDA0MjI0NDMxWjB1\n'
+ 'MQswCQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHU2Vh\n'
+ 'dHRsZTETMBEGA1UEChMKQW1hem9uLmNvbTEMMAoGA1UECxMDUkRTMRwwGgYDVQQD\n'
+ 'ExNhd3MuYW1hem9uLmNvbS9yZHMvMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n'
+ 'gQDKhXGU7tizxUR5WaFoMTFcxNxa05PEjZaIOEN5ctkWrqYSRov0/nOMoZjqk8bC\n'
+ 'med9vPFoQGD0OTakPs0jVe3wwmR735hyVwmKIPPsGlaBYj1O6llIpZeQVyupNx56\n'
+ 'UzqtiLaDzh1KcmfqP3qP2dInzBfJQKjiRudo1FWnpPt33QIDAQABo4HaMIHXMB0G\n'
+ 'A1UdDgQWBBT/H3x+cqSkR/ePSIinPtc4yWKe3DCBpwYDVR0jBIGfMIGcgBT/H3x+\n'
+ 'cqSkR/ePSIinPtc4yWKe3KF5pHcwdTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldh\n'
+ 'c2hpbmd0b24xEDAOBgNVBAcTB1NlYXR0bGUxEzARBgNVBAoTCkFtYXpvbi5jb20x\n'
+ 'DDAKBgNVBAsTA1JEUzEcMBoGA1UEAxMTYXdzLmFtYXpvbi5jb20vcmRzL4IJAOd1\n'
+ 'tlfiGoEoMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAvguZy/BDT66x\n'
+ 'GfgnJlyQwnFSeVLQm9u/FIvz4huGjbq9dqnD6h/Gm56QPFdyMEyDiZWaqY6V08lY\n'
+ 'LTBNb4kcIc9/6pc0/ojKciP5QJRm6OiZ4vgG05nF4fYjhU7WClUx7cxq1fKjNc2J\n'
+ 'UCmmYqgiVkAGWRETVo+byOSDZ4swb10=\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS global root CA 2015 to 2020
*
* CN = Amazon RDS Root CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2015-02-05T09:11:31Z/2020-03-05T09:11:31Z
* F = E8:11:88:56:E7:A7:CE:3E:5E:DC:9A:31:25:1B:93:AC:DC:43:CE:B0
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIID9DCCAtygAwIBAgIBQjANBgkqhkiG9w0BAQUFADCBijELMAkGA1UEBhMCVVMx\n'
+ 'EzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIjAgBgNVBAoM\n'
+ 'GUFtYXpvbiBXZWIgU2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtYXpvbiBSRFMx\n'
+ 'GzAZBgNVBAMMEkFtYXpvbiBSRFMgUm9vdCBDQTAeFw0xNTAyMDUwOTExMzFaFw0y\n'
+ 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n'
+ '2u6O/+YE2U+qyyxHE5Wd5oqde0oo9UUpFETJPVb6Q2cEeQib8PBAyi0i6KnF+kIV\n'
+ 'A9dY7IHSubtCK/i8wxMVqfd5GtbA8mmpeJFwnDvm9rBEsHybl08qlax9syEwsUYr\n'
+ '/40NawZfTUU=\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS global root CA 2019 to 2024
*
* CN = Amazon RDS Root 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-08-22T17:08:50Z/2024-08-22T17:08:50Z
* F = D4:0D:DB:29:E3:75:0D:FF:A6:71:C3:14:0B:BF:5F:47:8D:1C:80:96
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIEBjCCAu6gAwIBAgIJAMc0ZzaSUK51MA0GCSqGSIb3DQEBCwUAMIGPMQswCQYD\n'
+ 'VQQGEwJVUzEQMA4GA1UEBwwHU2VhdHRsZTETMBEGA1UECAwKV2FzaGluZ3RvbjEi\n'
+ 'MCAGA1UECgwZQW1hem9uIFdlYiBTZXJ2aWNlcywgSW5jLjETMBEGA1UECwwKQW1h\n'
+ 'em9uIFJEUzEgMB4GA1UEAwwXQW1hem9uIFJEUyBSb290IDIwMTkgQ0EwHhcNMTkw\n'
+ 'ODIyMTcwODUwWhcNMjQwODIyMTcwODUwWjCBjzELMAkGA1UEBhMCVVMxEDAOBgNV\n'
+ 'BAcMB1NlYXR0bGUxEzARBgNVBAgMCldhc2hpbmd0b24xIjAgBgNVBAoMGUFtYXpv\n'
+ 'biBXZWIgU2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtYXpvbiBSRFMxIDAeBgNV\n'
+ 'BAMMF0FtYXpvbiBSRFMgUm9vdCAyMDE5IENBMIIBIjANBgkqhkiG9w0BAQEFAAOC\n'
+ 'AQ8AMIIBCgKCAQEArXnF/E6/Qh+ku3hQTSKPMhQQlCpoWvnIthzX6MK3p5a0eXKZ\n'
+ 'oWIjYcNNG6UwJjp4fUXl6glp53Jobn+tWNX88dNH2n8DVbppSwScVE2LpuL+94vY\n'
+ '0EYE/XxN7svKea8YvlrqkUBKyxLxTjh+U/KrGOaHxz9v0l6ZNlDbuaZw3qIWdD/I\n'
+ '6aNbGeRUVtpM6P+bWIoxVl/caQylQS6CEYUk+CpVyJSkopwJlzXT07tMoDL5WgX9\n'
+ 'O08KVgDNz9qP/IGtAcRduRcNioH3E9v981QO1zt/Gpb2f8NqAjUUCUZzOnij6mx9\n'
+ 'McZ+9cWX88CRzR0vQODWuZscgI08NvM69Fn2SQIDAQABo2MwYTAOBgNVHQ8BAf8E\n'
+ 'BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUc19g2LzLA5j0Kxc0LjZa\n'
+ 'pmD/vB8wHwYDVR0jBBgwFoAUc19g2LzLA5j0Kxc0LjZapmD/vB8wDQYJKoZIhvcN\n'
+ 'AQELBQADggEBAHAG7WTmyjzPRIM85rVj+fWHsLIvqpw6DObIjMWokpliCeMINZFV\n'
+ 'ynfgBKsf1ExwbvJNzYFXW6dihnguDG9VMPpi2up/ctQTN8tm9nDKOy08uNZoofMc\n'
+ 'NUZxKCEkVKZv+IL4oHoeayt8egtv3ujJM6V14AstMQ6SwvwvA93EP/Ug2e4WAXHu\n'
+ 'cbI1NAbUgVDqp+DRdfvZkgYKryjTWd/0+1fS8X1bBZVWzl7eirNVnHbSH2ZDpNuY\n'
+ '0SBd8dj5F6ld3t58ydZbrTHze7JJOd8ijySAp4/kiu9UfZWuTPABzDa/DSdz9Dk/\n'
+ 'zPW4CXXvhLmE02TA9/HeCw3KEHIwicNuEfw=\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS ap-northeast-1 certificate CA 2015 to 2020
*
* CN = Amazon RDS ap-northeast-1 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2015-02-05T22:03:06Z/2020-03-05T22:03:06Z
* F = 4B:2D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AQDAgEGMBIG\n'
+ 'A1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0OBBYEFIiKM0Q6n1K4EmLxs3ZXxINbwEwR\n'
+ 'MB8GA1UdIwQYMBaAFE4C7qw+9hXITO0s9QXBj5yECEmDMA0GCSqGSIb3DQEBBQUA\n'
+ 'A4IBAQBezGbE9Rw/k2e25iGjj5n8r+M3dlye8ORfCE/dijHtxqAKasXHgKX8I9Tw\n'
+ 'JkBiGWiuzqn7gO5MJ0nMMro1+gq29qjZnYX1pDHPgsRjUX8R+juRhgJ3JSHijRbf\n'
+ '4qNJrnwga7pj94MhcLq9u0f6dxH6dXbyMv21T4TZMTmcFduf1KgaiVx1PEyJjC6r\n'
+ 'M+Ru+A0eM+jJ7uCjUoZKcpX8xkj4nmSnz9NMPog3wdOSB9cAW7XIc5mHa656wr7I\n'
+ 'WJxVcYNHTXIjCcng2zMKd1aCcl2KSFfy56sRfT7J5Wp69QSr+jq8KM55gw8uqAwi\n'
+ 'VPrXn2899T1rcTtFYFP16WXjGuc0\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS ap-northeast-2 certificate CA 2015 to 2020
*
* CN = Amazon RDS ap-northeast-2 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2015-11-06T00:05:46Z/2020-03-05T00:05:46Z
* F = 77:D9:33:4E:CE:56:FC:42:7B:29:57:8D:67:59:ED:29:4E:18:CB:6B
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIEATCCAumgAwIBAgIBTDANBgkqhkiG9w0BAQUFADCBijELMAkGA1UEBhMCVVMx\n'
+ 'EzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIjAgBgNVBAoM\n'
+ 'GUFtYXpvbiBXZWIgU2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtYXpvbiBSRFMx\n'
+ 'GzAZBgNVBAMMEkFtYXpvbiBSRFMgUm9vdCBDQT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WKr+CYnniNxCQLfFtXYJsfOdVBzK3xNL+Z3ucOQRhr2helWc\n'
+ 'CDQgwfhP1+3pRVKqHvWCPC4R3fT7RZHuRmZ38kndv476GxRntejh+ePffif78bFI\n'
+ '3rIZCPBGobrrUMycafSbyXteoGca/kA+/IqrAPlk0pWQ4aEL0yTWN2h2dnjoD7oX\n'
+ 'byIuL/g9AGRh97+ssn7D6bDRPTbW\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS ap-southeast-1 certificate CA 2015 to 2020
*
* CN = Amazon RDS ap-southeast-1 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2015-02-05T22:03:19Z/2020-03-05T22:03:19Z
* F = 0E:EC:5D:BD:F9:80:EE:A9:A0:8D:81:AC:37:D9:8D:34:1C:CD:27:D1
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIEATCCAumgAwIBAgIBRTANBgkqhkiG9w0BAQUFADCBijELMAkGA1UEBhMCVVMx\n'
+ 'EzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIjAgBgNVBAoM\n'
+ 'GUFtYXpvbiBXZWIgU2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtYXpvbiBSRFMx\n'
+ 'GzAZBgNVBAMMEkFtYXpvbiBSRFMgUm9vdCBDQTAeFw0xNTAyMDUyMjAzMTlaFw0y\n'
+ 'MDAzMDUyMjAzMTlaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2FzaGluZ3Rv\n'
+ 'bjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIFdlYiBTZXJ2aWNl\n'
+ 'cywgSW5jLjETMBEGA1UECwwKQW1hem9uIFJEUzElMCMGA1UEAwwcQW1hem9uIFJE\n'
+ 'UyBhcC1zb3V0aGVhc3QtMSBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC\n'
+ 'ggEBANaXEl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XO\n'
+ 'n2AX7gMouo3mtv34iDTZ0h6YCGkCAwEAAaNmMGQwDgYDVR0PAQH/BAQDAgEGMBIG\n'
+ 'A1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0OBBYEFIlQnY0KHYWn1jYumSdJYfwj/Nfw\n'
+ 'MB8GA1UdIwQYMBaAFE4C7qw+9hXITO0s9QXBj5yECEmDMA0GCSqGSIb3DQEBBQUA\n'
+ 'A4IBAQA0wVU6/l41cTzHc4azc4CDYY2Wd90DFWiH9C/mw0SgToYfCJ/5Cfi0NT/Y\n'
+ 'PRnk3GchychCJgoPA/k9d0//IhYEAIiIDjyFVgjbTkKV3sh4RbdldKVOUB9kumz/\n'
+ 'ZpShplsGt3z4QQiVnKfrAgqxWDjR0I0pQKkxXa6Sjkicos9LQxVtJ0XA4ieG1E7z\n'
+ 'zJr+6t80wmzxvkInSaWP3xNJK9azVRTrgQZQlvkbpDbExl4mNTG66VD3bAp6t3Wa\n'
+ 'B49//uDdfZmPkqqbX+hsxp160OH0rxJppwO3Bh869PkDnaPEd/Pxw7PawC+li0gi\n'
+ 'NRV8iCEx85aFxcyOhqn0WZOasxee\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS eu-central-1 certificate CA 2015 to 2020
*
* CN = Amazon RDS eu-central-1 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2015-02-05T22:03:31Z/2020-03-05T22:03:31Z
* F = 94:B4:DF:B9:6D:7E:F7:C3:B7:BF:51:E9:A6:B7:44:A0:D0:82:11:84
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIID/zCCAuegAwIBAgIBRzANBgkqhkiG9w0BAQUFADCBijELMAkGA1UEBhMCVVMx\n'
+ 'EzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIjAgBgNVBAoM\n'
+ 'GUFtYXpvbiBXZWIgU2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtY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pl/tQkbpco9Jh1HDs558D5NnZQxNqH5qXQ3Mm\n'
+ 'uPgCw0pYcPOa7bhs07i+MdVwPBsX27CFDtsgAIru8HvKxY1oTZrWnyIRo93tt/pk\n'
+ 'WuItVMVHjaQZVfTCow0aDUbte6Vlw82KjUFq+n2NMSCJDiDKsDDHT6BJc4AJHIq3\n'
+ '/4Z52MSC9KMr0yAaaoWfW/yMEj9LliQauAgwVjArF4q78rxpfKTG9Rfd8U1BZANP\n'
+ '7FrFMN0ThjfA1IvmOYcgskY5bQ==\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS eu-west-1 certificate CA 2015 to 2020
*
* CN = Amazon RDS eu-west-1 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2015-02-05T22:03:35Z/2020-03-05T22:03:35Z
* F = 1A:95:F0:43:82:D2:5D:A6:AD:F5:13:27:0B:40:8A:72:D9:92:F3:E0
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIID/DCCAuSgAwIBAgIBSDANBgkqhkiG9w0BAQUFADCBijELMAkGA1UEBhMCVVMx\n'
+ 'EzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIjAgBgNVBAoM\n'
+ 'GUFtYXpvbiBXZWIgU2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtYXpvbiBSRFMx\n'
+ 'GzAZBgNVBAMMEkFtYXpvbiBSRFMgUm9vdCBDQTAeFw0xNTAyMDUyMjAzMzVaFw0y\n'
+ 'MDAzMDUyMjAzMzVaMIGPMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2FzaGluZ3Rv\n'
+ 'bjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIFdlYiBTZXJ2aWNl\n'
+ 'cywgSW5jLjETMBEGA1UECwwKQW1hem9uIFJEUzEgMB4GA1UEAwwXQW1hem9uIFJE\n'
+ 'UyBldS13ZXN0LTEgQ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015 to 2020
*
* CN = Amazon RDS sa-east-1 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2015-02-05T22:03:40Z/2020-03-05T22:03:40Z
* F = 32:10:3D:FA:6D:42:F5:35:98:40:15:F4:4C:74:74:27:CB:CE:D4:B5
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIID/DCCAuSgAwIBAgIBSTANBgkqhkiG9w0BAQUFADCBijELMAkGA1UEBhMCVVMx\n'
+ 'EzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIjAgBgNVBAoM\n'
+ 'GUFtYXpvbiBXZWIgU2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtYXpvbiBSRFMx\n'
+ 'GzAZBgNVBAMMEkFtYXpvbiBSRFMgUm9vdCBDQTAeFw0xNTAyMDUyMjAzNDBaFw0y\n'
+ 'MDAzMDUyMjAzNDBaMIGPMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2FzaGluZ3Rv\n'
+ 'bjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIFdlYiBTZXJ2aWNl\n'
+ 'cywgSW5jLjETMBEGA1UECwwKQW1hem9uIFJEUzEgMB4GA1UEAwwXQW1hem9uIFJE\n'
+ 'UyBzYS1lYXN0LTEgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCU\n'
+ 'X4OBnQ5xA6TLJAiFEI6l7bUWjoVJBa/VbMdCCSs2i2dOKmqUaXu2ix2zcPILj3lZ\n'
+ 'GMk3d/2zvTK/cKhcFrewHUBamTeVHdEmynhMQamqNmkM4ptYzFcvEUw1TGxHT4pV\n'
+ 'Q6gSN7+/AJewQvyHexHo8D0+LDN0/Wa9mRm4ixCYH2CyYYJNKaZt9+EZfNu+PPS4\n'
+ '8iB0TWH0DgQkbWMBfCRgolLLitAZklZ4dvdlEBS7evN1/7ttBxUK6SvkeeSx3zBl\n'
+ 'ww3BlXqc3bvTQL0A+RRysaVyFbvtp9domFaDKZCpMmDFAN/ntx215xmQdrSt+K3F\n'
+ 'cXdGQYHx5q410CAclGnbAgMBAAGjZjBkMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMB\n'
+ 'Af8ECDAGAQH/AgEAMB0GA1UdDgQWBBT6iVWnm/uakS+tEX2mzIfw+8JL0zAfBgNV\n'
+ 'HSMEGDAWgBROAu6sPvYVyEztLPUFwY+chAhJgzANBgkqhkiG9w0BAQUFAAOCAQEA\n'
+ 'FmDD+QuDklXn2EgShwQxV13+txPRuVdOSrutHhoCgMwFWCMtPPtBAKs6KPY7Guvw\n'
+ 'DpJoZSehDiOfsgMirjOWjvfkeWSNvKfjWTVneX7pZD9W5WPnsDBvTbCGezm+v87z\n'
+ 'b+ZM2ZMo98m/wkMcIEAgdSKilR2fuw8rLkAjhYFfs0A7tDgZ9noKwgHvoE4dsrI0\n'
+ 'KZYco6DlP/brASfHTPa2puBLN9McK3v+h0JaSqqm5Ro2Bh56tZkQh8AWy/miuDuK\n'
+ '3+hNEVdxosxlkM1TPa1DGj0EzzK0yoeerXuH2HX7LlCrrxf6/wdKnjR12PMrLQ4A\n'
+ 'pCqkcWw894z6bV9MAvKe6A==\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS us-east-1 certificate CA 2015 to 2020
*
* CN = Amazon RDS us-east-1 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2015-02-05T21:54:04Z/2020-03-05T21:54:04Z
* F = 34:47:8A:90:8A:83:AE:45:DC:B6:16:76:D2:35:EC:E9:75:C6:2C:63
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIID/DCCAuSgAwIBAgIBQzANBgkqhkiG9w0BAQUFADCBijELMAkGA1UEBhMCVVMx\n'
+ 'EzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIjAgBgNVBAoM\n'
+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HA\n'
+ 'Pc7nxAF5gPpuzatx0OTLPcmYucFmfqT/1qA5WlgCnMNtczyNMH97lKFTNV7Njtek\n'
+ 'jWEzAEQSyEWrkNpNlC4j6kMYyPzVXQeXUeZTgJ9FNnVZqmvfjip2N22tawMjrCn5\n'
+ '7KN/zN65EwY2oO9XsaTwwWmBu3NrDdMbzJnbxoWcFWj4RBwanR1XjQOVNhDwmCOl\n'
+ '/1Et13b8CPyj69PC8BOVU6cfTSx8WUVy0qvYOKHNY9Bqa5BDnIL3IVmUkeTlM1mt\n'
+ 'enRpyBj+Bk9rh/ICdiRKmA==\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS us-west-1 certificate CA 2015 to 2020
*
* CN = Amazon RDS us-west-1 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2015-02-05T22:03:45Z/2020-03-05T22:03:45Z
* F = EF:94:2F:E3:58:0E:09:D6:79:C2:16:97:91:FB:37:EA:D7:70:A8:4B
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIID/DCCAuSgAwIBAgIBSjANBgkqhkiG9w0BAQUFADCBijELMAkGA1UEBhMCVVMx\n'
+ 'EzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIjAgBgNVBAoM\n'
+ 'GUFtYXpvbiBXZWIgU2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtYXpvbiBSRFMx\n'
+ 'GzAZBgNVBAMMEkFtYXpvbiBSRFMgUm9vdCBDQTAeFw0xNTAyMDUyMjAzNDVaFw0y\n'
+ 'MDAzMDUyMjAzNDVaMIGPMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2FzaGluZ3Rv\n'
+ 'bjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIFdlYiBTZXJ2aWNl\n'
+ 'cywgSW5jLjETMBEGA1UECwwKQW1hem9uIFJEUzEgMB4GA1UEAwwXQW1hem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TIFICATE-----\n',
/**
* Amazon RDS us-west-2 certificate CA 2015 to 2020
*
* CN = Amazon RDS us-west-2 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2015-02-05T22:03:50Z/2020-03-05T22:03:50Z
* F = 94:2C:A8:B0:23:48:17:F0:CD:2F:19:7F:C1:E0:21:7C:65:79:13:3A
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIID/DCCAuSgAwIBAgIBSzANBgkqhkiG9w0BAQUFADCBijELMAkGA1UEBhMCVVMx\n'
+ 'EzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIjAgBgNVBAoM\n'
+ 'GUFtYXpvbiBXZWIgU2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtYXpvbiBSRFMx\n'
+ 'GzAZBgNVBAMMEkFtYXpvbiBSRFMgUm9vdCBDQTAeFw0xNTAyMDUyMjAzNTBaFw0y\n'
+ 'MDAzMDUyMjAzNTBaMIGPMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2FzaGluZ3Rv\n'
+ 'bjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIFdlYiBTZXJ2aWNl\n'
+ 'cywgSW5jLjETMBEGA1UECwwKQW1hem9uIFJEUzEgMB4GA1UEAwwXQW1hem9uIFJE\n'
+ 'UyB1cy13ZXN0LTIgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDM\n'
+ 'H58SR48U6jyERC1vYTnub34smf5EQVXyzaTmspWGWGzT31NLNZGSDFaa7yef9kdO\n'
+ 'mzJsgebR5tXq6LdwlIoWkKYQ7ycUaadtVKVYdI40QcI3cHn0qLFlg2iBXmWp/B+i\n'
+ 'Z34VuVlCh31Uj5WmhaBoz8t/GRqh1V/aCsf3Wc6jCezH3QfuCjBpzxdOOHN6Ie2v\n'
+ 'xX09O5qmZTvMoRBAvPkxdaPg/Mi7fxueWTbEVk78kuFbF1jHYw8U1BLILIAhcqlq\n'
+ 'x4u8nl73t3O3l/soNUcIwUDK0/S+Kfqhwn9yQyPlhb4Wy3pfnZLJdkyHldktnQav\n'
+ '9TB9u7KH5Lk0aAYslMLxAgMBAAGjZjBkMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMB\n'
+ 'Af8ECDAGAQH/AgEAMB0GA1UdDgQWBBT8roM4lRnlFHWMPWRz0zkwFZog1jAfBgNV\n'
+ 'HSMEGDAWgBROAu6sPvYVyEztLPUFwY+chAhJgzANBgkqhkiG9w0BAQUFAAOCAQEA\n'
+ 'JwrxwgwmPtcdaU7O7WDdYa4hprpOMamI49NDzmE0s10oGrqmLwZygcWU0jT+fJ+Y\n'
+ 'pJe1w0CVfKaeLYNsOBVW3X4ZPmffYfWBheZiaiEflq/P6t7/Eg81gaKYnZ/x1Dfa\n'
+ 'sUYkzPvCkXe9wEz5zdUTOCptDt89rBR9CstL9vE7WYUgiVVmBJffWbHQLtfjv6OF\n'
+ 'NMb0QME981kGRzc2WhgP71YS2hHd1kXtsoYP1yTu4vThSKsoN4bkiHsaC1cRkLoy\n'
+ '0fFA4wpB3WloMEvCDaUvvH1LZlBXTNlwi9KtcwD4tDxkkBt4tQczKLGpQ/nF/W9n\n'
+ '8YDWk3IIc1sd0bkZqoau2Q==\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS ap-south-1 certificate CA 2016 to 2020
*
* CN = Amazon RDS ap-south-1 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2016-05-03T21:29:22Z/2020-03-05T21:29:22Z
* F = F3:A3:C2:52:D9:82:20:AC:8C:62:31:2A:8C:AD:5D:7B:1C:31:F1:DD
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIID/TCCAuWgAwIBAgIBTTANBgkqhkiG9w0BAQsFADCBijELMAkGA1UEBhMCVVMx\n'
+ 'EzARBgNVBAgMCldhc2hpbmd0b24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DqoSQOky52QBwsGaj+xWYHW5Gm7EvCqvQuhWMkeBuD6YJmMvNyA9G\n'
+ 'I2lh6/o+sUk/RIsbYbxPRdhNPTOgDR9zsNRw6qxaHztq/CEC+mxDCLa3O1hHBaDV\n'
+ 'BmB3nCZb93BvO0EQSEk7aytKq/f+sjyxqOcs385gintdHGU9uM7gTZHnU9vByJsm\n'
+ '/TL07Miq67X0NlhIoo3jAk+xHaeKJdxdKATQp0448P5cY20q4b8aMk1twcNaMvCP\n'
+ 'dG4M5doaoUA8OQ/0ukLLae/LBxLeTw04q1/a2SyFaVUX2Twbb1S3xVWwLA8vsyGr\n'
+ 'igXx7B5GgP+IHb6DTjPJAi0=\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS us-east-2 certificate CA 2016 to 2020
*
* CN = Amazon RDS us-east-2 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2016-08-11T19:58:45Z/2020-03-05T19:58:45Z
* F = 9B:78:E3:64:7F:74:BC:B2:52:18:CF:13:C3:62:B8:35:9D:3D:5F:B6
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIID/DCCAuSgAwIBAgIBTjANBgkqhkiG9w0BAQsFADCBijELMAkGA1UEBhMCVVMx\n'
+ 'EzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIjAgBgNVBAoM\n'
+ 'GUFtYXpvbiBXZWIgU2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtYXpvbiBSRFMx\n'
+ 'GzAZBgNVBAMMEkFtYXpvbiBSRFMgUm9vdCBDQTAeFw0xNjA4MTExOTU4NDVaFw0y\n'
+ 'MDAzMDUxOTU4NDVaMIGPMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2FzaGluZ3Rv\n'
+ 'bjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIFdlYiBTZXJ2aWNl\n'
+ 'cywgSW5jLj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'fl/EGSZ0TEvZkENrXcPlVA==\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS ca-central-1 certificate CA 2016 to 2020
*
* CN = Amazon RDS ca-central-1 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2016-09-15T00:10:11Z/2020-03-05T00:10:11Z
* F = D7:E0:16:AB:8A:0B:63:9F:67:1F:16:87:42:F4:0A:EE:73:A6:FC:04
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIID/zCCAuegAwIBAgIBTzANBgkqhkiG9w0BAQsFADCBijELMAkGA1UEBhMCVVMx\n'
+ 'EzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIjAgBgNVBAoM\n'
+ 'GUFtYXpvbiBXZWIgU2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtYXpvbiBSRFMx\n'
+ 'GzAZBgNVBAMMEkFtYXpvbiBSRFMgUm9vdCBDQTAeFw0xNjA5MTUwMDEwMTFaFw0y\n'
+ 'MDAzMDUwMDEwMTFaMIGSMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2FzaGluZ3Rv\n'
+ 'bjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIFdlYiBTZXJ2aWNl\n'
+ 'cywgSW5jLjETMBEGA1UECwwKQW1hem9uIFJEUzEjMCEGA1UEAwwaQW1hem9uIFJE\n'
+ 'UyBjYS1jZW50cmFsLTEgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\n'
+ 'AQCZYI/iQ6DrS3ny3t1EwX1wAD+3LMgh7Fd01EW5LIuaK2kYIIQpsVKhxLCit/V5\n'
+ 'AGc/1qiJS1Qz9ODLTh0Na6bZW6EakRzuHJLe32KJtoFYPC7Z09UqzXrpA/XL+1hM\n'
+ 'P0ZmCWsU7Nn/EmvfBp9zX3dZp6P6ATrvDuYaVFr+SA7aT3FXpBroqBS1fyzUPs+W\n'
+ 'c6zTR6+yc4zkHX0XQxC5RH6xjgpeRkoOajA/sNo7AQF7KlWmKHbdVF44cvvAhRKZ\n'
+ 'XaoVs/C4GjkaAEPTCbopYdhzg+KLx9eB2BQnYLRrIOQZtRfbQI2Nbj7p3VsRuOW1\n'
+ 'tlcks2w1Gb0YC6w6SuIMFkl1AgMBAAGjZjBkMA4GA1UdDwEB/wQEAwIBBjASBgNV\n'
+ 'HRMBAf8ECDAGAQH/AgEAMB0GA1UdDgQWBBToYWxE1lawl6Ks6NsvpbHQ3GKEtzAf\n'
+ 'BgNVHSMEGDAWgBROAu6sPvYVyEztLPUFwY+chAhJgzANBgkqhkiG9w0BAQsFAAOC\n'
+ 'AQEAG/8tQ0ooi3hoQpa5EJz0/E5VYBsAz3YxA2HoIonn0jJyG16bzB4yZt4vNQMA\n'
+ 'KsNlQ1uwDWYL1nz63axieUUFIxqxl1KmwfhsmLgZ0Hd2mnTPIl2Hw3uj5+wdgGBg\n'
+ 'agnAZ0bajsBYgD2VGQbqjdk2Qn7Fjy3LEWIvGZx4KyZ99OJ2QxB7JOPdauURAtWA\n'
+ 'DKYkP4LLJxtj07DSzG8kuRWb9B47uqUD+eKDIyjfjbnzGtd9HqqzYFau7EX3HVD9\n'
+ '9Qhnjl7bTZ6YfAEZ3nH2t3Vc0z76XfGh47rd0pNRhMV+xpok75asKf/lNh5mcUrr\n'
+ 'VKwflyMkQpSbDCmcdJ90N2xEXQ==\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS eu-west-2 certificate CA 2016 to 2020
*
* CN = Amazon RDS eu-west-2 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2016-10-10T17:44:42Z/2020-03-05T17:44:42Z
* F = 47:79:51:9F:FF:07:D3:F4:27:D3:AB:64:56:7F:00:45:BB:84:C1:71
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIID/DCCAuSgAwIBAgIBUDANBgkqh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6sPvYVyEztLPUFwY+chAhJgzANBgkqhkiG9w0BAQsFAAOCAQEA\n'
+ 'UyCUQjsF3nUAABjfEZmpksTuUo07aT3KGYt+EMMFdejnBQ0+2lJJFGtT+CDAk1SD\n'
+ 'RSgfEBon5vvKEtlnTf9a3pv8WXOAkhfxnryr9FH6NiB8obISHNQNPHn0ljT2/T+I\n'
+ 'Y6ytfRvKHa0cu3V0NXbJm2B4KEOt4QCDiFxUIX9z6eB4Kditwu05OgQh6KcogOiP\n'
+ 'JesWxBMXXGoDC1rIYTFO7szwDyOHlCcVXJDNsTJhc32oDWYdeIbW7o/5I+aQsrXZ\n'
+ 'C96HykZcgWzz6sElrQxUaT3IoMw/5nmw4uWKKnZnxgI9bY4fpQwMeBZ96iHfFxvH\n'
+ 'mqfEEuC7uUoPofXdBp2ObQ==\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS us-gov-west-1 CA 2017 to 2022
*
* CN = Amazon RDS us-gov-west-1 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2017-05-19T22:31:19Z/2022-05-18T12:00:00Z
* F = 77:55:8C:C4:5E:71:1F:1B:57:E3:DA:6E:5B:74:27:12:4E:E8:69:E8
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIECjCCAvKgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwgZMxCzAJBgNVBAYTAlVT\n'
+ 'MRAwDgYDVQQHDAdTZWF0dGxlMRMwEQYDVQQIDApXYXNoaW5ndG9uMSIwIAYDVQQK\n'
+ 'DBlBbWF6b24gV2ViIFNlcnZpY2VzLCBJbmMuMRMwEQYDVQQLDApBbWF6b24gUkRT\n'
+ 'MSQwIgYDVQQDDBtBbWF6b24gUkRTIEdvdkNsb3VkIFJvb3QgQ0EwHhcNMTcwNTE5\n'
+ 'MjIzMTE5WhcNMjIwNTE4MTIwMDAwWjCBkzELMAkGA1UEBhMCVVMxEzARBgNVBAgM\n'
+ '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M0tHI15Kjch\n'
+ 'RuUCvyQecy2ZFNAa3jmd5ycNdL63RWe8oayRBpQBxPPCbHfILxGZEdJbCH9aJ2D/\n'
+ 'l8oHIDnvOLdv7/cBjyYuvmprgPtu3QEkbre5Hln/\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS eu-west-3 certificate CA 2017 to 2020
*
* CN = Amazon RDS eu-west-3 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2017-08-25T21:39:26Z/2020-03-05T21:39:26Z
* F = FD:35:A7:84:60:68:98:00:12:54:ED:34:26:8C:66:0F:72:DD:B2:F4
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIID/DCCAuSgAwIBAgIBUTANBgkqhkiG9w0BAQsFADCBijELMAkGA1UEBhMCVVMx\n'
+ 'EzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIjAgBgNVBAoM\n'
+ 'GUFtYXpvbiBXZWIgU2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtYXpvbiBSRFMx\n'
+ 'GzAZBgNVBAMMEkFtYXpvbiBSRFMgUm9vdCBDQTAeFw0xNzA4MjUyMTM5MjZaFw0y\n'
+ 'MDAzMDUyMTM5MjZaMIGPMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2FzaGluZ3Rv\n'
+ 'bjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIFdlYiBTZXJ2aWNl\n'
+ 'cywgSW5jLjETMBEGA1UECwwKQW1hem9uIFJEUzEgMB4GA1UEAwwXQW1hem9uIFJE\n'
+ 'UyBldS13ZXN0LTMgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC+\n'
+ 'xmlEC/3a4cJH+UPwXCE02lC7Zq5NHd0dn6peMeLN8agb6jW4VfSY0NydjRj2DJZ8\n'
+ 'K7wV6sub5NUGT1NuFmvSmdbNR2T59KX0p2dVvxmXHHtIpQ9Y8Aq3ZfhmC5q5Bqgw\n'
+ 'tMA1xayDi7HmoPX3R8kk9ktAZQf6lDeksCvok8idjTu9tiSpDiMwds5BjMsWfyjZ\n'
+ 'd13PTGGNHYVdP692BSyXzSP1Vj84nJKnciW8tAqwIiadreJt5oXyrCXi8ekUMs80\n'
+ 'cUTuGm3aA3Q7PB5ljJMPqz0eVddaiIvmTJ9O3Ez3Du/HpImyMzXjkFaf+oNXf/Hx\n'
+ '/EW5jCRR6vEiXJcDRDS7AgMBAAGjZjBkMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMB\n'
+ 'Af8ECDAGAQH/AgEAMB0GA1UdDgQWBBRZ9mRtS5fHk3ZKhG20Oack4cAqMTAfBgNV\n'
+ 'HSMEGDAWgBROAu6sPvYVyEztLPUFwY+chAhJgzANBgkqhkiG9w0BAQsFAAOCAQEA\n'
+ 'F/u/9L6ExQwD73F/bhCw7PWcwwqsK1mypIdrjdIsu0JSgwWwGCXmrIspA3n3Dqxq\n'
+ 'sMhAJD88s9Em7337t+naar2VyLO63MGwjj+vA4mtvQRKq8ScIpiEc7xN6g8HUMsd\n'
+ 'gPG9lBGfNjuAZsrGJflrko4HyuSM7zHExMjXLH+CXcv/m3lWOZwnIvlVMa4x0Tz0\n'
+ 'A4fklaawryngzeEjuW6zOiYCzjZtPlP8Fw0SpzppJ8VpQfrZ751RDo4yudmPqoPK\n'
+ '5EUe36L8U+oYBXnC5TlYs9bpVv9o5wJQI5qA9oQE2eFWxF1E0AyZ4V5sgGUBStaX\n'
+ 'BjDDWul0wSo7rt1Tq7XpnA==\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS ap-northeast-3 certificate CA 2017 to 2020
*
* CN = Amazon RDS ap-northeast-3 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2017-12-01T00:55:42Z/2020-03-05T00:55:42Z
* F = C0:C7:D4:B3:91:40:A0:77:43:28:BF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wEB/wQIMAYBAf8CAQAwHQYDVR0OBBYEFETv7ELNplYy/xTeIOInl6nzeiHg\n'
+ 'MB8GA1UdIwQYMBaAFE4C7qw+9hXITO0s9QXBj5yECEmDMA0GCSqGSIb3DQEBBQUA\n'
+ 'A4IBAQCpKxOQcd0tEKb3OtsOY8q/MPwTyustGk2Rt7t9G68idADp8IytB7M0SDRo\n'
+ 'wWZqynEq7orQVKdVOanhEWksNDzGp0+FPAf/KpVvdYCd7ru3+iI+V4ZEp2JFdjuZ\n'
+ 'Zz0PIjS6AgsZqE5Ri1J+NmfmjGZCPhsHnGZiBaenX6K5VRwwwmLN6xtoqrrfR5zL\n'
+ 'QfBeeZNJG6KiM3R/DxJ5rAa6Fz+acrhJ60L7HprhB7SFtj1RCijau3+ZwiGmUOMr\n'
+ 'yKlMv+VgmzSw7o4Hbxy1WVrA6zQsTHHSGf+vkQn2PHvnFMUEu/ZLbTDYFNmTLK91\n'
+ 'K6o4nMsEvhBKgo4z7H1EqqxXhvN2\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS GovCloud Root CA 2017 to 2022
*
* CN = Amazon RDS GovCloud Root CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2017-05-19T22:29:11Z/2022-05-18T22:29:11Z
* F = A3:61:F9:C9:A2:5B:91:FE:73:A6:52:E3:59:14:8E:CE:35:12:0F:FD
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIEDjCCAvagAwIBAgIJAMM61RQn3/kdMA0GCSqGSIb3DQEBCwUAMIGTMQswCQYD\n'
+ 'VQQGEwJVUzEQMA4GA1UEBwwHU2VhdHRsZTETMBEGA1UECAwKV2FzaGluZ3RvbjEi\n'
+ 'MCAGA1UECgwZQW1hem9uIFdlYiBTZXJ2aWNlcywgSW5jLjETMBEGA1UECwwKQW1h\n'
+ 'em9uIFJEUzEkMCIGA1UEAwwbQW1hem9uIFJEUyBHb3ZDbG91ZCBSb290IENBM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UUn0BK3okhiXS0i+NloMyaBCL7vk\n'
+ 'kDwkHwEqflRKfZ9/oFTcCfoiHPA7AdBtaPVr0/Kj9L7k+ouz122huqG5KqX0Zpo8\n'
+ 'S0IGvcd2FZjNSNPttNAK7YuBVsZ0m2nIH1SLp//00v7yAHIgytQwwB17PBcp4NXD\n'
+ 'pCfTa27ng9mMMC2YLqWQpW4TkqjDin2ZC+5X/mbrjzTvVg==\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS ap-east-1 certificate CA 2019 to 2022
*
* CN = Amazon RDS ap-east-1 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-02-17T02:47:00Z/2022-06-01T12:00:00Z
* F = BC:F8:70:75:1F:93:3F:A7:82:86:67:63:A8:86:1F:A4:E8:07:CE:06
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIEBzCCAu+gAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwgZQxCzAJBgNVBAYTAlVT\n'
+ 'MRAwDgYDVQQHDAdTZWF0dGxlMRMwEQYDVQQIDApXYXNoaW5ndG9uMSIwIAYDVQQK\n'
+ 'DBlBbWF6b24gV2ViIFNlcnZpY2VzLCBJbmMuMRMwEQYDVQQLDApBbWF6b24gUkRT\n'
+ 'MSUwIwYDVQQDDBxBbWF6b24gUkRTIGFwLWVhc3QtMSBSb290IENBMB4XDTE5MDIx\n'
+ 'NzAyNDcwMFoXDTIyMDYwMTEyMDAwMFowgY8xCzAJBgNVBAYTAlVTMRMwEQYDVQQI\n'
+ 'DApXYXNoaW5ndG9uMRAwDgYDVQQHDAdTZWF0dGxlMSIwIAYDVQQKDBlBbWF6b24g\n'
+ 'V2ViIFNlcnZpY2VzLCBJbmMuMRMwEQYDVQQLDApBbWF6b24gUkRTMSAwHgYDVQQD\n'
+ 'DBdBbWF6b24gUkRTIGFwLWVhc3QtMSBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEP\n'
+ 'ADC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YuyqRl6//9nK40cfGKyxVnimB8XrrcxUN743Vud\n'
+ 'QQVU0Esm8OVTX013mXWQXJHP2c0aKkog8LOga0vobQIDAQABo2YwZDAOBgNVHQ8B\n'
+ 'Af8EBAMCAQYwEgYDVR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQULmoOS1mFSjj+\n'
+ 'snUPx4DgS3SkLFYwHwYDVR0jBBgwFoAUc19g2LzLA5j0Kxc0LjZapmD/vB8wDQYJ\n'
+ 'KoZIhvcNAQELBQADggEBAAkVL2P1M2/G9GM3DANVAqYOwmX0Xk58YBHQu6iiQg4j\n'
+ 'b4Ky/qsZIsgT7YBsZA4AOcPKQFgGTWhe9pvhmXqoN3RYltN8Vn7TbUm/ZVDoMsrM\n'
+ 'gwv0+TKxW1/u7s8cXYfHPiTzVSJuOogHx99kBW6b2f99GbP7O1Sv3sLq4j6lVvBX\n'
+ 'Fiacf5LAWC925nvlTzLlBgIc3O9xDtFeAGtZcEtxZJ4fnGXiqEnN4539+nqzIyYq\n'
+ 'nvlgCzyvcfRAxwltrJHuuRu6Maw5AGcd2Y0saMhqOVq9KYKFKuD/927BTrbd2JVf\n'
+ '2sGWyuPZPCk3gq+5pCjbD0c6DkhcMGI6WwxvM5V/zSM=\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS ap-northeast-2 certificate CA 2019 to 2024
*
* CN = Amazon RDS ap-northeast-2 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-09-10T17:46:21Z/2024-08-22T17:08:50Z
* F = 8E:1C:70:C1:64:BD:FC:F9:93:9B:A2:67:CA:CF:52:F0:E1:F7:B4:F0
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIEDDCCAvSgAwIBAgICOFAwDQYJKoZIhvcNAQELBQAwgY8xCzAJBgNVBAYTAlVT\n'
+ 'MRAwDgYDVQQHDAdTZWF0dGxlMRMwEQYDVQQIDApXYXNoaW5ndG9uM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7HVhX0ehPZoGRYRt3PBuI2YjfrrJRTZ9X5wc\n'
+ '9T8oHmw07mHmNy1qqWvooNJg09bDGfB0k5goC2emDiIiGfc/kvMLI7u+eQOoMKj6\n'
+ 'mkfCncyRN3ty08Po45vTLBFZGUvtQmjM6yKewc4sXiASSBmQUpsMbiHRCL72M5qV\n'
+ 'obcJOjGcIdDTmV1BHdWT+XcjynsGjUqOvQWWhhLPrn4jWe6Xuxll75qlrpn3IrIx\n'
+ 'CRBv/5r7qbcQJPOgwQsyK4kv9Ly8g7YT1/vYBlR3cRsYQjccw5ceWUj2DrMVWhJ4\n'
+ 'prf+E3Aa4vYmLLOUUvKnDQ1k3RGNu56V0tonsQbfsaM=\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS ap-northeast-3 certificate CA 2019 to 2024
*
* CN = Amazon RDS ap-northeast-3 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-09-17T20:05:29Z/2024-08-22T17:08:50Z
* F = D1:08:B1:40:6D:6C:80:8E:F4:C1:2C:8A:1F:66:17:01:54:CD:1A:4E
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIEDDCCAvSgAwIBAgICOYIwDQYJKoZIhvcNAQELBQAwgY8xCzAJBgNVBAYTAlVT\n'
+ 'MRAwDgYDVQQHDAdTZWF0dGxlMRMwEQYDVQQIDApXYXNoaW5ndG9uMSIwIAYDVQQK\n'
+ 'DBlBbWF6b24gV2ViIFNlcnZpY2VzLCBJbmMuMRMwEQYDVQQLDApBbWF6b24gUkRT\n'
+ 'MSAwHgYDVQQDDBdBbWF6b24gUkRTIFJvb3QgMjAxOSBDQTAeFw0xOTA5MTcyMDA1\n'
+ 'MjlaFw0yNDA4MjIxNzA4NTBaMIGZMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2Fz\n'
+ 'aGluZ3RvbjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIF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MLc142bD4D9VSy\n'
+ 'DgactwPDTShK/PXqhvNey9v/sKXm4XatZvwcc8KYlW4=\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS ap-south-1 certificate CA 2019 to 2024
*
* CN = Amazon RDS ap-south-1 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-09-04T17:13:04Z/2024-08-22T17:08:50Z
* F = D6:AD:45:A9:54:36:E4:BA:9C:B7:9B:06:8C:0C:CD:CC:1E:81:B5:00
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIECDCCAvCgAwIBAgICVIYwDQYJKoZIhvcNAQELBQAwgY8xCzAJBgNVBAYTAlVT\n'
+ 'MRAwDgYDVQQHDAdTZWF0dGxlMRMwEQYDVQQIDApXYXNoaW5ndG9uMSIwIAYDVQQK\n'
+ 'DBlBbWF6b24gV2ViIFNlcnZpY2VzLCBJbmMuMRMwEQYDVQQLDApBbWF6b24gUkRT\n'
+ 'MSAwHgYDVQQDDBdBbWF6b24gUkRTIFJvb3QgMjAxOSBDQTAeFw0xOTA5MDQxNzEz\n'
+ 'MDRaFw0yNDA4MjIxNzA4NTBaMIGVMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2Fz\n'
+ 'aGluZ3RvbjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIFdlYiBT\n'
+ 'ZXJ2aWNlcywgSW5jLjETMBEGA1UECwwKQW1hem9uIFJEUzEmMCQGA1UEAwwdQW1h\n'
+ 'em9uIFJEUyBhcC1zb3V0aC0xIDIwMTkgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IB\n'
+ 'DwAwggEKAoIBAQDUYOz1hGL42yUCrcsMSOoU8AeD/3KgZ4q7gP+vAz1WnY9K/kim\n'
+ 'eWN/2Qqzlo3+mxSFQFyD4MyV3+CnCPnBl9Sh1G/F6kThNiJ7dEWSWBQGAB6HMDbC\n'
+ 'BaAsmUc1UIz8sLTL3fO+S9wYhA63Wun0Fbm/Rn2yk/4WnJAaMZcEtYf6e0KNa0LM\n'
+ 'p/kN/70/8cD3iz3dDR8zOZFpHoCtf0ek80QqTich0A9n3JLxR6g6tpwoYviVg89e\n'
+ 'qCjQ4axxOkWWeusLeTJCcY6CkVyFvDAKvcUl1ytM5AiaUkXblE7zDFXRM4qMMRdt\n'
+ 'lPm8d3pFxh0fRYk8bIKnpmtOpz3RIctDrZZxAgMBAAGjZjBkMA4GA1UdDwEB/wQE\n'
+ 'AwIBBjASBgNVHRMBAf8ECDAGAQH/AgEAMB0GA1UdDgQWBBT99wKJftD3jb4sHoHG\n'
+ 'i3uGlH6W6TAfBgNVHSMEGDAWgBRzX2DYvMsDmPQrFzQuNlqmYP+8HzANBgkqhkiG\n'
+ '9w0BAQsFAAOCAQEAZ17hhr3dII3hUfuHQ1hPWGrpJOX/G9dLzkprEIcCidkmRYl+\n'
+ 'hu1Pe3caRMh/17+qsoEErmnVq5jNY9X1GZL04IZH8YbHc7iRHw3HcWAdhN8633+K\n'
+ 'jYEB2LbJ3vluCGnCejq9djDb6alOugdLMJzxOkHDhMZ6/gYbECOot+ph1tQuZXzD\n'
+ 'tZ7prRsrcuPBChHlPjmGy8M9z8u+kF196iNSUGC4lM8vLkHM7ycc1/ZOwRq9aaTe\n'
+ 'iOghbQQyAEe03MWCyDGtSmDfr0qEk+CHN+6hPiaL8qKt4s+V9P7DeK4iW08ny8Ox\n'
+ 'AVS7u0OK/5+jKMAMrKwpYrBydOjTUTHScocyNw==\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS ap-southeast-1 certificate CA 2019 to 2024
*
* CN = Amazon RDS ap-southeast-1 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-09-13T20:11:42Z/2024-08-22T17:08:50Z
* F = 0D:20:FB:91:DE:BE:D2:CF:F3:F8:F8:43:AF:68:C6:03:76:F3:DD:B8
*/
'-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gwBgEB/wIBADAdBgNVHQ4EFgQUytwMiomQOgX5\n'
+ 'Ichd+2lDWRUhkikwHwYDVR0jBBgwFoAUc19g2LzLA5j0Kxc0LjZapmD/vB8wDQYJ\n'
+ 'KoZIhvcNAQELBQADggEBACf6lRDpfCD7BFRqiWM45hqIzffIaysmVfr+Jr+fBTjP\n'
+ 'uYe/ba1omSrNGG23bOcT9LJ8hkQJ9d+FxUwYyICQNWOy6ejicm4z0C3VhphbTPqj\n'
+ 'yjpt9nG56IAcV8BcRJh4o/2IfLNzC/dVuYJV8wj7XzwlvjysenwdrJCoLadkTr1h\n'
+ 'eIdG6Le07sB9IxrGJL9e04afk37h7c8ESGSE4E+oS4JQEi3ATq8ne1B9DQ9SasXi\n'
+ 'IRmhNAaISDzOPdyLXi9N9V9Lwe/DHcja7hgLGYx3UqfjhLhOKwp8HtoZORixAmOI\n'
+ 'HfILgNmwyugAbuZoCazSKKBhQ0wgO0WZ66ZKTMG8Oho=\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS ap-southeast-2 certificate CA 2019 to 2024
*
* CN = Amazon RDS ap-southeast-2 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-09-16T19:53:47Z/2024-08-22T17:08:50Z
* F = D5:D4:51:83:D9:A3:AC:47:B0:0A:5A:77:D8:A0:79:A9:6A:3F:6D:96
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIEDDCCAvSgAwIBAgICEkYwDQYJKoZIhvcNAQELBQAwgY8xCzAJBgNVBAYTAlVT\n'
+ 'MRAwDgYDVQQHDAdTZWF0dGxlMRMwEQYDVQQIDApXYXNoaW5ndG9uMSIwIAYDVQQK\n'
+ 'DBlBbWF6b24gV2ViIFNlcnZpY2VzLCBJbmMuMRMwEQYDVQQLDApBbWF6b24gUkRT\n'
+ 'MSAwHgYDVQQDDBdBbWF6b24gUkRTIFJvb3QgMjAxOSBDQTAeFw0xOTA5MTYxO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MkoNnw\n'
+ '1VR4XKhXHYGWo7KMvFrZ1KcjWhubxLHxZWXRulPVtGmyWg/MvE6KF+2XMLhojhUL\n'
+ '+9jB3Fpn53s6KMx5tVq1x8PukHmowcZuAF8k+W4gk8Y68wIwynrdZrKRyRv6CVtR\n'
+ 'FZ8DeJgoNZT3y/GT254VqMxxfuy2Ccb/RInd16tEvVk=\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS ca-central-1 certificate CA 2019 to 2024
*
* CN = Amazon RDS ca-central-1 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-09-10T20:52:25Z/2024-08-22T17:08:50Z
* F = A1:03:46:F2:BB:29:BF:4F:EC:04:7E:82:9A:A6:C0:11:4D:AB:82:25
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIECjCCAvKgAwIBAgICEzUwDQYJKoZIhvcNAQELBQAwgY8xCzAJBgNVBAYTAlVT\n'
+ 'MRAwDgYDVQQHDAdTZWF0dGxlMRMwEQYDVQQIDApXYXNoaW5ndG9uMSIwIAYDVQQK\n'
+ 'DBlBbWF6b24gV2ViIFNlcnZpY2VzLCBJbmMuMRMwEQYDVQQLDApBbWF6b24gUkRT\n'
+ 'MSAwHgYDVQQDDBdBbWF6b24gUkRTIFJvb3QgMjAxOSBDQTAeFw0xOTA5MTAyMDUy\n'
+ 'MjVaFw0yNDA4MjIxNzA4NTBaMIGXMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2Fz\n'
+ 'aGluZ3RvbjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIFdlYiBT\n'
+ 'ZXJ2aWNlcywgSW5jLjETMBEGA1UECwwKQW1hem9uIFJEUzEoMCYGA1UEAwwfQW1h\n'
+ 'em9uIFJEUyBjYS1jZW50cmFsLTEgMjAxOSBDQTCCASIwDQYJKoZIhvcNAQEBBQAD\n'
+ 'ggEPADCCAQoCggEBAOxHqdcP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FfZHpt18A6Zkq6A2u6\n'
+ 'D/oTSL6c9/3sAaFTFgMyL3wHb2YlW0BPiljZIqECAwEAAaNmMGQwDgYDVR0PAQH/\n'
+ 'BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0OBBYEFOcAToAc6skWffJa\n'
+ 'TnreaswAfrbcMB8GA1UdIwQYMBaAFHNfYNi8ywOY9CsXNC42WqZg/7wfMA0GCSqG\n'
+ 'SIb3DQEBCwUAA4IBAQA1d0Whc1QtspK496mFWfFEQNegLh0a9GWYlJm+Htcj5Nxt\n'
+ 'DAIGXb+8xrtOZFHmYP7VLCT5Zd2C+XytqseK/+s07iAr0/EPF+O2qcyQWMN5KhgE\n'
+ 'cXw2SwuP9FPV3i+YAm11PBVeenrmzuk9NrdHQ7TxU4v7VGhcsd2C++0EisrmquWH\n'
+ 'mgIfmVDGxphwoES52cY6t3fbnXmTkvENvR+h3rj+fUiSz0aSo+XZUGHPgvuEKM/W\n'
+ 'CBD9Smc9CBoBgvy7BgHRgRUmwtABZHFUIEjHI5rIr7ZvYn+6A0O6sogRfvVYtWFc\n'
+ 'qpyrW1YX8mD0VlJ8fGKM3G+aCOsiiPKDV/Uafrm+\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS eu-north-1 certificate CA 2019 to 2024
*
* CN = Amazon RDS eu-north-1 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-09-12T18:19:44Z/2024-08-22T17:08:50Z
* F = D0:CA:9C:6E:47:4C:4F:DB:85:28:03:4A:60:AC:14:E0:E6:DF:D4:42
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIECDCCAvCgAwIBAgICGAcwDQYJKoZIhvcNAQELBQAwgY8xCzAJBgNVBAYTAlVT\n'
+ 'MRAwDgYDVQQHDAdTZWF0dGxlMRMwEQYDVQQIDApXYXNoaW5ndG9uMSIwIAYDVQQK\n'
+ 'DBlBbWF6b24gV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5CeoSr9CMuVC8grYyBjXblC4OsM5NMvmsrXl/u5C9dEwtBFjo8mm53rOOIm1fxl\n'
+ 'I1oYB/9mtO9ANWjkykuLzWeBlqDT/i7ckaKwalhLODsRDO73vRhYNjsIUGloNsKe\n'
+ 'pxw3dzHwAZx4upSdEVG4RGCZ1D0LJ4Gw40OfD69hfkDfRVVxKGrbEzqxXRvovmDc\n'
+ 'tKLdYZO/6REoca36v4BlgIs1CbUXJGLSXUwtg7YXGLSVBJ/U0+22iGJmBSNcoyUN\n'
+ 'cjPFD9JQEhDDIYYKSGzIYpvslvGc4T5ISXFiuQ==\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS eu-west-1 certificate CA 2019 to 2024
*
* CN = Amazon RDS eu-west-1 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-09-11T17:31:48Z/2024-08-22T17:08:50Z
* F = 2D:1A:A6:3E:0D:EB:D6:26:03:3E:A1:8A:0A:DF:14:80:78:EC:B6:63
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIEBzCCAu+gAwIBAgICYpgwDQYJKoZIhvcNAQELBQAwgY8xCzAJBgNVBAYTAlVT\n'
+ 'MRAwDgYDVQQHDAdTZWF0dGxlMRMwEQYDVQQIDApXYXNoaW5ndG9uMSIwIAYDVQQK\n'
+ 'DBlBbWF6b24gV2ViIFNlcnZpY2VzLCBJbmMuMRMwEQYDVQQLDApBbWF6b24gUkRT\n'
+ 'MSAwHgYDVQQDDBdBbWF6b24gUkRTIFJvb3QgMjAxOSBDQTAeFw0xOTA5MTExNzMx\n'
+ 'NDhaFw0yNDA4MjIxNzA4NTBaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2Fz\n'
+ 'aGluZ3RvbjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIFdlYiBT\n'
+ 'ZXJ2aWNlcywgSW5jLjETMBEGA1UECwwKQW1hem9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eHABZcvz\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS eu-west-2 certificate CA 2019 to 2024
*
* CN = Amazon RDS eu-west-2 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-09-12T21:32:32Z/2024-08-22T17:08:50Z
* F = 60:65:44:F4:74:6E:2E:29:50:19:38:7C:4B:BE:18:B9:5B:D4:CD:23
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIEBzCCAu+gAwIBAgICZIEwDQYJKoZIhvcNAQELBQAwgY8xCzAJBgNVBAYTAlVT\n'
+ 'MRAwDgYDVQQHDAdTZWF0dGxlMRMwEQYDVQQIDApXYXNoaW5ndG9uMSIwIAYDVQQK\n'
+ 'DBlBbWF6b24gV2ViIFNlcnZpY2VzLCBJbmMuMRMwEQYDVQQLDApBbWF6b24gUkRT\n'
+ 'MSAwHgYDVQQDDBdBbWF6b24gUkRTIFJvb3QgMjAxOSBDQTAeFw0xOTA5MTIyMTMy\n'
+ 'MzJaFw0yNDA4MjIxNzA4NTBaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2Fz\n'
+ 'aGluZ3RvbjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIFdlYiBT\n'
+ 'ZXJ2aWNlcywgSW5jLjETMBEGA1UECwwKQW1hem9uIFJEUzElMCMGA1UEAwwcQW1h\n'
+ 'em9uIFJEUyBldS13ZXN0LTIgMjAxOSBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEP\n'
+ 'ADCCAQoCggEBALGiwqjiF7xIjT0Sx7zB3764K2T2a1DHnAxEOr+/EIftWKxWzT3u\n'
+ 'PFwS2eEZcnKqSdRQ+vRzonLBeNLO4z8aLjQnNbkizZMBuXGm4BqRm1Kgq3nlLDQn\n'
+ '7YqdijOq54SpShvR/8zsO4sgMDMmHIYAJJOJqBdaus2smRt0NobIKc0liy7759KB\n'
+ '6kmQ47Gg+kfIwxrQA5zlvPLeQImxSoPi9LdbRoKvu7Iot7SOa+jGhVBh3VdqndJX\n'
+ '7tm/saj4NE375csmMETFLAOXjat7zViMRwVorX4V6AzEg1vkzxXpA9N7qywWIT5Y\n'
+ 'fYaq5M8i6vvLg0CzrH9fHORtnkdjdu1y+0MCAwEAAaNmMGQwDgYDVR0PAQH/BAQD\n'
+ 'AgEGMBIGA1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0OBBYEFFOhOx1yt3Z7mvGB9jBv\n'
+ '2ymdZwiOMB8GA1UdIwQYMBaAFHNfYNi8ywOY9CsXNC42WqZg/7wfMA0GCSqGSIb3\n'
+ 'DQEBCwUAA4IBAQBehqY36UGDvPVU9+vtaYGr38dBbp+LzkjZzHwKT1XJSSUc2wqM\n'
+ 'hnCIQKilonrTIvP1vmkQi8qHPvDRtBZKqvz/AErW/ZwQdZzqYNFd+BmOXaeZWV0Q\n'
+ 'oHtDzXmcwtP8aUQpxN0e1xkWb1E80qoy+0uuRqb/50b/R4Q5qqSfJhkn6z8nwB10\n'
+ '7RjLtJPrK8igxdpr3tGUzfAOyiPrIDncY7UJaL84GFp7WWAkH0WG3H8Y8DRcRXOU\n'
+ 'mqDxDLUP3rNuow3jnGxiUY+gGX5OqaZg4f4P6QzOSmeQYs6nLpH0PiN00+oS1BbD\n'
+ 'bpWdZEttILPI+vAYkU4QuBKKDjJL6HbSd+cn\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS eu-west-3 certificate CA 2019 to 2024
*
* CN = Amazon RDS eu-west-3 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-09-18T17:03:15Z/2024-08-22T17:08:50Z
* F = 6F:79:56:B0:74:9C:C6:3E:3B:50:26:C8:51:55:08:F0:BB:7E:32:04
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIEBzCCAu+gAwIBAgICJDQwDQYJKoZIhvcNAQELBQAwgY8xCzAJBgNV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sXNC42WqZg/7wfMA0GCSqGSIb3\n'
+ 'DQEBCwUAA4IBAQAigQ5VBNGyw+OZFXwxeJEAUYaXVoP/qrhTOJ6mCE2DXUVEoJeV\n'
+ 'SxScy/TlFA9tJXqmit8JH8VQ/xDL4ubBfeMFAIAo4WzNWDVoeVMqphVEcDWBHsI1\n'
+ 'AETWzfsapRS9yQekOMmxg63d/nV8xewIl8aNVTHdHYXMqhhik47VrmaVEok1UQb3\n'
+ 'O971RadLXIEbVd9tjY5bMEHm89JsZDnDEw1hQXBb67Elu64OOxoKaHBgUH8AZn/2\n'
+ 'zFsL1ynNUjOhCSAA15pgd1vjwc0YsBbAEBPcHBWYBEyME6NLNarjOzBl4FMtATSF\n'
+ 'wWCKRGkvqN8oxYhwR2jf2rR5Mu4DWkK5Q8Ep\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS me-south-1 certificate CA 2019 to 2024
*
* CN = Amazon RDS me-south-1 Root CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-05-10T21:48:27Z/2024-05-08T21:48:27Z
* F = 8A:69:D7:00:FB:5D:62:9C:B0:D1:75:6F:B7:B6:38:AA:76:C4:BD:1F
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIEEjCCAvqgAwIBAgIJANew34ehz5l8MA0GCSqGSIb3DQEBCwUAMIGVMQswCQYD\n'
+ 'VQQGEwJVUzEQMA4GA1UEBwwHU2VhdHRsZTETMBEGA1UECAwKV2FzaGluZ3RvbjEi\n'
+ 'MCAGA1UECgwZQW1hem9uIFdlYiBTZXJ2aWNlcywgSW5jLjETMBEGA1UECwwKQW1h\n'
+ 'em9uIFJEUzEmMCQGA1UEAwwdQW1hem9uIFJEUyBtZS1zb3V0aC0xIFJvb3QgQ0Ew\n'
+ 'HhcNMTkwNTEwMjE0ODI3WhcNMjQwNTA4MjE0ODI3WjCBlTELMAkGA1UEBhMCVVMx\n'
+ 'EDAOBgNVBAcM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681Z0mvkRdb+cdXtKOSuDZPoe2wJJIaz3IlNQNSrB5TImMYgmt6iAsFhv\n'
+ '3vfTSTKrZDNTJn4ybG6pq1zWExoXsktZPylJly6R3RBwV6nwqBM=\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS sa-east-1 certificate CA 2019 to 2024
*
* CN = Amazon RDS sa-east-1 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-09-05T18:46:29Z/2024-08-22T17:08:50Z
* F = 8C:34:0F:AA:FB:10:80:9C:05:CE:D7:BF:0B:12:4D:07:42:39:74:7A
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIEBzCCAu+gAwIBAgICQ2QwDQYJKoZIhvcNAQELBQAwgY8xCzAJBgNVBAYTAlVT\n'
+ 'MRAwDgYDVQQHDAdTZWF0dGxlMRMwEQYDVQQIDApXYXNoaW5ndG9uMSIwIAYDVQQK\n'
+ 'DBlBbWF6b24gV2ViIFNlcnZpY2VzLCBJbmMuMRMwEQYDVQQLDApBbWF6b24gUkRT\n'
+ 'MSAwHgYDVQQDDBdBbWF6b24gUkRTIFJvb3QgMjAxOSBDQTAeFw0xOTA5MDUxODQ2\n'
+ 'MjlaFw0yNDA4MjIxNzA4NTBaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2Fz\n'
+ 'aGluZ3RvbjEQMA4GA1UEBwwHU2VhdHRsZTEiMCAGA1UECgwZQW1hem9uIFdlYiBT\n'
+ 'ZXJ2aWNlcywgSW5jLjETMBEGA1UECwwKQW1hem9uIFJEUzElMCMGA1UEAwwcQW1h\n'
+ 'em9uIFJEUyBzYS1lYXN0LTEgMjAxOSBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEP\n'
+ 'ADCCAQoCggEBAMMvR+ReRnOzqJzoaPipNTt1Z2VA968jlN1+SYKUrYM3No+Vpz0H\n'
+ 'M6Tn0oYB66ByVsXiGc28ulsqX1HbHsxqDPwvQTKvO7SrmDokoAkjJgLocOLUAeld\n'
+ '5AwvUjxGRP6yY90NV7X786MpnYb2Il9DIIaV9HjCmPt+rjy2CZjS0UjPjCKNfB8J\n'
+ 'bFjgW6GGscjeyGb/zFwcom5p4j0rLydbNaOr9wOyQrtt3ZQWLYGY9Zees/b8pmcc\n'
+ 'Jt+7jstZ2UMV32OO/kIsJ4rMUn2r/uxccPwAc1IDeRSSxOrnFKhW3Cu69iB3bHp7\n'
+ 'JbawY12g7zshE4I14sHjv3QoXASoXjx4xgMCAwEAAaNmMGQwDgYDVR0PAQH/BAQD\n'
+ 'AgEGMBIGA1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0OBBYEFI1Fc/Ql2jx+oJPgBVYq\n'
+ 'ccgP0pQ8MB8GA1UdIwQYMBaAFHNfYNi8ywOY9CsXNC42WqZg/7wfMA0GCSqGSIb3\n'
+ 'DQEBCwUAA4IBAQB4VVVabVp70myuYuZ3vltQIWqSUMhkaTzehMgGcHjMf9iLoZ/I\n'
+ '93KiFUSGnek5cRePyS9wcpp0fcBT3FvkjpUdCjVtdttJgZFhBxgTd8y26ImdDDMR\n'
+ '4+BUuhI5msvjL08f+Vkkpu1GQcGmyFVPFOy/UY8iefu+QyUuiBUnUuEDd49Hw0Fn\n'
+ '/kIPII6Vj82a2mWV/Q8e+rgN8dIRksRjKI03DEoP8lhPlsOkhdwU6Uz9Vu6NOB2Q\n'
+ 'Ls1kbcxAc7cFSyRVJEhh12Sz9d0q/CQSTFsVJKOjSNQBQfVnLz1GwO/IieUEAr4C\n'
+ 'jkTntH0r1LX5b/GwN4R887LvjAEdTbg1his7\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS us-east-1 certificate CA 2019 to 2024
*
* CN = Amazon RDS us-east-1 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-09-19T18:16:53Z/2024-08-22T17:08:50Z
* F = F0:ED:82:3E:D1:44:47:BA:B5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GMBIGA1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0OBBYEFPqhoWZcrVY9mU7tuemR\n'
+ 'RBnQIj1jMB8GA1UdIwQYMBaAFHNfYNi8ywOY9CsXNC42WqZg/7wfMA0GCSqGSIb3\n'
+ 'DQEBCwUAA4IBAQB6zOLZ+YINEs72heHIWlPZ8c6WY8MDU+Be5w1M+BK2kpcVhCUK\n'
+ 'PJO4nMXpgamEX8DIiaO7emsunwJzMSvavSPRnxXXTKIc0i/g1EbiDjnYX9d85DkC\n'
+ 'E1LaAUCmCZBVi9fIe0H2r9whIh4uLWZA41oMnJx/MOmo3XyMfQoWcqaSFlMqfZM4\n'
+ '0rNoB/tdHLNuV4eIdaw2mlHxdWDtF4oH+HFm+2cVBUVC1jXKrFv/euRVtsTT+A6i\n'
+ 'h2XBHKxQ1Y4HgAn0jACP2QSPEmuoQEIa57bEKEcZsBR8SDY6ZdTd2HLRIApcCOSF\n'
+ 'MRM8CKLeF658I0XgF8D5EsYoKPsA+74Z+jDH\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS us-east-2 certificate CA 2019 to 2024
*
* CN = Amazon RDS us-east-2 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-09-13T17:06:41Z/2024-08-22T17:08:50Z
* F = E9:FE:27:2A:A0:0F:CE:DF:AD:51:03:A6:94:F7:1F:6F:BD:1E:28:D3
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIECDCCAvCgAwIBAgIDAIVCMA0GCSqGSIb3DQEBCwUAMIGPMQswCQYDVQQGEwJV\n'
+ 'UzEQMA4GA1UEBwwHU2VhdHRsZTETMBEGA1UECAwKV2FzaGluZ3RvbjEiMCAGA1UE\n'
+ 'CgwZQW1hem9uIFdlYiBTZXJ2aWNlcywgSW5jLjETMBEGA1UECwwKQW1hem9uIFJE\n'
+ 'UzEgMB4GA1UEAwwXQW1hem9uIFJEUyBSb290IDIwMTkgQ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sctKvCVaeBqbGpeCtt3Hh/26tgx0rorPLw90A2\n'
+ 'V8QSkZJjlcKkLa58N5CMM8Xz8KLWg3MZeT4DmlUXVCukqK2RGuP2L+aME8dOxqNv\n'
+ 'OnOz1zrL5mR2iJoDpk8+VE/eBDmJX40IJk6jBjWoxAO/RXq+vBozuF5YHN1ujE92\n'
+ 'tO8HItgTp37XT8bJBAiAnt5mxw+NLSqtxk2QdQ==\n'
+ '-----END CERTIFICATE-----\n',
/**
* Amazon RDS us-west-1 certificate CA 2019 to 2024
*
* CN = Amazon RDS us-west-1 2019 CA
* OU = Amazon RDS
* O = Amazon Web Services, Inc.
* L = Seattle
* ST = Washington
* C = US
* P = 2019-09-06T17:40:21Z/2024-08-22T17:08:50Z
* F = 1C:9F:DF:84:E6:13:32:F3:91:12:2D:0D:A5:9A:16:5D:AC:DC:E8:93
*/
'-----BEGIN CERTIFICATE-----\n'
+ 'MIIECDCCAvCgAwIBAgIDAIkHMA0GCSqGSIb3DQEBCwUAMIGPMQswCQYDVQQGEwJV\n'
+ 'UzEQMA4GA1UEBwwHU2VhdHRsZTETMBEGA1UECAwKV2FzaGluZ3RvbjEiMCAGA1UE\n'
+ 'CgwZQW1hem9uIFdlYiBTZXJ2aWNlcywgSW5jLjETMBEGA1UECwwKQW1hem9uIFJE\n'
+ 'UzEgMB4GA1UEAwwXQW1hem9uIFJEUyBSb290IDIwMTkgQ0EwHhcNMTkwOTA2MTc0\n'
+ 'MDIxWhcNMjQwODIyMTcwODUwWjCBlDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldh\n'
+ 'c2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIjAgBgNVBAoMGUFtYXpvbiBXZWIg\n'
+ 'U2VydmljZXMsIEluYy4xEzARBgNVBAsMCkFtYXpvbiBSRFMxJTAjBgNVBAMMHEFt\n'
+ 'YXpvbiBSRFMgdXMtd2VzdC0xIDIwMTkgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IB\n'
+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0xjmWdoEXz9/OwjmCihHqJq+20MJPsvFm7D6a\n'
+ '2NKybR9U+ddrjb8/iyLOjURUZnj5O+2+OPcCAwEAAaNmMGQwDgYDVR0PAQH/BAQD\n'
+ 'AgEGMBIGA1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0OBBYEFEBxMBdv81xuzqcK5TVu\n'
+ 'pHj+Aor8MB8GA1UdIwQYMBaAFHNfYNi8ywOY9CsXNC42WqZg/7wfMA0GCSqGSIb3\n'
+ 'DQEBCwUAA4IBAQBZkfiVqGoJjBI37aTlLOSjLcjI75L5wBrwO39q+B4cwcmpj58P\n'
+ '3sivv+jhYfAGEbQnGRzjuFoyPzWnZ1DesRExX+wrmHsLLQbF2kVjLZhEJMHF9eB7\n'
+ 'GZlTPdTzHErcnuXkwA/OqyXMpj9aghcQFuhCNguEfnROY9sAoK2PTfnTz9NJHL+Q\n'
+ 'UpDLEJEUfc0GZMVWYhahc0x38ZnSY2SKacIPECQrTI0KpqZv/P+ijCEcMD9xmYEb\n'
+ 'jL4en+XKS1uJpw5fIU5Sj0MxhdGstH6S84iAE5J3GM3XHklGSFwwqPYvuTXvANH6\n'
+ 'uboynxRgSae59jIlAK6Jrr6GWMwQRbgcaAlW\n'
+ '-----END CERTIFICATE-----\n'
]
};
/**
* MySQL type constants
*
* Extracted from version 5.7.29
*
* !! Generated by generate-type-constants.js, do not modify by hand !!
*/
exports.DECIMAL = 0;
exports.TINY = 1;
exports.SHORT = 2;
exports.LONG = 3;
exports.FLOAT = 4;
exports.DOUBLE = 5;
exports.NULL = 6;
exports.TIMESTAMP = 7;
exports.LONGLONG = 8;
exports.INT24 = 9;
exports.DATE = 10;
exports.TIME = 11;
exports.DATETIME = 12;
exports.YEAR = 13;
exports.NEWDATE = 14;
exports.VARCHAR = 15;
exports.BIT = 16;
exports.TIMESTAMP2 = 17;
exports.DATETIME2 = 18;
exports.TIME2 = 19;
exports.JSON = 245;
exports.NEWDECIMAL = 246;
exports.ENUM = 247;
exports.SET = 248;
exports.TINY_BLOB = 249;
exports.MEDIUM_BLOB = 250;
exports.LONG_BLOB = 251;
exports.BLOB = 252;
exports.VAR_STRING = 253;
exports.STRING = 254;
exports.GEOMETRY = 255;
// Lookup-by-number table
exports[0] = 'DECIMAL';
exports[1] = 'TINY';
exports[2] = 'SHORT';
exports[3] = 'LONG';
exports[4] = 'FLOAT';
exports[5] = 'DOUBLE';
exports[6] = 'NULL';
exports[7] = 'TIMESTAMP';
exports[8] = 'LONGLONG';
exports[9] = 'INT24';
exports[10] = 'DATE';
exports[11] = 'TIME';
exports[12] = 'DATETIME';
exports[13] = 'YEAR';
exports[14] = 'NEWDATE';
exports[15] = 'VARCHAR';
exports[16] = 'BIT';
exports[17] = 'TIMESTAMP2';
exports[18] = 'DATETIME2';
exports[19] = 'TIME2';
exports[245] = 'JSON';
exports[246] = 'NEWDECIMAL';
exports[247] = 'ENUM';
exports[248] = 'SET';
exports[249] = 'TINY_BLOB';
exports[250] = 'MEDIUM_BLOB';
exports[251] = 'LONG_BLOB';
exports[252] = 'BLOB';
exports[253] = 'VAR_STRING';
exports[254] = 'STRING';
exports[255] = 'GEOMETRY';
module.exports = AuthSwitchRequestPacket;
function AuthSwitchRequestPacket(options) {
options = options || {};
this.status = 0xfe;
this.authMethodName = options.authMethodName;
this.authMethodData = options.authMethodData;
}
AuthSwitchRequestPacket.prototype.parse = function parse(parser) {
this.status = parser.parseUnsignedNumber(1);
this.authMethodName = parser.parseNullTerminatedString();
this.authMethodData = parser.parsePacketTerminatedBuffer();
};
AuthSwitchRequestPacket.prototype.write = function write(writer) {
writer.writeUnsignedNumber(1, this.status);
writer.writeNullTerminatedString(this.authMethodName);
writer.writeBuffer(this.authMethodData);
};
module.exports = AuthSwitchResponsePacket;
function AuthSwitchResponsePacket(options) {
options = options || {};
this.data = options.data;
}
AuthSwitchResponsePacket.prototype.parse = function parse(parser) {
this.data = parser.parsePacketTerminatedBuffer();
};
AuthSwitchResponsePacket.prototype.write = function write(writer) {
writer.writeBuffer(this.data);
};
var Buffer = require('safe-buffer').Buffer;
module.exports = ClientAuthenticationPacket;
function ClientAuthenticationPacket(options) {
options = options || {};
this.clientFlags = options.clientFlags;
this.maxPacketSize = options.maxPacketSize;
this.charsetNumber = options.charsetNumber;
this.filler = undefined;
this.user = options.user;
this.scrambleBuff = options.scrambleBuff;
this.database = options.database;
this.protocol41 = options.protocol41;
}
ClientAuthenticationPacket.prototype.parse = function(parser) {
if (this.protocol41) {
this.clientFlags = parser.parseUnsignedNumber(4);
this.maxPacketSize = parser.parseUnsignedNumber(4);
this.charsetNumber = parser.parseUnsignedNumber(1);
this.filler = parser.parseFiller(23);
this.user = parser.parseNullTerminatedString();
this.scrambleBuff = parser.parseLengthCodedBuffer();
this.database = parser.parseNullTerminatedString();
} else {
this.clientFlags = parser.parseUnsignedNumber(2);
this.maxPacketSize = parser.parseUnsignedNumber(3);
this.user = parser.parseNullTerminatedString();
this.scrambleBuff = parser.parseBuffer(8);
this.database = parser.parseLengthCodedBuffer();
}
};
ClientAuthenticationPacket.prototype.write = function(writer) {
if (this.protocol41) {
writer.writeUnsignedNumber(4, this.clientFlags);
writer.writeUnsignedNumber(4, this.maxPacketSize);
writer.writeUnsignedNumber(1, this.charsetNumber);
writer.writeFiller(23);
writer.writeNullTerminatedString(this.user);
writer.writeLengthCodedBuffer(this.scrambleBuff);
writer.writeNullTerminatedString(this.database);
} else {
writer.writeUnsignedNumber(2, this.clientFlags);
writer.writeUnsignedNumber(3, this.maxPacketSize);
writer.writeNullTerminatedString(this.user);
writer.writeBuffer(this.scrambleBuff);
if (this.database && this.database.length) {
writer.writeFiller(1);
writer.writeBuffer(Buffer.from(this.database));
}
}
};
module.exports = ComChangeUserPacket;
function ComChangeUserPacket(options) {
options = options || {};
this.command = 0x11;
this.user = options.user;
this.scrambleBuff = options.scrambleBuff;
this.database = options.database;
this.charsetNumber = options.charsetNumber;
}
ComChangeUserPacket.prototype.parse = function(parser) {
this.command = parser.parseUnsignedNumber(1);
this.user = parser.parseNullTerminatedString();
this.scrambleBuff = parser.parseLengthCodedBuffer();
this.database = parser.parseNullTerminatedString();
this.charsetNumber = parser.parseUnsignedNumber(1);
};
ComChangeUserPacket.prototype.write = function(writer) {
writer.writeUnsignedNumber(1, this.command);
writer.writeNullTerminatedString(this.user);
writer.writeLengthCodedBuffer(this.scrambleBuff);
writer.writeNullTerminatedString(this.database);
writer.writeUnsignedNumber(2, this.charsetNumber);
};
module.exports = ComPingPacket;
function ComPingPacket() {
this.command = 0x0e;
}
ComPingPacket.prototype.write = function(writer) {
writer.writeUnsignedNumber(1, this.command);
};
ComPingPacket.prototype.parse = function(parser) {
this.command = parser.parseUnsignedNumber(1);
};
module.exports = ComQueryPacket;
function ComQueryPacket(sql) {
this.command = 0x03;
this.sql = sql;
}
ComQueryPacket.prototype.write = function(writer) {
writer.writeUnsignedNumber(1, this.command);
writer.writeString(this.sql);
};
ComQueryPacket.prototype.parse = function(parser) {
this.command = parser.parseUnsignedNumber(1);
this.sql = parser.parsePacketTerminatedString();
};
module.exports = ComQuitPacket;
function ComQuitPacket() {
this.command = 0x01;
}
ComQuitPacket.prototype.parse = function parse(parser) {
this.command = parser.parseUnsignedNumber(1);
};
ComQuitPacket.prototype.write = function write(writer) {
writer.writeUnsignedNumber(1, this.command);
};
module.exports = ComStatisticsPacket;
function ComStatisticsPacket() {
this.command = 0x09;
}
ComStatisticsPacket.prototype.write = function(writer) {
writer.writeUnsignedNumber(1, this.command);
};
ComStatisticsPacket.prototype.parse = function(parser) {
this.command = parser.parseUnsignedNumber(1);
};
module.exports = EmptyPacket;
function EmptyPacket() {
}
EmptyPacket.prototype.parse = function parse() {
};
EmptyPacket.prototype.write = function write() {
};
module.exports = EofPacket;
function EofPacket(options) {
options = options || {};
this.fieldCount = undefined;
this.warningCount = options.warningCount;
this.serverStatus = options.serverStatus;
this.protocol41 = options.protocol41;
}
EofPacket.prototype.parse = function(parser) {
this.fieldCount = parser.parseUnsignedNumber(1);
if (this.protocol41) {
this.warningCount = parser.parseUnsignedNumber(2);
this.serverStatus = parser.parseUnsignedNumber(2);
}
};
EofPacket.prototype.write = function(writer) {
writer.writeUnsignedNumber(1, 0xfe);
if (this.protocol41) {
writer.writeUnsignedNumber(2, this.warningCount);
writer.writeUnsignedNumber(2, this.serverStatus);
}
};
module.exports = ErrorPacket;
function ErrorPacket(options) {
options = options || {};
this.fieldCount = options.fieldCount;
this.errno = options.errno;
this.sqlStateMarker = options.sqlStateMarker;
this.sqlState = options.sqlState;
this.message = options.message;
}
ErrorPacket.prototype.parse = function(parser) {
this.fieldCount = parser.parseUnsignedNumber(1);
this.errno = parser.parseUnsignedNumber(2);
// sqlStateMarker ('#' = 0x23) indicates error packet format
if (parser.peak() === 0x23) {
this.sqlStateMarker = parser.parseString(1);
this.sqlState = parser.parseString(5);
}
this.message = parser.parsePacketTerminatedString();
};
ErrorPacket.prototype.write = function(writer) {
writer.writeUnsignedNumber(1, 0xff);
writer.writeUnsignedNumber(2, this.errno);
if (this.sqlStateMarker) {
writer.writeString(this.sqlStateMarker);
writer.writeString(this.sqlState);
}
writer.writeString(this.message);
};
var Types = require('../constants/types');
module.exports = Field;
function Field(options) {
options = options || {};
this.parser = options.parser;
this.packet = options.packet;
this.db = options.packet.db;
this.table = options.packet.table;
this.name = options.packet.name;
this.type = Types[options.packet.type];
this.length = options.packet.length;
}
Field.prototype.string = function () {
return this.parser.parseLengthCodedString();
};
Field.prototype.buffer = function () {
return this.parser.parseLengthCodedBuffer();
};
Field.prototype.geometry = function () {
return this.parser.parseGeometryValue();
};
module.exports = FieldPacket;
function FieldPacket(options) {
options = options || {};
this.catalog = options.catalog;
this.db = options.db;
this.table = options.table;
this.orgTable = options.orgTable;
this.name = options.name;
this.orgName = options.orgName;
this.charsetNr = options.charsetNr;
this.length = options.length;
this.type = options.type;
this.flags = options.flags;
this.decimals = options.decimals;
this.default = options.default;
this.zeroFill = options.zeroFill;
this.protocol41 = options.protocol41;
}
FieldPacket.prototype.parse = function(parser) {
if (this.protocol41) {
this.catalog = parser.parseLengthCodedString();
this.db = parser.parseLengthCodedString();
this.table = parser.parseLengthCodedString();
this.orgTable = parser.parseLengthCodedString();
this.name = parser.parseLengthCodedString();
this.orgName = parser.parseLengthCodedString();
if (parser.parseLengthCodedNumber() !== 0x0c) {
var err = new TypeError('Received invalid field length');
err.code = 'PARSER_INVALID_FIELD_LENGTH';
throw err;
}
this.charsetNr = parser.parseUnsignedNumber(2);
this.length = parser.parseUnsignedNumber(4);
this.type = parser.parseUnsignedNumber(1);
this.flags = parser.parseUnsignedNumber(2);
this.decimals = parser.parseUnsignedNumber(1);
var filler = parser.parseBuffer(2);
if (filler[0] !== 0x0 || filler[1] !== 0x0) {
var err = new TypeError('Received invalid filler');
err.code = 'PARSER_INVALID_FILLER';
throw err;
}
// parsed flags
this.zeroFill = (this.flags & 0x0040 ? true : false);
if (parser.reachedPacketEnd()) {
return;
}
this.default = parser.parseLengthCodedString();
} else {
this.table = parser.parseLengthCodedString();
this.name = parser.parseLengthCodedString();
this.length = parser.parseUnsignedNumber(parser.parseUnsignedNumber(1));
this.type = parser.parseUnsignedNumber(parser.parseUnsignedNumber(1));
}
};
FieldPacket.prototype.write = function(writer) {
if (this.protocol41) {
writer.writeLengthCodedString(this.catalog);
writer.writeLengthCodedString(this.db);
writer.writeLengthCodedString(this.table);
writer.writeLengthCodedString(this.orgTable);
writer.writeLengthCodedString(this.name);
writer.writeLengthCodedString(this.orgName);
writer.writeLengthCodedNumber(0x0c);
writer.writeUnsignedNumber(2, this.charsetNr || 0);
writer.writeUnsignedNumber(4, this.length || 0);
writer.writeUnsignedNumber(1, this.type || 0);
writer.writeUnsignedNumber(2, this.flags || 0);
writer.writeUnsignedNumber(1, this.decimals || 0);
writer.writeFiller(2);
if (this.default !== undefined) {
writer.writeLengthCodedString(this.default);
}
} else {
writer.writeLengthCodedString(this.table);
writer.writeLengthCodedString(this.name);
writer.writeUnsignedNumber(1, 0x01);
writer.writeUnsignedNumber(1, this.length);
writer.writeUnsignedNumber(1, 0x01);
writer.writeUnsignedNumber(1, this.type);
}
};
var Buffer = require('safe-buffer').Buffer;
var Client = require('../constants/client');
module.exports = HandshakeInitializationPacket;
function HandshakeInitializationPacket(options) {
options = options || {};
this.protocolVersion = options.protocolVersion;
this.serverVersion = options.serverVersion;
this.threadId = options.threadId;
this.scrambleBuff1 = options.scrambleBuff1;
this.filler1 = options.filler1;
this.serverCapabilities1 = options.serverCapabilities1;
this.serverLanguage = options.serverLanguage;
this.serverStatus = options.serverStatus;
this.serverCapabilities2 = options.serverCapabilities2;
this.scrambleLength = options.scrambleLength;
this.filler2 = options.filler2;
this.scrambleBuff2 = options.scrambleBuff2;
this.filler3 = options.filler3;
this.pluginData = options.pluginData;
this.protocol41 = options.protocol41;
if (this.protocol41) {
// force set the bit in serverCapabilities1
this.serverCapabilities1 |= Client.CLIENT_PROTOCOL_41;
}
}
HandshakeInitializationPacket.prototype.parse = function(parser) {
this.protocolVersion = parser.parseUnsignedNumber(1);
this.serverVersion = parser.parseNullTerminatedString();
this.threadId = parser.parseUnsignedNumber(4);
this.scrambleBuff1 = parser.parseBuffer(8);
this.filler1 = parser.parseFiller(1);
this.serverCapabilities1 = parser.parseUnsignedNumber(2);
this.serverLanguage = parser.parseUnsignedNumber(1);
this.serverStatus = parser.parseUnsignedNumber(2);
this.protocol41 = (this.serverCapabilities1 & (1 << 9)) > 0;
if (this.protocol41) {
this.serverCapabilities2 = parser.parseUnsignedNumber(2);
this.scrambleLength = parser.parseUnsignedNumber(1);
this.filler2 = parser.parseFiller(10);
// scrambleBuff2 should be 0x00 terminated, but sphinx does not do this
// so we assume scrambleBuff2 to be 12 byte and treat the next byte as a
// filler byte.
this.scrambleBuff2 = parser.parseBuffer(12);
this.filler3 = parser.parseFiller(1);
} else {
this.filler2 = parser.parseFiller(13);
}
if (parser.reachedPacketEnd()) {
return;
}
// According to the docs this should be 0x00 terminated, but MariaDB does
// not do this, so we assume this string to be packet terminated.
this.pluginData = parser.parsePacketTerminatedString();
// However, if there is a trailing '\0', strip it
var lastChar = this.pluginData.length - 1;
if (this.pluginData[lastChar] === '\0') {
this.pluginData = this.pluginData.substr(0, lastChar);
}
};
HandshakeInitializationPacket.prototype.write = function(writer) {
writer.writeUnsignedNumber(1, this.protocolVersion);
writer.writeNullTerminatedString(this.serverVersion);
writer.writeUnsignedNumber(4, this.threadId);
writer.writeBuffer(this.scrambleBuff1);
writer.writeFiller(1);
writer.writeUnsignedNumber(2, this.serverCapabilities1);
writer.writeUnsignedNumber(1, this.serverLanguage);
writer.writeUnsignedNumber(2, this.serverStatus);
if (this.protocol41) {
writer.writeUnsignedNumber(2, this.serverCapabilities2);
writer.writeUnsignedNumber(1, this.scrambleLength);
writer.writeFiller(10);
}
writer.writeNullTerminatedBuffer(this.scrambleBuff2);
if (this.pluginData !== undefined) {
writer.writeNullTerminatedString(this.pluginData);
}
};
HandshakeInitializationPacket.prototype.scrambleBuff = function() {
var buffer = null;
if (typeof this.scrambleBuff2 === 'undefined') {
buffer = Buffer.from(this.scrambleBuff1);
} else {
buffer = Buffer.allocUnsafe(this.scrambleBuff1.length + this.scrambleBuff2.length);
this.scrambleBuff1.copy(buffer, 0);
this.scrambleBuff2.copy(buffer, this.scrambleBuff1.length);
}
return buffer;
};
module.exports = LocalDataFilePacket;
/**
* Create a new LocalDataFilePacket
* @constructor
* @param {Buffer} data The data contents of the packet
* @public
*/
function LocalDataFilePacket(data) {
this.data = data;
}
LocalDataFilePacket.prototype.write = function(writer) {
writer.writeBuffer(this.data);
};
module.exports = LocalInfileRequestPacket;
function LocalInfileRequestPacket(options) {
options = options || {};
this.filename = options.filename;
}
LocalInfileRequestPacket.prototype.parse = function parse(parser) {
if (parser.parseLengthCodedNumber() !== null) {
var err = new TypeError('Received invalid field length');
err.code = 'PARSER_INVALID_FIELD_LENGTH';
throw err;
}
this.filename = parser.parsePacketTerminatedString();
};
LocalInfileRequestPacket.prototype.write = function write(writer) {
writer.writeLengthCodedNumber(null);
writer.writeString(this.filename);
};
// Language-neutral expression to match ER_UPDATE_INFO
var ER_UPDATE_INFO_REGEXP = /^[^:0-9]+: [0-9]+[^:0-9]+: ([0-9]+)[^:0-9]+: [0-9]+[^:0-9]*$/;
module.exports = OkPacket;
function OkPacket(options) {
options = options || {};
this.fieldCount = undefined;
this.affectedRows = undefined;
this.insertId = undefined;
this.serverStatus = undefined;
this.warningCount = undefined;
this.message = undefined;
this.protocol41 = options.protocol41;
}
OkPacket.prototype.parse = function(parser) {
this.fieldCount = parser.parseUnsignedNumber(1);
this.affectedRows = parser.parseLengthCodedNumber();
this.insertId = parser.parseLengthCodedNumber();
if (this.protocol41) {
this.serverStatus = parser.parseUnsignedNumber(2);
this.warningCount = parser.parseUnsignedNumber(2);
}
this.message = parser.parsePacketTerminatedString();
this.changedRows = 0;
var m = ER_UPDATE_INFO_REGEXP.exec(this.message);
if (m !== null) {
this.changedRows = parseInt(m[1], 10);
}
};
OkPacket.prototype.write = function(writer) {
writer.writeUnsignedNumber(1, 0x00);
writer.writeLengthCodedNumber(this.affectedRows || 0);
writer.writeLengthCodedNumber(this.insertId || 0);
if (this.protocol41) {
writer.writeUnsignedNumber(2, this.serverStatus || 0);
writer.writeUnsignedNumber(2, this.warningCount || 0);
}
writer.writeString(this.message);
};
module.exports = OldPasswordPacket;
function OldPasswordPacket(options) {
options = options || {};
this.scrambleBuff = options.scrambleBuff;
}
OldPasswordPacket.prototype.parse = function(parser) {
this.scrambleBuff = parser.parsePacketTerminatedBuffer();
};
OldPasswordPacket.prototype.write = function(writer) {
writer.writeBuffer(this.scrambleBuff);
};
module.exports = ResultSetHeaderPacket;
function ResultSetHeaderPacket(options) {
options = options || {};
this.fieldCount = options.fieldCount;
}
ResultSetHeaderPacket.prototype.parse = function(parser) {
this.fieldCount = parser.parseLengthCodedNumber();
};
ResultSetHeaderPacket.prototype.write = function(writer) {
writer.writeLengthCodedNumber(this.fieldCount);
};
var Types = require('../constants/types');
var Charsets = require('../constants/charsets');
var Field = require('./Field');
var IEEE_754_BINARY_64_PRECISION = Math.pow(2, 53);
module.exports = RowDataPacket;
function RowDataPacket() {
}
Object.defineProperty(RowDataPacket.prototype, 'parse', {
configurable : true,
enumerable : false,
value : parse
});
Object.defineProperty(RowDataPacket.prototype, '_typeCast', {
configurable : true,
enumerable : false,
value : typeCast
});
function parse(parser, fieldPackets, typeCast, nestTables, connection) {
var self = this;
var next = function () {
return self._typeCast(fieldPacket, parser, connection.config.timezone, connection.config.supportBigNumbers, connection.config.bigNumberStrings, connection.config.dateStrings);
};
for (var i = 0; i < fieldPackets.length; i++) {
var fieldPacket = fieldPackets[i];
var value;
if (typeof typeCast === 'function') {
value = typeCast.apply(connection, [ new Field({ packet: fieldPacket, parser: parser }), next ]);
} else {
value = (typeCast)
? this._typeCast(fieldPacket, parser, connection.config.timezone, connection.config.supportBigNumbers, connection.config.bigNumberStrings, connection.config.dateStrings)
: ( (fieldPacket.charsetNr === Charsets.BINARY)
? parser.parseLengthCodedBuffer()
: parser.parseLengthCodedString() );
}
if (typeof nestTables === 'string' && nestTables.length) {
this[fieldPacket.table + nestTables + fieldPacket.name] = value;
} else if (nestTables) {
this[fieldPacket.table] = this[fieldPacket.table] || {};
this[fieldPacket.table][fieldPacket.name] = value;
} else {
this[fieldPacket.name] = value;
}
}
}
function typeCast(field, parser, timeZone, supportBigNumbers, bigNumberStrings, dateStrings) {
var numberString;
switch (field.type) {
case Types.TIMESTAMP:
case Types.TIMESTAMP2:
case Types.DATE:
case Types.DATETIME:
case Types.DATETIME2:
case Types.NEWDATE:
var dateString = parser.parseLengthCodedString();
if (typeMatch(field.type, dateStrings)) {
return dateString;
}
if (dateString === null) {
return null;
}
var originalString = dateString;
if (field.type === Types.DATE) {
dateString += ' 00:00:00';
}
if (timeZone !== 'local') {
dateString += ' ' + timeZone;
}
var dt = new Date(dateString);
if (isNaN(dt.getTime())) {
return originalString;
}
return dt;
case Types.TINY:
case Types.SHORT:
case Types.LONG:
case Types.INT24:
case Types.YEAR:
case Types.FLOAT:
case Types.DOUBLE:
numberString = parser.parseLengthCodedString();
return (numberString === null || (field.zeroFill && numberString[0] === '0'))
? numberString : Number(numberString);
case Types.NEWDECIMAL:
case Types.LONGLONG:
numberString = parser.parseLengthCodedString();
return (numberString === null || (field.zeroFill && numberString[0] === '0'))
? numberString
: ((supportBigNumbers && (bigNumberStrings || (Number(numberString) >= IEEE_754_BINARY_64_PRECISION) || Number(numberString) <= -IEEE_754_BINARY_64_PRECISION))
? numberString
: Number(numberString));
case Types.BIT:
return parser.parseLengthCodedBuffer();
case Types.STRING:
case Types.VAR_STRING:
case Types.TINY_BLOB:
case Types.MEDIUM_BLOB:
case Types.LONG_BLOB:
case Types.BLOB:
return (field.charsetNr === Charsets.BINARY)
? parser.parseLengthCodedBuffer()
: parser.parseLengthCodedString();
case Types.GEOMETRY:
return parser.parseGeometryValue();
default:
return parser.parseLengthCodedString();
}
}
function typeMatch(type, list) {
if (Array.isArray(list)) {
return list.indexOf(Types[type]) !== -1;
} else {
return Boolean(list);
}
}
// http://dev.mysql.com/doc/internals/en/ssl.html
// http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::SSLRequest
var ClientConstants = require('../constants/client');
module.exports = SSLRequestPacket;
function SSLRequestPacket(options) {
options = options || {};
this.clientFlags = options.clientFlags | ClientConstants.CLIENT_SSL;
this.maxPacketSize = options.maxPacketSize;
this.charsetNumber = options.charsetNumber;
}
SSLRequestPacket.prototype.parse = function(parser) {
// TODO: check SSLRequest packet v41 vs pre v41
this.clientFlags = parser.parseUnsignedNumber(4);
this.maxPacketSize = parser.parseUnsignedNumber(4);
this.charsetNumber = parser.parseUnsignedNumber(1);
};
SSLRequestPacket.prototype.write = function(writer) {
writer.writeUnsignedNumber(4, this.clientFlags);
writer.writeUnsignedNumber(4, this.maxPacketSize);
writer.writeUnsignedNumber(1, this.charsetNumber);
writer.writeFiller(23);
};
module.exports = StatisticsPacket;
function StatisticsPacket() {
this.message = undefined;
}
StatisticsPacket.prototype.parse = function(parser) {
this.message = parser.parsePacketTerminatedString();
var items = this.message.split(/\s\s/);
for (var i = 0; i < items.length; i++) {
var m = items[i].match(/^(.+)\:\s+(.+)$/);
if (m !== null) {
this[m[1].toLowerCase().replace(/\s/g, '_')] = Number(m[2]);
}
}
};
StatisticsPacket.prototype.write = function(writer) {
writer.writeString(this.message);
};
module.exports = UseOldPasswordPacket;
function UseOldPasswordPacket(options) {
options = options || {};
this.firstByte = options.firstByte || 0xfe;
}
UseOldPasswordPacket.prototype.parse = function(parser) {
this.firstByte = parser.parseUnsignedNumber(1);
};
UseOldPasswordPacket.prototype.write = function(writer) {
writer.writeUnsignedNumber(1, this.firstByte);
};
exports.AuthSwitchRequestPacket = require('./AuthSwitchRequestPacket');
exports.AuthSwitchResponsePacket = require('./AuthSwitchResponsePacket');
exports.ClientAuthenticationPacket = require('./ClientAuthenticationPacket');
exports.ComChangeUserPacket = require('./ComChangeUserPacket');
exports.ComPingPacket = require('./ComPingPacket');
exports.ComQueryPacket = require('./ComQueryPacket');
exports.ComQuitPacket = require('./ComQuitPacket');
exports.ComStatisticsPacket = require('./ComStatisticsPacket');
exports.EmptyPacket = require('./EmptyPacket');
exports.EofPacket = require('./EofPacket');
exports.ErrorPacket = require('./ErrorPacket');
exports.Field = require('./Field');
exports.FieldPacket = require('./FieldPacket');
exports.HandshakeInitializationPacket = require('./HandshakeInitializationPacket');
exports.LocalDataFilePacket = require('./LocalDataFilePacket');
exports.LocalInfileRequestPacket = require('./LocalInfileRequestPacket');
exports.OkPacket = require('./OkPacket');
exports.OldPasswordPacket = require('./OldPasswordPacket');
exports.ResultSetHeaderPacket = require('./ResultSetHeaderPacket');
exports.RowDataPacket = require('./RowDataPacket');
exports.SSLRequestPacket = require('./SSLRequestPacket');
exports.StatisticsPacket = require('./StatisticsPacket');
exports.UseOldPasswordPacket = require('./UseOldPasswordPacket');
var Sequence = require('./Sequence');
var Util = require('util');
var Packets = require('../packets');
var Auth = require('../Auth');
module.exports = ChangeUser;
Util.inherits(ChangeUser, Sequence);
function ChangeUser(options, callback) {
Sequence.call(this, options, callback);
this._user = options.user;
this._password = options.password;
this._database = options.database;
this._charsetNumber = options.charsetNumber;
this._currentConfig = options.currentConfig;
}
ChangeUser.prototype.determinePacket = function determinePacket(firstByte) {
switch (firstByte) {
case 0xfe: return Packets.AuthSwitchRequestPacket;
case 0xff: return Packets.ErrorPacket;
default: return undefined;
}
};
ChangeUser.prototype.start = function(handshakeInitializationPacket) {
var scrambleBuff = handshakeInitializationPacket.scrambleBuff();
scrambleBuff = Auth.token(this._password, scrambleBuff);
var packet = new Packets.ComChangeUserPacket({
user : this._user,
scrambleBuff : scrambleBuff,
database : this._database,
charsetNumber : this._charsetNumber
});
this._currentConfig.user = this._user;
this._currentConfig.password = this._password;
this._currentConfig.database = this._database;
this._currentConfig.charsetNumber = this._charsetNumber;
this.emit('packet', packet);
};
ChangeUser.prototype['AuthSwitchRequestPacket'] = function (packet) {
var name = packet.authMethodName;
var data = Auth.auth(name, packet.authMethodData, {
password: this._password
});
if (data !== undefined) {
this.emit('packet', new Packets.AuthSwitchResponsePacket({
data: data
}));
} else {
var err = new Error('MySQL is requesting the ' + name + ' authentication method, which is not supported.');
err.code = 'UNSUPPORTED_AUTH_METHOD';
err.fatal = true;
this.end(err);
}
};
ChangeUser.prototype['ErrorPacket'] = function(packet) {
var err = this._packetToError(packet);
err.fatal = true;
this.end(err);
};
var Sequence = require('./Sequence');
var Util = require('util');
var Packets = require('../packets');
var Auth = require('../Auth');
var ClientConstants = require('../constants/client');
module.exports = Handshake;
Util.inherits(Handshake, Sequence);
function Handshake(options, callback) {
Sequence.call(this, options, callback);
options = options || {};
this._config = options.config;
this._handshakeInitializationPacket = null;
}
Handshake.prototype.determinePacket = function determinePacket(firstByte, parser) {
if (firstByte === 0xff) {
return Packets.ErrorPacket;
}
if (!this._handshakeInitializationPacket) {
return Packets.HandshakeInitializationPacket;
}
if (firstByte === 0xfe) {
return (parser.packetLength() === 1)
? Packets.UseOldPasswordPacket
: Packets.AuthSwitchRequestPacket;
}
return undefined;
};
Handshake.prototype['AuthSwitchRequestPacket'] = function (packet) {
var name = packet.authMethodName;
var data = Auth.auth(name, packet.authMethodData, {
password: this._config.password
});
if (data !== undefined) {
this.emit('packet', new Packets.AuthSwitchResponsePacket({
data: data
}));
} else {
var err = new Error('MySQL is requesting the ' + name + ' authentication method, which is not supported.');
err.code = 'UNSUPPORTED_AUTH_METHOD';
err.fatal = true;
this.end(err);
}
};
Handshake.prototype['HandshakeInitializationPacket'] = function(packet) {
this._handshakeInitializationPacket = packet;
this._config.protocol41 = packet.protocol41;
var serverSSLSupport = packet.serverCapabilities1 & ClientConstants.CLIENT_SSL;
if (this._config.ssl) {
if (!serverSSLSupport) {
var err = new Error('Server does not support secure connection');
err.code = 'HANDSHAKE_NO_SSL_SUPPORT';
err.fatal = true;
this.end(err);
return;
}
this._config.clientFlags |= ClientConstants.CLIENT_SSL;
this.emit('packet', new Packets.SSLRequestPacket({
clientFlags : this._config.clientFlags,
maxPacketSize : this._config.maxPacketSize,
charsetNumber : this._config.charsetNumber
}));
this.emit('start-tls');
} else {
this._sendCredentials();
}
};
Handshake.prototype._tlsUpgradeCompleteHandler = function() {
this._sendCredentials();
};
Handshake.prototype._sendCredentials = function() {
var packet = this._handshakeInitializationPacket;
this.emit('packet', new Packets.ClientAuthenticationPacket({
clientFlags : this._config.clientFlags,
maxPacketSize : this._config.maxPacketSize,
charsetNumber : this._config.charsetNumber,
user : this._config.user,
database : this._config.database,
protocol41 : packet.protocol41,
scrambleBuff : (packet.protocol41)
? Auth.token(this._config.password, packet.scrambleBuff())
: Auth.scramble323(packet.scrambleBuff(), this._config.password)
}));
};
Handshake.prototype['UseOldPasswordPacket'] = function() {
if (!this._config.insecureAuth) {
var err = new Error(
'MySQL server is requesting the old and insecure pre-4.1 auth mechanism. ' +
'Upgrade the user password or use the {insecureAuth: true} option.'
);
err.code = 'HANDSHAKE_INSECURE_AUTH';
err.fatal = true;
this.end(err);
return;
}
this.emit('packet', new Packets.OldPasswordPacket({
scrambleBuff: Auth.scramble323(this._handshakeInitializationPacket.scrambleBuff(), this._config.password)
}));
};
Handshake.prototype['ErrorPacket'] = function(packet) {
var err = this._packetToError(packet, true);
err.fatal = true;
this.end(err);
};
var Sequence = require('./Sequence');
var Util = require('util');
var Packets = require('../packets');
module.exports = Ping;
Util.inherits(Ping, Sequence);
function Ping(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
Sequence.call(this, options, callback);
}
Ping.prototype.start = function() {
this.emit('packet', new Packets.ComPingPacket());
};
var ClientConstants = require('../constants/client');
var fs = require('fs');
var Packets = require('../packets');
var ResultSet = require('../ResultSet');
var Sequence = require('./Sequence');
var ServerStatus = require('../constants/server_status');
var Readable = require('readable-stream');
var Util = require('util');
module.exports = Query;
Util.inherits(Query, Sequence);
function Query(options, callback) {
Sequence.call(this, options, callback);
this.sql = options.sql;
this.values = options.values;
this.typeCast = (options.typeCast === undefined)
? true
: options.typeCast;
this.nestTables = options.nestTables || false;
this._resultSet = null;
this._results = [];
this._fields = [];
this._index = 0;
this._loadError = null;
}
Query.prototype.start = function() {
this.emit('packet', new Packets.ComQueryPacket(this.sql));
};
Query.prototype.determinePacket = function determinePacket(byte, parser) {
var resultSet = this._resultSet;
if (!resultSet) {
switch (byte) {
case 0x00: return Packets.OkPacket;
case 0xfb: return Packets.LocalInfileRequestPacket;
case 0xff: return Packets.ErrorPacket;
default: return Packets.ResultSetHeaderPacket;
}
}
if (resultSet.eofPackets.length === 0) {
return (resultSet.fieldPackets.length < resultSet.resultSetHeaderPacket.fieldCount)
? Packets.FieldPacket
: Packets.EofPacket;
}
if (byte === 0xff) {
return Packets.ErrorPacket;
}
if (byte === 0xfe && parser.packetLength() < 9) {
return Packets.EofPacket;
}
return Packets.RowDataPacket;
};
Query.prototype['OkPacket'] = function(packet) {
// try...finally for exception safety
try {
if (!this._callback) {
this.emit('result', packet, this._index);
} else {
this._results.push(packet);
this._fields.push(undefined);
}
} finally {
this._index++;
this._resultSet = null;
this._handleFinalResultPacket(packet);
}
};
Query.prototype['ErrorPacket'] = function(packet) {
var err = this._packetToError(packet);
var results = (this._results.length > 0)
? this._results
: undefined;
var fields = (this._fields.length > 0)
? this._fields
: undefined;
err.index = this._index;
err.sql = this.sql;
this.end(err, results, fields);
};
Query.prototype['LocalInfileRequestPacket'] = function(packet) {
if (this._connection.config.clientFlags & ClientConstants.CLIENT_LOCAL_FILES) {
this._sendLocalDataFile(packet.filename);
} else {
this._loadError = new Error('Load local files command is disabled');
this._loadError.code = 'LOCAL_FILES_DISABLED';
this._loadError.fatal = false;
this.emit('packet', new Packets.EmptyPacket());
}
};
Query.prototype['ResultSetHeaderPacket'] = function(packet) {
this._resultSet = new ResultSet(packet);
};
Query.prototype['FieldPacket'] = function(packet) {
this._resultSet.fieldPackets.push(packet);
};
Query.prototype['EofPacket'] = function(packet) {
this._resultSet.eofPackets.push(packet);
if (this._resultSet.eofPackets.length === 1 && !this._callback) {
this.emit('fields', this._resultSet.fieldPackets, this._index);
}
if (this._resultSet.eofPackets.length !== 2) {
return;
}
if (this._callback) {
this._results.push(this._resultSet.rows);
this._fields.push(this._resultSet.fieldPackets);
}
this._index++;
this._resultSet = null;
this._handleFinalResultPacket(packet);
};
Query.prototype._handleFinalResultPacket = function(packet) {
if (packet.serverStatus & ServerStatus.SERVER_MORE_RESULTS_EXISTS) {
return;
}
var results = (this._results.length > 1)
? this._results
: this._results[0];
var fields = (this._fields.length > 1)
? this._fields
: this._fields[0];
this.end(this._loadError, results, fields);
};
Query.prototype['RowDataPacket'] = function(packet, parser, connection) {
packet.parse(parser, this._resultSet.fieldPackets, this.typeCast, this.nestTables, connection);
if (this._callback) {
this._resultSet.rows.push(packet);
} else {
this.emit('result', packet, this._index);
}
};
Query.prototype._sendLocalDataFile = function(path) {
var self = this;
var localStream = fs.createReadStream(path, {
flag : 'r',
encoding : null,
autoClose : true
});
this.on('pause', function () {
localStream.pause();
});
this.on('resume', function () {
localStream.resume();
});
localStream.on('data', function (data) {
self.emit('packet', new Packets.LocalDataFilePacket(data));
});
localStream.on('error', function (err) {
self._loadError = err;
localStream.emit('end');
});
localStream.on('end', function () {
self.emit('packet', new Packets.EmptyPacket());
});
};
Query.prototype.stream = function(options) {
var self = this;
options = options || {};
options.objectMode = true;
var stream = new Readable(options);
stream._read = function() {
self._connection && self._connection.resume();
};
stream.once('end', function() {
process.nextTick(function () {
stream.emit('close');
});
});
this.on('result', function(row, i) {
if (!stream.push(row)) self._connection.pause();
stream.emit('result', row, i); // replicate old emitter
});
this.on('error', function(err) {
stream.emit('error', err); // Pass on any errors
});
this.on('end', function() {
stream.push(null); // pushing null, indicating EOF
});
this.on('fields', function(fields, i) {
stream.emit('fields', fields, i); // replicate old emitter
});
return stream;
};
var Sequence = require('./Sequence');
var Util = require('util');
var Packets = require('../packets');
module.exports = Quit;
Util.inherits(Quit, Sequence);
function Quit(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
Sequence.call(this, options, callback);
this._started = false;
}
Quit.prototype.end = function end(err) {
if (this._ended) {
return;
}
if (!this._started) {
Sequence.prototype.end.call(this, err);
return;
}
if (err && err.code === 'ECONNRESET' && err.syscall === 'read') {
// Ignore read errors after packet sent
Sequence.prototype.end.call(this);
return;
}
Sequence.prototype.end.call(this, err);
};
Quit.prototype.start = function() {
this._started = true;
this.emit('packet', new Packets.ComQuitPacket());
};
var Util = require('util');
var EventEmitter = require('events').EventEmitter;
var Packets = require('../packets');
var ErrorConstants = require('../constants/errors');
var Timer = require('../Timer');
// istanbul ignore next: Node.js < 0.10 not covered
var listenerCount = EventEmitter.listenerCount
|| function(emitter, type){ return emitter.listeners(type).length; };
var LONG_STACK_DELIMITER = '\n --------------------\n';
module.exports = Sequence;
Util.inherits(Sequence, EventEmitter);
function Sequence(options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
EventEmitter.call(this);
options = options || {};
this._callback = callback;
this._callSite = null;
this._ended = false;
this._timeout = options.timeout;
this._timer = new Timer(this);
}
Sequence.determinePacket = function(byte) {
switch (byte) {
case 0x00: return Packets.OkPacket;
case 0xfe: return Packets.EofPacket;
case 0xff: return Packets.ErrorPacket;
default: return undefined;
}
};
Sequence.prototype.hasErrorHandler = function() {
return Boolean(this._callback) || listenerCount(this, 'error') > 1;
};
Sequence.prototype._packetToError = function(packet) {
var code = ErrorConstants[packet.errno] || 'UNKNOWN_CODE_PLEASE_REPORT';
var err = new Error(code + ': ' + packet.message);
err.code = code;
err.errno = packet.errno;
err.sqlMessage = packet.message;
err.sqlState = packet.sqlState;
return err;
};
Sequence.prototype.end = function(err) {
if (this._ended) {
return;
}
this._ended = true;
if (err) {
this._addLongStackTrace(err);
}
// Without this we are leaking memory. This problem was introduced in
// 8189925374e7ce3819bbe88b64c7b15abac96b16. I suspect that the error object
// causes a cyclic reference that the GC does not detect properly, but I was
// unable to produce a standalone version of this leak. This would be a great
// challenge for somebody interested in difficult problems : )!
this._callSite = null;
// try...finally for exception safety
try {
if (err) {
this.emit('error', err);
}
} finally {
try {
if (this._callback) {
this._callback.apply(this, arguments);
}
} finally {
this.emit('end');
}
}
};
Sequence.prototype['OkPacket'] = function(packet) {
this.end(null, packet);
};
Sequence.prototype['ErrorPacket'] = function(packet) {
this.end(this._packetToError(packet));
};
// Implemented by child classes
Sequence.prototype.start = function() {};
Sequence.prototype._addLongStackTrace = function _addLongStackTrace(err) {
var callSiteStack = this._callSite && this._callSite.stack;
if (!callSiteStack || typeof callSiteStack !== 'string') {
// No recorded call site
return;
}
if (err.stack.indexOf(LONG_STACK_DELIMITER) !== -1) {
// Error stack already looks long
return;
}
var index = callSiteStack.indexOf('\n');
if (index !== -1) {
// Append recorded call site
err.stack += LONG_STACK_DELIMITER + callSiteStack.substr(index + 1);
}
};
Sequence.prototype._onTimeout = function _onTimeout() {
this.emit('timeout');
};
var Sequence = require('./Sequence');
var Util = require('util');
var Packets = require('../packets');
module.exports = Statistics;
Util.inherits(Statistics, Sequence);
function Statistics(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = {};
}
Sequence.call(this, options, callback);
}
Statistics.prototype.start = function() {
this.emit('packet', new Packets.ComStatisticsPacket());
};
Statistics.prototype['StatisticsPacket'] = function (packet) {
this.end(null, packet);
};
Statistics.prototype.determinePacket = function determinePacket(firstByte) {
if (firstByte === 0x55) {
return Packets.StatisticsPacket;
}
return undefined;
};
exports.ChangeUser = require('./ChangeUser');
exports.Handshake = require('./Handshake');
exports.Ping = require('./Ping');
exports.Query = require('./Query');
exports.Quit = require('./Quit');
exports.Sequence = require('./Sequence');
exports.Statistics = require('./Statistics');
{
"_from": "mysql",
"_id": "mysql@2.18.1",
"_inBundle": false,
"_integrity": "sha512-Bca+gk2YWmqp2Uf6k5NFEurwY/0td0cpebAucFpY/3jhrwrVGuxU2uQFCHjU19SJfje0yQvi+rVWdq78hR5lig==",
"_location": "/mysql",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "mysql",
"name": "mysql",
"escapedName": "mysql",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz",
"_shasum": "2254143855c5a8c73825e4522baf2ea021766717",
"_spec": "mysql",
"_where": "C:\\Users\\user\\Desktop\\Singer-Composer",
"author": {
"name": "Felix Geisendörfer",
"email": "felix@debuggable.com",
"url": "http://debuggable.com/"
},
"bugs": {
"url": "https://github.com/mysqljs/mysql/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Andrey Sidorov",
"email": "sidorares@yandex.ru"
},
{
"name": "Bradley Grainger",
"email": "bgrainger@gmail.com"
},
{
"name": "Douglas Christopher Wilson",
"email": "doug@somethingdoug.com"
},
{
"name": "Diogo Resende",
"email": "dresende@thinkdigital.pt"
},
{
"name": "Nathan Woltman",
"email": "nwoltman@outlook.com"
}
],
"dependencies": {
"bignumber.js": "9.0.0",
"readable-stream": "2.3.7",
"safe-buffer": "5.1.2",
"sqlstring": "2.3.1"
},
"deprecated": false,
"description": "A node.js driver for mysql. It is written in JavaScript, does not require compiling, and is 100% MIT licensed.",
"devDependencies": {
"after": "0.8.2",
"eslint": "5.16.0",
"seedrandom": "3.0.5",
"timezone-mock": "0.0.7",
"urun": "0.0.8",
"utest": "0.0.8"
},
"engines": {
"node": ">= 0.6"
},
"files": [
"lib/",
"Changes.md",
"License",
"Readme.md",
"index.js"
],
"homepage": "https://github.com/mysqljs/mysql#readme",
"license": "MIT",
"name": "mysql",
"repository": {
"type": "git",
"url": "git+https://github.com/mysqljs/mysql.git"
},
"scripts": {
"lint": "eslint . && node tool/lint-readme.js",
"test": "node test/run.js",
"test-ci": "node tool/install-nyc.js --nyc-optional --reporter=text -- npm test",
"test-cov": "node tool/install-nyc.js --reporter=html --reporter=text -- npm test",
"version": "node tool/version-changes.js && git add Changes.md"
},
"version": "2.18.1"
}
'use strict';
if (typeof process === 'undefined' ||
!process.version ||
process.version.indexOf('v0.') === 0 ||
process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
module.exports = { nextTick: nextTick };
} else {
module.exports = process
}
function nextTick(fn, arg1, arg2, arg3) {
if (typeof fn !== 'function') {
throw new TypeError('"callback" argument must be a function');
}
var len = arguments.length;
var args, i;
switch (len) {
case 0:
case 1:
return process.nextTick(fn);
case 2:
return process.nextTick(function afterTickOne() {
fn.call(null, arg1);
});
case 3:
return process.nextTick(function afterTickTwo() {
fn.call(null, arg1, arg2);
});
case 4:
return process.nextTick(function afterTickThree() {
fn.call(null, arg1, arg2, arg3);
});
default:
args = new Array(len - 1);
i = 0;
while (i < args.length) {
args[i++] = arguments[i];
}
return process.nextTick(function afterTick() {
fn.apply(null, args);
});
}
}
# Copyright (c) 2015 Calvin Metcalf
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.**
{
"_from": "process-nextick-args@~2.0.0",
"_id": "process-nextick-args@2.0.1",
"_inBundle": false,
"_integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
"_location": "/process-nextick-args",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "process-nextick-args@~2.0.0",
"name": "process-nextick-args",
"escapedName": "process-nextick-args",
"rawSpec": "~2.0.0",
"saveSpec": null,
"fetchSpec": "~2.0.0"
},
"_requiredBy": [
"/readable-stream"
],
"_resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"_shasum": "7820d9b16120cc55ca9ae7792680ae7dba6d7fe2",
"_spec": "process-nextick-args@~2.0.0",
"_where": "C:\\Users\\user\\Desktop\\Singer-Composer\\node_modules\\readable-stream",
"author": "",
"bugs": {
"url": "https://github.com/calvinmetcalf/process-nextick-args/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "process.nextTick but always with args",
"devDependencies": {
"tap": "~0.2.6"
},
"files": [
"index.js"
],
"homepage": "https://github.com/calvinmetcalf/process-nextick-args",
"license": "MIT",
"main": "index.js",
"name": "process-nextick-args",
"repository": {
"type": "git",
"url": "git+https://github.com/calvinmetcalf/process-nextick-args.git"
},
"scripts": {
"test": "node test.js"
},
"version": "2.0.1"
}
process-nextick-args
=====
[![Build Status](https://travis-ci.org/calvinmetcalf/process-nextick-args.svg?branch=master)](https://travis-ci.org/calvinmetcalf/process-nextick-args)
```bash
npm install --save process-nextick-args
```
Always be able to pass arguments to process.nextTick, no matter the platform
```js
var pna = require('process-nextick-args');
pna.nextTick(function (a, b, c) {
console.log(a, b, c);
}, 'step', 3, 'profit');
```
sudo: false
language: node_js
before_install:
- (test $NPM_LEGACY && npm install -g npm@2 && npm install -g npm@3) || true
notifications:
email: false
matrix:
fast_finish: true
include:
- node_js: '0.8'
env: NPM_LEGACY=true
- node_js: '0.10'
env: NPM_LEGACY=true
- node_js: '0.11'
env: NPM_LEGACY=true
- node_js: '0.12'
env: NPM_LEGACY=true
- node_js: 1
env: NPM_LEGACY=true
- node_js: 2
env: NPM_LEGACY=true
- node_js: 3
env: NPM_LEGACY=true
- node_js: 4
- node_js: 5
- node_js: 6
- node_js: 7
- node_js: 8
- node_js: 9
script: "npm run test"
env:
global:
- secure: rE2Vvo7vnjabYNULNyLFxOyt98BoJexDqsiOnfiD6kLYYsiQGfr/sbZkPMOFm9qfQG7pjqx+zZWZjGSswhTt+626C0t/njXqug7Yps4c3dFblzGfreQHp7wNX5TFsvrxd6dAowVasMp61sJcRnB2w8cUzoe3RAYUDHyiHktwqMc=
- secure: g9YINaKAdMatsJ28G9jCGbSaguXCyxSTy+pBO6Ch0Cf57ZLOTka3HqDj8p3nV28LUIHZ3ut5WO43CeYKwt4AUtLpBS3a0dndHdY6D83uY6b2qh5hXlrcbeQTq2cvw2y95F7hm4D1kwrgZ7ViqaKggRcEupAL69YbJnxeUDKWEdI=
# Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
* (a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
* (b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
* (c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
* (d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
## Moderation Policy
The [Node.js Moderation Policy] applies to this WG.
## Code of Conduct
The [Node.js Code of Conduct][] applies to this WG.
[Node.js Code of Conduct]:
https://github.com/nodejs/node/blob/master/CODE_OF_CONDUCT.md
[Node.js Moderation Policy]:
https://github.com/nodejs/TSC/blob/master/Moderation-Policy.md
### Streams Working Group
The Node.js Streams is jointly governed by a Working Group
(WG)
that is responsible for high-level guidance of the project.
The WG has final authority over this project including:
* Technical direction
* Project governance and process (including this policy)
* Contribution policy
* GitHub repository hosting
* Conduct guidelines
* Maintaining the list of additional Collaborators
For the current list of WG members, see the project
[README.md](./README.md#current-project-team-members).
### Collaborators
The readable-stream GitHub repository is
maintained by the WG and additional Collaborators who are added by the
WG on an ongoing basis.
Individuals making significant and valuable contributions are made
Collaborators and given commit-access to the project. These
individuals are identified by the WG and their addition as
Collaborators is discussed during the WG meeting.
_Note:_ If you make a significant contribution and are not considered
for commit-access log an issue or contact a WG member directly and it
will be brought up in the next WG meeting.
Modifications of the contents of the readable-stream repository are
made on
a collaborative basis. Anybody with a GitHub account may propose a
modification via pull request and it will be considered by the project
Collaborators. All pull requests must be reviewed and accepted by a
Collaborator with sufficient expertise who is able to take full
responsibility for the change. In the case of pull requests proposed
by an existing Collaborator, an additional Collaborator is required
for sign-off. Consensus should be sought if additional Collaborators
participate and there is disagreement around a particular
modification. See _Consensus Seeking Process_ below for further detail
on the consensus model used for governance.
Collaborators may opt to elevate significant or controversial
modifications, or modifications that have not found consensus to the
WG for discussion by assigning the ***WG-agenda*** tag to a pull
request or issue. The WG should serve as the final arbiter where
required.
For the current list of Collaborators, see the project
[README.md](./README.md#members).
### WG Membership
WG seats are not time-limited. There is no fixed size of the WG.
However, the expected target is between 6 and 12, to ensure adequate
coverage of important areas of expertise, balanced with the ability to
make decisions efficiently.
There is no specific set of requirements or qualifications for WG
membership beyond these rules.
The WG may add additional members to the WG by unanimous consensus.
A WG member may be removed from the WG by voluntary resignation, or by
unanimous consensus of all other WG members.
Changes to WG membership should be posted in the agenda, and may be
suggested as any other agenda item (see "WG Meetings" below).
If an addition or removal is proposed during a meeting, and the full
WG is not in attendance to participate, then the addition or removal
is added to the agenda for the subsequent meeting. This is to ensure
that all members are given the opportunity to participate in all
membership decisions. If a WG member is unable to attend a meeting
where a planned membership decision is being made, then their consent
is assumed.
No more than 1/3 of the WG members may be affiliated with the same
employer. If removal or resignation of a WG member, or a change of
employment by a WG member, creates a situation where more than 1/3 of
the WG membership shares an employer, then the situation must be
immediately remedied by the resignation or removal of one or more WG
members affiliated with the over-represented employer(s).
### WG Meetings
The WG meets occasionally on a Google Hangout On Air. A designated moderator
approved by the WG runs the meeting. Each meeting should be
published to YouTube.
Items are added to the WG agenda that are considered contentious or
are modifications of governance, contribution policy, WG membership,
or release process.
The intention of the agenda is not to approve or review all patches;
that should happen continuously on GitHub and be handled by the larger
group of Collaborators.
Any community member or contributor can ask that something be added to
the next meeting's agenda by logging a GitHub Issue. Any Collaborator,
WG member or the moderator can add the item to the agenda by adding
the ***WG-agenda*** tag to the issue.
Prior to each WG meeting the moderator will share the Agenda with
members of the WG. WG members can add any items they like to the
agenda at the beginning of each meeting. The moderator and the WG
cannot veto or remove items.
The WG may invite persons or representatives from certain projects to
participate in a non-voting capacity.
The moderator is responsible for summarizing the discussion of each
agenda item and sends it as a pull request after the meeting.
### Consensus Seeking Process
The WG follows a
[Consensus
Seeking](http://en.wikipedia.org/wiki/Consensus-seeking_decision-making)
decision-making model.
When an agenda item has appeared to reach a consensus the moderator
will ask "Does anyone object?" as a final call for dissent from the
consensus.
If an agenda item cannot reach a consensus a WG member can call for
either a closing vote or a vote to table the issue to the next
meeting. The call for a vote must be seconded by a majority of the WG
or else the discussion will continue. Simple majority wins.
Note that changes to WG membership require a majority consensus. See
"WG Membership" above.
Node.js is licensed for use as follows:
"""
Copyright Node.js contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""
This license applies to parts of Node.js originating from the
https://github.com/joyent/node repository:
"""
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""
# readable-stream
***Node-core v8.11.1 streams for userland*** [![Build Status](https://travis-ci.org/nodejs/readable-stream.svg?branch=master)](https://travis-ci.org/nodejs/readable-stream)
[![NPM](https://nodei.co/npm/readable-stream.png?downloads=true&downloadRank=true)](https://nodei.co/npm/readable-stream/)
[![NPM](https://nodei.co/npm-dl/readable-stream.png?&months=6&height=3)](https://nodei.co/npm/readable-stream/)
[![Sauce Test Status](https://saucelabs.com/browser-matrix/readable-stream.svg)](https://saucelabs.com/u/readable-stream)
```bash
npm install --save readable-stream
```
***Node-core streams for userland***
This package is a mirror of the Streams2 and Streams3 implementations in
Node-core.
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.11.1/docs/api/stream.html).
If you want to guarantee a stable streams base, regardless of what version of
Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).
As of version 2.0.0 **readable-stream** uses semantic versioning.
# Streams Working Group
`readable-stream` is maintained by the Streams Working Group, which
oversees the development and maintenance of the Streams API within
Node.js. The responsibilities of the Streams Working Group include:
* Addressing stream issues on the Node.js issue tracker.
* Authoring and editing stream documentation within the Node.js project.
* Reviewing changes to stream subclasses within the Node.js project.
* Redirecting changes to streams from the Node.js project to this
project.
* Assisting in the implementation of stream providers within Node.js.
* Recommending versions of `readable-stream` to be included in Node.js.
* Messaging about the future of streams to give the community advance
notice of changes.
<a name="members"></a>
## Team Members
* **Chris Dickinson** ([@chrisdickinson](https://github.com/chrisdickinson)) &lt;christopher.s.dickinson@gmail.com&gt;
- Release GPG key: 9554F04D7259F04124DE6B476D5A82AC7E37093B
* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) &lt;calvin.metcalf@gmail.com&gt;
- Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
* **Rod Vagg** ([@rvagg](https://github.com/rvagg)) &lt;rod@vagg.org&gt;
- Release GPG key: DD8F2338BAE7501E3DD5AC78C273792F7D83545D
* **Sam Newman** ([@sonewman](https://github.com/sonewman)) &lt;newmansam@outlook.com&gt;
* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) &lt;mathiasbuus@gmail.com&gt;
* **Domenic Denicola** ([@domenic](https://github.com/domenic)) &lt;d@domenic.me&gt;
* **Matteo Collina** ([@mcollina](https://github.com/mcollina)) &lt;matteo.collina@gmail.com&gt;
- Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E
* **Irina Shestak** ([@lrlna](https://github.com/lrlna)) &lt;shestak.irina@gmail.com&gt;
# streams WG Meeting 2015-01-30
## Links
* **Google Hangouts Video**: http://www.youtube.com/watch?v=I9nDOSGfwZg
* **GitHub Issue**: https://github.com/iojs/readable-stream/issues/106
* **Original Minutes Google Doc**: https://docs.google.com/document/d/17aTgLnjMXIrfjgNaTUnHQO7m3xgzHR2VXBTmi03Qii4/
## Agenda
Extracted from https://github.com/iojs/readable-stream/labels/wg-agenda prior to meeting.
* adopt a charter [#105](https://github.com/iojs/readable-stream/issues/105)
* release and versioning strategy [#101](https://github.com/iojs/readable-stream/issues/101)
* simpler stream creation [#102](https://github.com/iojs/readable-stream/issues/102)
* proposal: deprecate implicit flowing of streams [#99](https://github.com/iojs/readable-stream/issues/99)
## Minutes
### adopt a charter
* group: +1's all around
### What versioning scheme should be adopted?
* group: +1’s 3.0.0
* domenic+group: pulling in patches from other sources where appropriate
* mikeal: version independently, suggesting versions for io.js
* mikeal+domenic: work with TC to notify in advance of changes
simpler stream creation
### streamline creation of streams
* sam: streamline creation of streams
* domenic: nice simple solution posted
but, we lose the opportunity to change the model
may not be backwards incompatible (double check keys)
**action item:** domenic will check
### remove implicit flowing of streams on(‘data’)
* add isFlowing / isPaused
* mikeal: worrying that we’re documenting polyfill methods – confuses users
* domenic: more reflective API is probably good, with warning labels for users
* new section for mad scientists (reflective stream access)
* calvin: name the “third state”
* mikeal: maybe borrow the name from whatwg?
* domenic: we’re missing the “third state”
* consensus: kind of difficult to name the third state
* mikeal: figure out differences in states / compat
* mathias: always flow on data – eliminates third state
* explore what it breaks
**action items:**
* ask isaac for ability to list packages by what public io.js APIs they use (esp. Stream)
* ask rod/build for infrastructure
* **chris**: explore the “flow on data” approach
* add isPaused/isFlowing
* add new docs section
* move isPaused to that section
module.exports = require('./lib/_stream_duplex.js');
module.exports = require('./readable').Duplex
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// a duplex stream is just a stream that is both readable and writable.
// Since JS doesn't have multiple prototypal inheritance, this class
// prototypally inherits from Readable, and then parasitically from
// Writable.
'use strict';
/*<replacement>*/
var pna = require('process-nextick-args');
/*</replacement>*/
/*<replacement>*/
var objectKeys = Object.keys || function (obj) {
var keys = [];
for (var key in obj) {
keys.push(key);
}return keys;
};
/*</replacement>*/
module.exports = Duplex;
/*<replacement>*/
var util = Object.create(require('core-util-is'));
util.inherits = require('inherits');
/*</replacement>*/
var Readable = require('./_stream_readable');
var Writable = require('./_stream_writable');
util.inherits(Duplex, Readable);
{
// avoid scope creep, the keys array can then be collected
var keys = objectKeys(Writable.prototype);
for (var v = 0; v < keys.length; v++) {
var method = keys[v];
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
}
}
function Duplex(options) {
if (!(this instanceof Duplex)) return new Duplex(options);
Readable.call(this, options);
Writable.call(this, options);
if (options && options.readable === false) this.readable = false;
if (options && options.writable === false) this.writable = false;
this.allowHalfOpen = true;
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
this.once('end', onend);
}
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function () {
return this._writableState.highWaterMark;
}
});
// the no-half-open enforcer
function onend() {
// if we allow half-open state, or if the writable side ended,
// then we're ok.
if (this.allowHalfOpen || this._writableState.ended) return;
// no more data can be written.
// But allow more writes to happen in this tick.
pna.nextTick(onEndNT, this);
}
function onEndNT(self) {
self.end();
}
Object.defineProperty(Duplex.prototype, 'destroyed', {
get: function () {
if (this._readableState === undefined || this._writableState === undefined) {
return false;
}
return this._readableState.destroyed && this._writableState.destroyed;
},
set: function (value) {
// we ignore the value if the stream
// has not been initialized yet
if (this._readableState === undefined || this._writableState === undefined) {
return;
}
// backward compatibility, the user is explicitly
// managing destroyed
this._readableState.destroyed = value;
this._writableState.destroyed = value;
}
});
Duplex.prototype._destroy = function (err, cb) {
this.push(null);
this.end();
pna.nextTick(cb, err);
};
\ No newline at end of file
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// a passthrough stream.
// basically just the most minimal sort of Transform stream.
// Every written chunk gets output as-is.
'use strict';
module.exports = PassThrough;
var Transform = require('./_stream_transform');
/*<replacement>*/
var util = Object.create(require('core-util-is'));
util.inherits = require('inherits');
/*</replacement>*/
util.inherits(PassThrough, Transform);
function PassThrough(options) {
if (!(this instanceof PassThrough)) return new PassThrough(options);
Transform.call(this, options);
}
PassThrough.prototype._transform = function (chunk, encoding, cb) {
cb(null, chunk);
};
\ No newline at end of file
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
/*<replacement>*/
var pna = require('process-nextick-args');
/*</replacement>*/
module.exports = Readable;
/*<replacement>*/
var isArray = require('isarray');
/*</replacement>*/
/*<replacement>*/
var Duplex;
/*</replacement>*/
Readable.ReadableState = ReadableState;
/*<replacement>*/
var EE = require('events').EventEmitter;
var EElistenerCount = function (emitter, type) {
return emitter.listeners(type).length;
};
/*</replacement>*/
/*<replacement>*/
var Stream = require('./internal/streams/stream');
/*</replacement>*/
/*<replacement>*/
var Buffer = require('safe-buffer').Buffer;
var OurUint8Array = global.Uint8Array || function () {};
function _uint8ArrayToBuffer(chunk) {
return Buffer.from(chunk);
}
function _isUint8Array(obj) {
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
}
/*</replacement>*/
/*<replacement>*/
var util = Object.create(require('core-util-is'));
util.inherits = require('inherits');
/*</replacement>*/
/*<replacement>*/
var debugUtil = require('util');
var debug = void 0;
if (debugUtil && debugUtil.debuglog) {
debug = debugUtil.debuglog('stream');
} else {
debug = function () {};
}
/*</replacement>*/
var BufferList = require('./internal/streams/BufferList');
var destroyImpl = require('./internal/streams/destroy');
var StringDecoder;
util.inherits(Readable, Stream);
var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
function prependListener(emitter, event, fn) {
// Sadly this is not cacheable as some libraries bundle their own
// event emitter implementation with them.
if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
// This is a hack to make sure that our error handler is attached before any
// userland ones. NEVER DO THIS. This is here only because this code needs
// to continue to work with older versions of Node.js that do not include
// the prependListener() method. The goal is to eventually remove this hack.
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
}
function ReadableState(options, stream) {
Duplex = Duplex || require('./_stream_duplex');
options = options || {};
// Duplex streams are both readable and writable, but share
// the same options object.
// However, some cases require setting options to different
// values for the readable and the writable sides of the duplex stream.
// These options can be provided separately as readableXXX and writableXXX.
var isDuplex = stream instanceof Duplex;
// object stream flag. Used to make read(n) ignore n and to
// make all the buffer merging and length checks go away
this.objectMode = !!options.objectMode;
if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
// the point at which it stops calling _read() to fill the buffer
// Note: 0 is a valid value, means "don't call _read preemptively ever"
var hwm = options.highWaterMark;
var readableHwm = options.readableHighWaterMark;
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
// cast to ints.
this.highWaterMark = Math.floor(this.highWaterMark);
// A linked list is used to store data chunks instead of an array because the
// linked list can remove elements from the beginning faster than
// array.shift()
this.buffer = new BufferList();
this.length = 0;
this.pipes = null;
this.pipesCount = 0;
this.flowing = null;
this.ended = false;
this.endEmitted = false;
this.reading = false;
// a flag to be able to tell if the event 'readable'/'data' is emitted
// immediately, or on a later tick. We set this to true at first, because
// any actions that shouldn't happen until "later" should generally also
// not happen before the first read call.
this.sync = true;
// whenever we return null, then we set a flag to say
// that we're awaiting a 'readable' event emission.
this.needReadable = false;
this.emittedReadable = false;
this.readableListening = false;
this.resumeScheduled = false;
// has it been destroyed
this.destroyed = false;
// Crypto is kind of old and crusty. Historically, its default string
// encoding is 'binary' so we have to make this configurable.
// Everything else in the universe uses 'utf8', though.
this.defaultEncoding = options.defaultEncoding || 'utf8';
// the number of writers that are awaiting a drain event in .pipe()s
this.awaitDrain = 0;
// if true, a maybeReadMore has been scheduled
this.readingMore = false;
this.decoder = null;
this.encoding = null;
if (options.encoding) {
if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
this.decoder = new StringDecoder(options.encoding);
this.encoding = options.encoding;
}
}
function Readable(options) {
Duplex = Duplex || require('./_stream_duplex');
if (!(this instanceof Readable)) return new Readable(options);
this._readableState = new ReadableState(options, this);
// legacy
this.readable = true;
if (options) {
if (typeof options.read === 'function') this._read = options.read;
if (typeof options.destroy === 'function') this._destroy = options.destroy;
}
Stream.call(this);
}
Object.defineProperty(Readable.prototype, 'destroyed', {
get: function () {
if (this._readableState === undefined) {
return false;
}
return this._readableState.destroyed;
},
set: function (value) {
// we ignore the value if the stream
// has not been initialized yet
if (!this._readableState) {
return;
}
// backward compatibility, the user is explicitly
// managing destroyed
this._readableState.destroyed = value;
}
});
Readable.prototype.destroy = destroyImpl.destroy;
Readable.prototype._undestroy = destroyImpl.undestroy;
Readable.prototype._destroy = function (err, cb) {
this.push(null);
cb(err);
};
// Manually shove something into the read() buffer.
// This returns true if the highWaterMark has not been hit yet,
// similar to how Writable.write() returns true if you should
// write() some more.
Readable.prototype.push = function (chunk, encoding) {
var state = this._readableState;
var skipChunkCheck;
if (!state.objectMode) {
if (typeof chunk === 'string') {
encoding = encoding || state.defaultEncoding;
if (encoding !== state.encoding) {
chunk = Buffer.from(chunk, encoding);
encoding = '';
}
skipChunkCheck = true;
}
} else {
skipChunkCheck = true;
}
return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
};
// Unshift should *always* be something directly out of read()
Readable.prototype.unshift = function (chunk) {
return readableAddChunk(this, chunk, null, true, false);
};
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
var state = stream._readableState;
if (chunk === null) {
state.reading = false;
onEofChunk(stream, state);
} else {
var er;
if (!skipChunkCheck) er = chunkInvalid(state, chunk);
if (er) {
stream.emit('error', er);
} else if (state.objectMode || chunk && chunk.length > 0) {
if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
chunk = _uint8ArrayToBuffer(chunk);
}
if (addToFront) {
if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
} else if (state.ended) {
stream.emit('error', new Error('stream.push() after EOF'));
} else {
state.reading = false;
if (state.decoder && !encoding) {
chunk = state.decoder.write(chunk);
if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
} else {
addChunk(stream, state, chunk, false);
}
}
} else if (!addToFront) {
state.reading = false;
}
}
return needMoreData(state);
}
function addChunk(stream, state, chunk, addToFront) {
if (state.flowing && state.length === 0 && !state.sync) {
stream.emit('data', chunk);
stream.read(0);
} else {
// update the buffer info.
state.length += state.objectMode ? 1 : chunk.length;
if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
if (state.needReadable) emitReadable(stream);
}
maybeReadMore(stream, state);
}
function chunkInvalid(state, chunk) {
var er;
if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
er = new TypeError('Invalid non-string/buffer chunk');
}
return er;
}
// if it's past the high water mark, we can push in some more.
// Also, if we have no data yet, we can stand some
// more bytes. This is to work around cases where hwm=0,
// such as the repl. Also, if the push() triggered a
// readable event, and the user called read(largeNumber) such that
// needReadable was set, then we ought to push more, so that another
// 'readable' event will be triggered.
function needMoreData(state) {
return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
}
Readable.prototype.isPaused = function () {
return this._readableState.flowing === false;
};
// backwards compatibility.
Readable.prototype.setEncoding = function (enc) {
if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
this._readableState.decoder = new StringDecoder(enc);
this._readableState.encoding = enc;
return this;
};
// Don't raise the hwm > 8MB
var MAX_HWM = 0x800000;
function computeNewHighWaterMark(n) {
if (n >= MAX_HWM) {
n = MAX_HWM;
} else {
// Get the next highest power of 2 to prevent increasing hwm excessively in
// tiny amounts
n--;
n |= n >>> 1;
n |= n >>> 2;
n |= n >>> 4;
n |= n >>> 8;
n |= n >>> 16;
n++;
}
return n;
}
// This function is designed to be inlinable, so please take care when making
// changes to the function body.
function howMuchToRead(n, state) {
if (n <= 0 || state.length === 0 && state.ended) return 0;
if (state.objectMode) return 1;
if (n !== n) {
// Only flow one buffer at a time
if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
}
// If we're asking for more than the current hwm, then raise the hwm.
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
if (n <= state.length) return n;
// Don't have enough
if (!state.ended) {
state.needReadable = true;
return 0;
}
return state.length;
}
// you can override either this method, or the async _read(n) below.
Readable.prototype.read = function (n) {
debug('read', n);
n = parseInt(n, 10);
var state = this._readableState;
var nOrig = n;
if (n !== 0) state.emittedReadable = false;
// if we're doing read(0) to trigger a readable event, but we
// already have a bunch of data in the buffer, then just trigger
// the 'readable' event and move on.
if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
debug('read: emitReadable', state.length, state.ended);
if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
return null;
}
n = howMuchToRead(n, state);
// if we've ended, and we're now clear, then finish it up.
if (n === 0 && state.ended) {
if (state.length === 0) endReadable(this);
return null;
}
// All the actual chunk generation logic needs to be
// *below* the call to _read. The reason is that in certain
// synthetic stream cases, such as passthrough streams, _read
// may be a completely synchronous operation which may change
// the state of the read buffer, providing enough data when
// before there was *not* enough.
//
// So, the steps are:
// 1. Figure out what the state of things will be after we do
// a read from the buffer.
//
// 2. If that resulting state will trigger a _read, then call _read.
// Note that this may be asynchronous, or synchronous. Yes, it is
// deeply ugly to write APIs this way, but that still doesn't mean
// that the Readable class should behave improperly, as streams are
// designed to be sync/async agnostic.
// Take note if the _read call is sync or async (ie, if the read call
// has returned yet), so that we know whether or not it's safe to emit
// 'readable' etc.
//
// 3. Actually pull the requested chunks out of the buffer and return.
// if we need a readable event, then we need to do some reading.
var doRead = state.needReadable;
debug('need readable', doRead);
// if we currently have less than the highWaterMark, then also read some
if (state.length === 0 || state.length - n < state.highWaterMark) {
doRead = true;
debug('length less than watermark', doRead);
}
// however, if we've ended, then there's no point, and if we're already
// reading, then it's unnecessary.
if (state.ended || state.reading) {
doRead = false;
debug('reading or ended', doRead);
} else if (doRead) {
debug('do read');
state.reading = true;
state.sync = true;
// if the length is currently zero, then we *need* a readable event.
if (state.length === 0) state.needReadable = true;
// call internal read method
this._read(state.highWaterMark);
state.sync = false;
// If _read pushed data synchronously, then `reading` will be false,
// and we need to re-evaluate how much data we can return to the user.
if (!state.reading) n = howMuchToRead(nOrig, state);
}
var ret;
if (n > 0) ret = fromList(n, state);else ret = null;
if (ret === null) {
state.needReadable = true;
n = 0;
} else {
state.length -= n;
}
if (state.length === 0) {
// If we have nothing in the buffer, then we want to know
// as soon as we *do* get something into the buffer.
if (!state.ended) state.needReadable = true;
// If we tried to read() past the EOF, then emit end on the next tick.
if (nOrig !== n && state.ended) endReadable(this);
}
if (ret !== null) this.emit('data', ret);
return ret;
};
function onEofChunk(stream, state) {
if (state.ended) return;
if (state.decoder) {
var chunk = state.decoder.end();
if (chunk && chunk.length) {
state.buffer.push(chunk);
state.length += state.objectMode ? 1 : chunk.length;
}
}
state.ended = true;
// emit 'readable' now to make sure it gets picked up.
emitReadable(stream);
}
// Don't emit readable right away in sync mode, because this can trigger
// another read() call => stack overflow. This way, it might trigger
// a nextTick recursion warning, but that's not so bad.
function emitReadable(stream) {
var state = stream._readableState;
state.needReadable = false;
if (!state.emittedReadable) {
debug('emitReadable', state.flowing);
state.emittedReadable = true;
if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
}
}
function emitReadable_(stream) {
debug('emit readable');
stream.emit('readable');
flow(stream);
}
// at this point, the user has presumably seen the 'readable' event,
// and called read() to consume some data. that may have triggered
// in turn another _read(n) call, in which case reading = true if
// it's in progress.
// However, if we're not ended, or reading, and the length < hwm,
// then go ahead and try to read some more preemptively.
function maybeReadMore(stream, state) {
if (!state.readingMore) {
state.readingMore = true;
pna.nextTick(maybeReadMore_, stream, state);
}
}
function maybeReadMore_(stream, state) {
var len = state.length;
while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
debug('maybeReadMore read 0');
stream.read(0);
if (len === state.length)
// didn't get any data, stop spinning.
break;else len = state.length;
}
state.readingMore = false;
}
// abstract method. to be overridden in specific implementation classes.
// call cb(er, data) where data is <= n in length.
// for virtual (non-string, non-buffer) streams, "length" is somewhat
// arbitrary, and perhaps not very meaningful.
Readable.prototype._read = function (n) {
this.emit('error', new Error('_read() is not implemented'));
};
Readable.prototype.pipe = function (dest, pipeOpts) {
var src = this;
var state = this._readableState;
switch (state.pipesCount) {
case 0:
state.pipes = dest;
break;
case 1:
state.pipes = [state.pipes, dest];
break;
default:
state.pipes.push(dest);
break;
}
state.pipesCount += 1;
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
var endFn = doEnd ? onend : unpipe;
if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
dest.on('unpipe', onunpipe);
function onunpipe(readable, unpipeInfo) {
debug('onunpipe');
if (readable === src) {
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
unpipeInfo.hasUnpiped = true;
cleanup();
}
}
}
function onend() {
debug('onend');
dest.end();
}
// when the dest drains, it reduces the awaitDrain counter
// on the source. This would be more elegant with a .once()
// handler in flow(), but adding and removing repeatedly is
// too slow.
var ondrain = pipeOnDrain(src);
dest.on('drain', ondrain);
var cleanedUp = false;
function cleanup() {
debug('cleanup');
// cleanup event handlers once the pipe is broken
dest.removeListener('close', onclose);
dest.removeListener('finish', onfinish);
dest.removeListener('drain', ondrain);
dest.removeListener('error', onerror);
dest.removeListener('unpipe', onunpipe);
src.removeListener('end', onend);
src.removeListener('end', unpipe);
src.removeListener('data', ondata);
cleanedUp = true;
// if the reader is waiting for a drain event from this
// specific writer, then it would cause it to never start
// flowing again.
// So, if this is awaiting a drain, then we just call it now.
// If we don't know, then assume that we are waiting for one.
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
}
// If the user pushes more data while we're writing to dest then we'll end up
// in ondata again. However, we only want to increase awaitDrain once because
// dest will only emit one 'drain' event for the multiple writes.
// => Introduce a guard on increasing awaitDrain.
var increasedAwaitDrain = false;
src.on('data', ondata);
function ondata(chunk) {
debug('ondata');
increasedAwaitDrain = false;
var ret = dest.write(chunk);
if (false === ret && !increasedAwaitDrain) {
// If the user unpiped during `dest.write()`, it is possible
// to get stuck in a permanently paused state if that write
// also returned false.
// => Check whether `dest` is still a piping destination.
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
debug('false write response, pause', src._readableState.awaitDrain);
src._readableState.awaitDrain++;
increasedAwaitDrain = true;
}
src.pause();
}
}
// if the dest has an error, then stop piping into it.
// however, don't suppress the throwing behavior for this.
function onerror(er) {
debug('onerror', er);
unpipe();
dest.removeListener('error', onerror);
if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
}
// Make sure our error handler is attached before userland ones.
prependListener(dest, 'error', onerror);
// Both close and finish should trigger unpipe, but only once.
function onclose() {
dest.removeListener('finish', onfinish);
unpipe();
}
dest.once('close', onclose);
function onfinish() {
debug('onfinish');
dest.removeListener('close', onclose);
unpipe();
}
dest.once('finish', onfinish);
function unpipe() {
debug('unpipe');
src.unpipe(dest);
}
// tell the dest that it's being piped to
dest.emit('pipe', src);
// start the flow if it hasn't been started already.
if (!state.flowing) {
debug('pipe resume');
src.resume();
}
return dest;
};
function pipeOnDrain(src) {
return function () {
var state = src._readableState;
debug('pipeOnDrain', state.awaitDrain);
if (state.awaitDrain) state.awaitDrain--;
if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
state.flowing = true;
flow(src);
}
};
}
Readable.prototype.unpipe = function (dest) {
var state = this._readableState;
var unpipeInfo = { hasUnpiped: false };
// if we're not piping anywhere, then do nothing.
if (state.pipesCount === 0) return this;
// just one destination. most common case.
if (state.pipesCount === 1) {
// passed in one, but it's not the right one.
if (dest && dest !== state.pipes) return this;
if (!dest) dest = state.pipes;
// got a match.
state.pipes = null;
state.pipesCount = 0;
state.flowing = false;
if (dest) dest.emit('unpipe', this, unpipeInfo);
return this;
}
// slow case. multiple pipe destinations.
if (!dest) {
// remove all.
var dests = state.pipes;
var len = state.pipesCount;
state.pipes = null;
state.pipesCount = 0;
state.flowing = false;
for (var i = 0; i < len; i++) {
dests[i].emit('unpipe', this, unpipeInfo);
}return this;
}
// try to find the right one.
var index = indexOf(state.pipes, dest);
if (index === -1) return this;
state.pipes.splice(index, 1);
state.pipesCount -= 1;
if (state.pipesCount === 1) state.pipes = state.pipes[0];
dest.emit('unpipe', this, unpipeInfo);
return this;
};
// set up data events if they are asked for
// Ensure readable listeners eventually get something
Readable.prototype.on = function (ev, fn) {
var res = Stream.prototype.on.call(this, ev, fn);
if (ev === 'data') {
// Start flowing on next tick if stream isn't explicitly paused
if (this._readableState.flowing !== false) this.resume();
} else if (ev === 'readable') {
var state = this._readableState;
if (!state.endEmitted && !state.readableListening) {
state.readableListening = state.needReadable = true;
state.emittedReadable = false;
if (!state.reading) {
pna.nextTick(nReadingNextTick, this);
} else if (state.length) {
emitReadable(this);
}
}
}
return res;
};
Readable.prototype.addListener = Readable.prototype.on;
function nReadingNextTick(self) {
debug('readable nexttick read 0');
self.read(0);
}
// pause() and resume() are remnants of the legacy readable stream API
// If the user uses them, then switch into old mode.
Readable.prototype.resume = function () {
var state = this._readableState;
if (!state.flowing) {
debug('resume');
state.flowing = true;
resume(this, state);
}
return this;
};
function resume(stream, state) {
if (!state.resumeScheduled) {
state.resumeScheduled = true;
pna.nextTick(resume_, stream, state);
}
}
function resume_(stream, state) {
if (!state.reading) {
debug('resume read 0');
stream.read(0);
}
state.resumeScheduled = false;
state.awaitDrain = 0;
stream.emit('resume');
flow(stream);
if (state.flowing && !state.reading) stream.read(0);
}
Readable.prototype.pause = function () {
debug('call pause flowing=%j', this._readableState.flowing);
if (false !== this._readableState.flowing) {
debug('pause');
this._readableState.flowing = false;
this.emit('pause');
}
return this;
};
function flow(stream) {
var state = stream._readableState;
debug('flow', state.flowing);
while (state.flowing && stream.read() !== null) {}
}
// wrap an old-style stream as the async data source.
// This is *not* part of the readable stream interface.
// It is an ugly unfortunate mess of history.
Readable.prototype.wrap = function (stream) {
var _this = this;
var state = this._readableState;
var paused = false;
stream.on('end', function () {
debug('wrapped end');
if (state.decoder && !state.ended) {
var chunk = state.decoder.end();
if (chunk && chunk.length) _this.push(chunk);
}
_this.push(null);
});
stream.on('data', function (chunk) {
debug('wrapped data');
if (state.decoder) chunk = state.decoder.write(chunk);
// don't skip over falsy values in objectMode
if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
var ret = _this.push(chunk);
if (!ret) {
paused = true;
stream.pause();
}
});
// proxy all the other methods.
// important when wrapping filters and duplexes.
for (var i in stream) {
if (this[i] === undefined && typeof stream[i] === 'function') {
this[i] = function (method) {
return function () {
return stream[method].apply(stream, arguments);
};
}(i);
}
}
// proxy certain important events.
for (var n = 0; n < kProxyEvents.length; n++) {
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
}
// when we try to consume some more bytes, simply unpause the
// underlying stream.
this._read = function (n) {
debug('wrapped _read', n);
if (paused) {
paused = false;
stream.resume();
}
};
return this;
};
Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function () {
return this._readableState.highWaterMark;
}
});
// exposed for testing purposes only.
Readable._fromList = fromList;
// Pluck off n bytes from an array of buffers.
// Length is the combined lengths of all the buffers in the list.
// This function is designed to be inlinable, so please take care when making
// changes to the function body.
function fromList(n, state) {
// nothing buffered
if (state.length === 0) return null;
var ret;
if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
// read it all, truncate the list
if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
state.buffer.clear();
} else {
// read part of list
ret = fromListPartial(n, state.buffer, state.decoder);
}
return ret;
}
// Extracts only enough buffered data to satisfy the amount requested.
// This function is designed to be inlinable, so please take care when making
// changes to the function body.
function fromListPartial(n, list, hasStrings) {
var ret;
if (n < list.head.data.length) {
// slice is the same for buffers and strings
ret = list.head.data.slice(0, n);
list.head.data = list.head.data.slice(n);
} else if (n === list.head.data.length) {
// first chunk is a perfect match
ret = list.shift();
} else {
// result spans more than one buffer
ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
}
return ret;
}
// Copies a specified amount of characters from the list of buffered data
// chunks.
// This function is designed to be inlinable, so please take care when making
// changes to the function body.
function copyFromBufferString(n, list) {
var p = list.head;
var c = 1;
var ret = p.data;
n -= ret.length;
while (p = p.next) {
var str = p.data;
var nb = n > str.length ? str.length : n;
if (nb === str.length) ret += str;else ret += str.slice(0, n);
n -= nb;
if (n === 0) {
if (nb === str.length) {
++c;
if (p.next) list.head = p.next;else list.head = list.tail = null;
} else {
list.head = p;
p.data = str.slice(nb);
}
break;
}
++c;
}
list.length -= c;
return ret;
}
// Copies a specified amount of bytes from the list of buffered data chunks.
// This function is designed to be inlinable, so please take care when making
// changes to the function body.
function copyFromBuffer(n, list) {
var ret = Buffer.allocUnsafe(n);
var p = list.head;
var c = 1;
p.data.copy(ret);
n -= p.data.length;
while (p = p.next) {
var buf = p.data;
var nb = n > buf.length ? buf.length : n;
buf.copy(ret, ret.length - n, 0, nb);
n -= nb;
if (n === 0) {
if (nb === buf.length) {
++c;
if (p.next) list.head = p.next;else list.head = list.tail = null;
} else {
list.head = p;
p.data = buf.slice(nb);
}
break;
}
++c;
}
list.length -= c;
return ret;
}
function endReadable(stream) {
var state = stream._readableState;
// If we get here before consuming all the bytes, then that is a
// bug in node. Should never happen.
if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
if (!state.endEmitted) {
state.ended = true;
pna.nextTick(endReadableNT, state, stream);
}
}
function endReadableNT(state, stream) {
// Check that we didn't get one last unshift.
if (!state.endEmitted && state.length === 0) {
state.endEmitted = true;
stream.readable = false;
stream.emit('end');
}
}
function indexOf(xs, x) {
for (var i = 0, l = xs.length; i < l; i++) {
if (xs[i] === x) return i;
}
return -1;
}
\ No newline at end of file
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// a transform stream is a readable/writable stream where you do
// something with the data. Sometimes it's called a "filter",
// but that's not a great name for it, since that implies a thing where
// some bits pass through, and others are simply ignored. (That would
// be a valid example of a transform, of course.)
//
// While the output is causally related to the input, it's not a
// necessarily symmetric or synchronous transformation. For example,
// a zlib stream might take multiple plain-text writes(), and then
// emit a single compressed chunk some time in the future.
//
// Here's how this works:
//
// The Transform stream has all the aspects of the readable and writable
// stream classes. When you write(chunk), that calls _write(chunk,cb)
// internally, and returns false if there's a lot of pending writes
// buffered up. When you call read(), that calls _read(n) until
// there's enough pending readable data buffered up.
//
// In a transform stream, the written data is placed in a buffer. When
// _read(n) is called, it transforms the queued up data, calling the
// buffered _write cb's as it consumes chunks. If consuming a single
// written chunk would result in multiple output chunks, then the first
// outputted bit calls the readcb, and subsequent chunks just go into
// the read buffer, and will cause it to emit 'readable' if necessary.
//
// This way, back-pressure is actually determined by the reading side,
// since _read has to be called to start processing a new chunk. However,
// a pathological inflate type of transform can cause excessive buffering
// here. For example, imagine a stream where every byte of input is
// interpreted as an integer from 0-255, and then results in that many
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
// 1kb of data being output. In this case, you could write a very small
// amount of input, and end up with a very large amount of output. In
// such a pathological inflating mechanism, there'd be no way to tell
// the system to stop doing the transform. A single 4MB write could
// cause the system to run out of memory.
//
// However, even in such a pathological case, only a single written chunk
// would be consumed, and then the rest would wait (un-transformed) until
// the results of the previous transformed chunk were consumed.
'use strict';
module.exports = Transform;
var Duplex = require('./_stream_duplex');
/*<replacement>*/
var util = Object.create(require('core-util-is'));
util.inherits = require('inherits');
/*</replacement>*/
util.inherits(Transform, Duplex);
function afterTransform(er, data) {
var ts = this._transformState;
ts.transforming = false;
var cb = ts.writecb;
if (!cb) {
return this.emit('error', new Error('write callback called multiple times'));
}
ts.writechunk = null;
ts.writecb = null;
if (data != null) // single equals check for both `null` and `undefined`
this.push(data);
cb(er);
var rs = this._readableState;
rs.reading = false;
if (rs.needReadable || rs.length < rs.highWaterMark) {
this._read(rs.highWaterMark);
}
}
function Transform(options) {
if (!(this instanceof Transform)) return new Transform(options);
Duplex.call(this, options);
this._transformState = {
afterTransform: afterTransform.bind(this),
needTransform: false,
transforming: false,
writecb: null,
writechunk: null,
writeencoding: null
};
// start out asking for a readable event once data is transformed.
this._readableState.needReadable = true;
// we have implemented the _read method, and done the other things
// that Readable wants before the first _read call, so unset the
// sync guard flag.
this._readableState.sync = false;
if (options) {
if (typeof options.transform === 'function') this._transform = options.transform;
if (typeof options.flush === 'function') this._flush = options.flush;
}
// When the writable side finishes, then flush out anything remaining.
this.on('prefinish', prefinish);
}
function prefinish() {
var _this = this;
if (typeof this._flush === 'function') {
this._flush(function (er, data) {
done(_this, er, data);
});
} else {
done(this, null, null);
}
}
Transform.prototype.push = function (chunk, encoding) {
this._transformState.needTransform = false;
return Duplex.prototype.push.call(this, chunk, encoding);
};
// This is the part where you do stuff!
// override this function in implementation classes.
// 'chunk' is an input chunk.
//
// Call `push(newChunk)` to pass along transformed output
// to the readable side. You may call 'push' zero or more times.
//
// Call `cb(err)` when you are done with this chunk. If you pass
// an error, then that'll put the hurt on the whole operation. If you
// never call cb(), then you'll never get another chunk.
Transform.prototype._transform = function (chunk, encoding, cb) {
throw new Error('_transform() is not implemented');
};
Transform.prototype._write = function (chunk, encoding, cb) {
var ts = this._transformState;
ts.writecb = cb;
ts.writechunk = chunk;
ts.writeencoding = encoding;
if (!ts.transforming) {
var rs = this._readableState;
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
}
};
// Doesn't matter what the args are here.
// _transform does all the work.
// That we got here means that the readable side wants more data.
Transform.prototype._read = function (n) {
var ts = this._transformState;
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
ts.transforming = true;
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
} else {
// mark that we need a transform, so that any data that comes in
// will get processed, now that we've asked for it.
ts.needTransform = true;
}
};
Transform.prototype._destroy = function (err, cb) {
var _this2 = this;
Duplex.prototype._destroy.call(this, err, function (err2) {
cb(err2);
_this2.emit('close');
});
};
function done(stream, er, data) {
if (er) return stream.emit('error', er);
if (data != null) // single equals check for both `null` and `undefined`
stream.push(data);
// if there's nothing in the write buffer, then that means
// that nothing more will ever be provided
if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
return stream.push(null);
}
\ No newline at end of file
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// A bit simpler than readable streams.
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
// the drain event emission and buffering.
'use strict';
/*<replacement>*/
var pna = require('process-nextick-args');
/*</replacement>*/
module.exports = Writable;
/* <replacement> */
function WriteReq(chunk, encoding, cb) {
this.chunk = chunk;
this.encoding = encoding;
this.callback = cb;
this.next = null;
}
// It seems a linked list but it is not
// there will be only 2 of these for each stream
function CorkedRequest(state) {
var _this = this;
this.next = null;
this.entry = null;
this.finish = function () {
onCorkedFinish(_this, state);
};
}
/* </replacement> */
/*<replacement>*/
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
/*</replacement>*/
/*<replacement>*/
var Duplex;
/*</replacement>*/
Writable.WritableState = WritableState;
/*<replacement>*/
var util = Object.create(require('core-util-is'));
util.inherits = require('inherits');
/*</replacement>*/
/*<replacement>*/
var internalUtil = {
deprecate: require('util-deprecate')
};
/*</replacement>*/
/*<replacement>*/
var Stream = require('./internal/streams/stream');
/*</replacement>*/
/*<replacement>*/
var Buffer = require('safe-buffer').Buffer;
var OurUint8Array = global.Uint8Array || function () {};
function _uint8ArrayToBuffer(chunk) {
return Buffer.from(chunk);
}
function _isUint8Array(obj) {
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
}
/*</replacement>*/
var destroyImpl = require('./internal/streams/destroy');
util.inherits(Writable, Stream);
function nop() {}
function WritableState(options, stream) {
Duplex = Duplex || require('./_stream_duplex');
options = options || {};
// Duplex streams are both readable and writable, but share
// the same options object.
// However, some cases require setting options to different
// values for the readable and the writable sides of the duplex stream.
// These options can be provided separately as readableXXX and writableXXX.
var isDuplex = stream instanceof Duplex;
// object stream flag to indicate whether or not this stream
// contains buffers or objects.
this.objectMode = !!options.objectMode;
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
// the point at which write() starts returning false
// Note: 0 is a valid value, means that we always return false if
// the entire buffer is not flushed immediately on write()
var hwm = options.highWaterMark;
var writableHwm = options.writableHighWaterMark;
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
// cast to ints.
this.highWaterMark = Math.floor(this.highWaterMark);
// if _final has been called
this.finalCalled = false;
// drain event flag.
this.needDrain = false;
// at the start of calling end()
this.ending = false;
// when end() has been called, and returned
this.ended = false;
// when 'finish' is emitted
this.finished = false;
// has it been destroyed
this.destroyed = false;
// should we decode strings into buffers before passing to _write?
// this is here so that some node-core streams can optimize string
// handling at a lower level.
var noDecode = options.decodeStrings === false;
this.decodeStrings = !noDecode;
// Crypto is kind of old and crusty. Historically, its default string
// encoding is 'binary' so we have to make this configurable.
// Everything else in the universe uses 'utf8', though.
this.defaultEncoding = options.defaultEncoding || 'utf8';
// not an actual buffer we keep track of, but a measurement
// of how much we're waiting to get pushed to some underlying
// socket or file.
this.length = 0;
// a flag to see when we're in the middle of a write.
this.writing = false;
// when true all writes will be buffered until .uncork() call
this.corked = 0;
// a flag to be able to tell if the onwrite cb is called immediately,
// or on a later tick. We set this to true at first, because any
// actions that shouldn't happen until "later" should generally also
// not happen before the first write call.
this.sync = true;
// a flag to know if we're processing previously buffered items, which
// may call the _write() callback in the same tick, so that we don't
// end up in an overlapped onwrite situation.
this.bufferProcessing = false;
// the callback that's passed to _write(chunk,cb)
this.onwrite = function (er) {
onwrite(stream, er);
};
// the callback that the user supplies to write(chunk,encoding,cb)
this.writecb = null;
// the amount that is being written when _write is called.
this.writelen = 0;
this.bufferedRequest = null;
this.lastBufferedRequest = null;
// number of pending user-supplied write callbacks
// this must be 0 before 'finish' can be emitted
this.pendingcb = 0;
// emit prefinish if the only thing we're waiting for is _write cbs
// This is relevant for synchronous Transform streams
this.prefinished = false;
// True if the error was already emitted and should not be thrown again
this.errorEmitted = false;
// count buffered requests
this.bufferedRequestCount = 0;
// allocate the first CorkedRequest, there is always
// one allocated and free to use, and we maintain at most two
this.corkedRequestsFree = new CorkedRequest(this);
}
WritableState.prototype.getBuffer = function getBuffer() {
var current = this.bufferedRequest;
var out = [];
while (current) {
out.push(current);
current = current.next;
}
return out;
};
(function () {
try {
Object.defineProperty(WritableState.prototype, 'buffer', {
get: internalUtil.deprecate(function () {
return this.getBuffer();
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
});
} catch (_) {}
})();
// Test _writableState for inheritance to account for Duplex streams,
// whose prototype chain only points to Readable.
var realHasInstance;
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
realHasInstance = Function.prototype[Symbol.hasInstance];
Object.defineProperty(Writable, Symbol.hasInstance, {
value: function (object) {
if (realHasInstance.call(this, object)) return true;
if (this !== Writable) return false;
return object && object._writableState instanceof WritableState;
}
});
} else {
realHasInstance = function (object) {
return object instanceof this;
};
}
function Writable(options) {
Duplex = Duplex || require('./_stream_duplex');
// Writable ctor is applied to Duplexes, too.
// `realHasInstance` is necessary because using plain `instanceof`
// would return false, as no `_writableState` property is attached.
// Trying to use the custom `instanceof` for Writable here will also break the
// Node.js LazyTransform implementation, which has a non-trivial getter for
// `_writableState` that would lead to infinite recursion.
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
return new Writable(options);
}
this._writableState = new WritableState(options, this);
// legacy.
this.writable = true;
if (options) {
if (typeof options.write === 'function') this._write = options.write;
if (typeof options.writev === 'function') this._writev = options.writev;
if (typeof options.destroy === 'function') this._destroy = options.destroy;
if (typeof options.final === 'function') this._final = options.final;
}
Stream.call(this);
}
// Otherwise people can pipe Writable streams, which is just wrong.
Writable.prototype.pipe = function () {
this.emit('error', new Error('Cannot pipe, not readable'));
};
function writeAfterEnd(stream, cb) {
var er = new Error('write after end');
// TODO: defer error events consistently everywhere, not just the cb
stream.emit('error', er);
pna.nextTick(cb, er);
}
// Checks that a user-supplied chunk is valid, especially for the particular
// mode the stream is in. Currently this means that `null` is never accepted
// and undefined/non-string values are only allowed in object mode.
function validChunk(stream, state, chunk, cb) {
var valid = true;
var er = false;
if (chunk === null) {
er = new TypeError('May not write null values to stream');
} else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
er = new TypeError('Invalid non-string/buffer chunk');
}
if (er) {
stream.emit('error', er);
pna.nextTick(cb, er);
valid = false;
}
return valid;
}
Writable.prototype.write = function (chunk, encoding, cb) {
var state = this._writableState;
var ret = false;
var isBuf = !state.objectMode && _isUint8Array(chunk);
if (isBuf && !Buffer.isBuffer(chunk)) {
chunk = _uint8ArrayToBuffer(chunk);
}
if (typeof encoding === 'function') {
cb = encoding;
encoding = null;
}
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
if (typeof cb !== 'function') cb = nop;
if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
state.pendingcb++;
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
}
return ret;
};
Writable.prototype.cork = function () {
var state = this._writableState;
state.corked++;
};
Writable.prototype.uncork = function () {
var state = this._writableState;
if (state.corked) {
state.corked--;
if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
}
};
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
// node::ParseEncoding() requires lower case.
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
this._writableState.defaultEncoding = encoding;
return this;
};
function decodeChunk(state, chunk, encoding) {
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
chunk = Buffer.from(chunk, encoding);
}
return chunk;
}
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function () {
return this._writableState.highWaterMark;
}
});
// if we're already writing something, then just put this
// in the queue, and wait our turn. Otherwise, call _write
// If we return false, then we need a drain event, so set that flag.
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
if (!isBuf) {
var newChunk = decodeChunk(state, chunk, encoding);
if (chunk !== newChunk) {
isBuf = true;
encoding = 'buffer';
chunk = newChunk;
}
}
var len = state.objectMode ? 1 : chunk.length;
state.length += len;
var ret = state.length < state.highWaterMark;
// we must ensure that previous needDrain will not be reset to false.
if (!ret) state.needDrain = true;
if (state.writing || state.corked) {
var last = state.lastBufferedRequest;
state.lastBufferedRequest = {
chunk: chunk,
encoding: encoding,
isBuf: isBuf,
callback: cb,
next: null
};
if (last) {
last.next = state.lastBufferedRequest;
} else {
state.bufferedRequest = state.lastBufferedRequest;
}
state.bufferedRequestCount += 1;
} else {
doWrite(stream, state, false, len, chunk, encoding, cb);
}
return ret;
}
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
state.writelen = len;
state.writecb = cb;
state.writing = true;
state.sync = true;
if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
state.sync = false;
}
function onwriteError(stream, state, sync, er, cb) {
--state.pendingcb;
if (sync) {
// defer the callback if we are being called synchronously
// to avoid piling up things on the stack
pna.nextTick(cb, er);
// this can emit finish, and it will always happen
// after error
pna.nextTick(finishMaybe, stream, state);
stream._writableState.errorEmitted = true;
stream.emit('error', er);
} else {
// the caller expect this to happen before if
// it is async
cb(er);
stream._writableState.errorEmitted = true;
stream.emit('error', er);
// this can emit finish, but finish must
// always follow error
finishMaybe(stream, state);
}
}
function onwriteStateUpdate(state) {
state.writing = false;
state.writecb = null;
state.length -= state.writelen;
state.writelen = 0;
}
function onwrite(stream, er) {
var state = stream._writableState;
var sync = state.sync;
var cb = state.writecb;
onwriteStateUpdate(state);
if (er) onwriteError(stream, state, sync, er, cb);else {
// Check if we're actually ready to finish, but don't emit yet
var finished = needFinish(state);
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
clearBuffer(stream, state);
}
if (sync) {
/*<replacement>*/
asyncWrite(afterWrite, stream, state, finished, cb);
/*</replacement>*/
} else {
afterWrite(stream, state, finished, cb);
}
}
}
function afterWrite(stream, state, finished, cb) {
if (!finished) onwriteDrain(stream, state);
state.pendingcb--;
cb();
finishMaybe(stream, state);
}
// Must force callback to be called on nextTick, so that we don't
// emit 'drain' before the write() consumer gets the 'false' return
// value, and has a chance to attach a 'drain' listener.
function onwriteDrain(stream, state) {
if (state.length === 0 && state.needDrain) {
state.needDrain = false;
stream.emit('drain');
}
}
// if there's something in the buffer waiting, then process it
function clearBuffer(stream, state) {
state.bufferProcessing = true;
var entry = state.bufferedRequest;
if (stream._writev && entry && entry.next) {
// Fast case, write everything using _writev()
var l = state.bufferedRequestCount;
var buffer = new Array(l);
var holder = state.corkedRequestsFree;
holder.entry = entry;
var count = 0;
var allBuffers = true;
while (entry) {
buffer[count] = entry;
if (!entry.isBuf) allBuffers = false;
entry = entry.next;
count += 1;
}
buffer.allBuffers = allBuffers;
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
// doWrite is almost always async, defer these to save a bit of time
// as the hot path ends with doWrite
state.pendingcb++;
state.lastBufferedRequest = null;
if (holder.next) {
state.corkedRequestsFree = holder.next;
holder.next = null;
} else {
state.corkedRequestsFree = new CorkedRequest(state);
}
state.bufferedRequestCount = 0;
} else {
// Slow case, write chunks one-by-one
while (entry) {
var chunk = entry.chunk;
var encoding = entry.encoding;
var cb = entry.callback;
var len = state.objectMode ? 1 : chunk.length;
doWrite(stream, state, false, len, chunk, encoding, cb);
entry = entry.next;
state.bufferedRequestCount--;
// if we didn't call the onwrite immediately, then
// it means that we need to wait until it does.
// also, that means that the chunk and cb are currently
// being processed, so move the buffer counter past them.
if (state.writing) {
break;
}
}
if (entry === null) state.lastBufferedRequest = null;
}
state.bufferedRequest = entry;
state.bufferProcessing = false;
}
Writable.prototype._write = function (chunk, encoding, cb) {
cb(new Error('_write() is not implemented'));
};
Writable.prototype._writev = null;
Writable.prototype.end = function (chunk, encoding, cb) {
var state = this._writableState;
if (typeof chunk === 'function') {
cb = chunk;
chunk = null;
encoding = null;
} else if (typeof encoding === 'function') {
cb = encoding;
encoding = null;
}
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
// .end() fully uncorks
if (state.corked) {
state.corked = 1;
this.uncork();
}
// ignore unnecessary end() calls.
if (!state.ending && !state.finished) endWritable(this, state, cb);
};
function needFinish(state) {
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
}
function callFinal(stream, state) {
stream._final(function (err) {
state.pendingcb--;
if (err) {
stream.emit('error', err);
}
state.prefinished = true;
stream.emit('prefinish');
finishMaybe(stream, state);
});
}
function prefinish(stream, state) {
if (!state.prefinished && !state.finalCalled) {
if (typeof stream._final === 'function') {
state.pendingcb++;
state.finalCalled = true;
pna.nextTick(callFinal, stream, state);
} else {
state.prefinished = true;
stream.emit('prefinish');
}
}
}
function finishMaybe(stream, state) {
var need = needFinish(state);
if (need) {
prefinish(stream, state);
if (state.pendingcb === 0) {
state.finished = true;
stream.emit('finish');
}
}
return need;
}
function endWritable(stream, state, cb) {
state.ending = true;
finishMaybe(stream, state);
if (cb) {
if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
}
state.ended = true;
stream.writable = false;
}
function onCorkedFinish(corkReq, state, err) {
var entry = corkReq.entry;
corkReq.entry = null;
while (entry) {
var cb = entry.callback;
state.pendingcb--;
cb(err);
entry = entry.next;
}
if (state.corkedRequestsFree) {
state.corkedRequestsFree.next = corkReq;
} else {
state.corkedRequestsFree = corkReq;
}
}
Object.defineProperty(Writable.prototype, 'destroyed', {
get: function () {
if (this._writableState === undefined) {
return false;
}
return this._writableState.destroyed;
},
set: function (value) {
// we ignore the value if the stream
// has not been initialized yet
if (!this._writableState) {
return;
}
// backward compatibility, the user is explicitly
// managing destroyed
this._writableState.destroyed = value;
}
});
Writable.prototype.destroy = destroyImpl.destroy;
Writable.prototype._undestroy = destroyImpl.undestroy;
Writable.prototype._destroy = function (err, cb) {
this.end();
cb(err);
};
\ No newline at end of file
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Buffer = require('safe-buffer').Buffer;
var util = require('util');
function copyBuffer(src, target, offset) {
src.copy(target, offset);
}
module.exports = function () {
function BufferList() {
_classCallCheck(this, BufferList);
this.head = null;
this.tail = null;
this.length = 0;
}
BufferList.prototype.push = function push(v) {
var entry = { data: v, next: null };
if (this.length > 0) this.tail.next = entry;else this.head = entry;
this.tail = entry;
++this.length;
};
BufferList.prototype.unshift = function unshift(v) {
var entry = { data: v, next: this.head };
if (this.length === 0) this.tail = entry;
this.head = entry;
++this.length;
};
BufferList.prototype.shift = function shift() {
if (this.length === 0) return;
var ret = this.head.data;
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
--this.length;
return ret;
};
BufferList.prototype.clear = function clear() {
this.head = this.tail = null;
this.length = 0;
};
BufferList.prototype.join = function join(s) {
if (this.length === 0) return '';
var p = this.head;
var ret = '' + p.data;
while (p = p.next) {
ret += s + p.data;
}return ret;
};
BufferList.prototype.concat = function concat(n) {
if (this.length === 0) return Buffer.alloc(0);
if (this.length === 1) return this.head.data;
var ret = Buffer.allocUnsafe(n >>> 0);
var p = this.head;
var i = 0;
while (p) {
copyBuffer(p.data, ret, i);
i += p.data.length;
p = p.next;
}
return ret;
};
return BufferList;
}();
if (util && util.inspect && util.inspect.custom) {
module.exports.prototype[util.inspect.custom] = function () {
var obj = util.inspect({ length: this.length });
return this.constructor.name + ' ' + obj;
};
}
\ No newline at end of file
'use strict';
/*<replacement>*/
var pna = require('process-nextick-args');
/*</replacement>*/
// undocumented cb() API, needed for core, not for public API
function destroy(err, cb) {
var _this = this;
var readableDestroyed = this._readableState && this._readableState.destroyed;
var writableDestroyed = this._writableState && this._writableState.destroyed;
if (readableDestroyed || writableDestroyed) {
if (cb) {
cb(err);
} else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
pna.nextTick(emitErrorNT, this, err);
}
return this;
}
// we set destroyed to true before firing error callbacks in order
// to make it re-entrance safe in case destroy() is called within callbacks
if (this._readableState) {
this._readableState.destroyed = true;
}
// if this is a duplex stream mark the writable part as destroyed as well
if (this._writableState) {
this._writableState.destroyed = true;
}
this._destroy(err || null, function (err) {
if (!cb && err) {
pna.nextTick(emitErrorNT, _this, err);
if (_this._writableState) {
_this._writableState.errorEmitted = true;
}
} else if (cb) {
cb(err);
}
});
return this;
}
function undestroy() {
if (this._readableState) {
this._readableState.destroyed = false;
this._readableState.reading = false;
this._readableState.ended = false;
this._readableState.endEmitted = false;
}
if (this._writableState) {
this._writableState.destroyed = false;
this._writableState.ended = false;
this._writableState.ending = false;
this._writableState.finished = false;
this._writableState.errorEmitted = false;
}
}
function emitErrorNT(self, err) {
self.emit('error', err);
}
module.exports = {
destroy: destroy,
undestroy: undestroy
};
\ No newline at end of file
module.exports = require('events').EventEmitter;
{
"_from": "readable-stream@2.3.7",
"_id": "readable-stream@2.3.7",
"_inBundle": false,
"_integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
"_location": "/readable-stream",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "readable-stream@2.3.7",
"name": "readable-stream",
"escapedName": "readable-stream",
"rawSpec": "2.3.7",
"saveSpec": null,
"fetchSpec": "2.3.7"
},
"_requiredBy": [
"/mysql"
],
"_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
"_shasum": "1eca1cf711aef814c04f62252a36a62f6cb23b57",
"_spec": "readable-stream@2.3.7",
"_where": "C:\\Users\\user\\Desktop\\Singer-Composer\\node_modules\\mysql",
"browser": {
"util": false,
"./readable.js": "./readable-browser.js",
"./writable.js": "./writable-browser.js",
"./duplex.js": "./duplex-browser.js",
"./lib/internal/streams/stream.js": "./lib/internal/streams/stream-browser.js"
},
"bugs": {
"url": "https://github.com/nodejs/readable-stream/issues"
},
"bundleDependencies": false,
"dependencies": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
},
"deprecated": false,
"description": "Streams3, a user-land copy of the stream library from Node.js",
"devDependencies": {
"assert": "^1.4.0",
"babel-polyfill": "^6.9.1",
"buffer": "^4.9.0",
"lolex": "^2.3.2",
"nyc": "^6.4.0",
"tap": "^0.7.0",
"tape": "^4.8.0"
},
"homepage": "https://github.com/nodejs/readable-stream#readme",
"keywords": [
"readable",
"stream",
"pipe"
],
"license": "MIT",
"main": "readable.js",
"name": "readable-stream",
"nyc": {
"include": [
"lib/**.js"
]
},
"repository": {
"type": "git",
"url": "git://github.com/nodejs/readable-stream.git"
},
"scripts": {
"ci": "tap test/parallel/*.js test/ours/*.js --tap | tee test.tap && node test/verify-dependencies.js",
"cover": "nyc npm test",
"report": "nyc report --reporter=lcov",
"test": "tap test/parallel/*.js test/ours/*.js && node test/verify-dependencies.js"
},
"version": "2.3.7"
}
module.exports = require('./readable').PassThrough
exports = module.exports = require('./lib/_stream_readable.js');
exports.Stream = exports;
exports.Readable = exports;
exports.Writable = require('./lib/_stream_writable.js');
exports.Duplex = require('./lib/_stream_duplex.js');
exports.Transform = require('./lib/_stream_transform.js');
exports.PassThrough = require('./lib/_stream_passthrough.js');
var Stream = require('stream');
if (process.env.READABLE_STREAM === 'disable' && Stream) {
module.exports = Stream;
exports = module.exports = Stream.Readable;
exports.Readable = Stream.Readable;
exports.Writable = Stream.Writable;
exports.Duplex = Stream.Duplex;
exports.Transform = Stream.Transform;
exports.PassThrough = Stream.PassThrough;
exports.Stream = Stream;
} else {
exports = module.exports = require('./lib/_stream_readable.js');
exports.Stream = Stream || exports;
exports.Readable = exports;
exports.Writable = require('./lib/_stream_writable.js');
exports.Duplex = require('./lib/_stream_duplex.js');
exports.Transform = require('./lib/_stream_transform.js');
exports.PassThrough = require('./lib/_stream_passthrough.js');
}
module.exports = require('./readable').Transform
module.exports = require('./lib/_stream_writable.js');
var Stream = require("stream")
var Writable = require("./lib/_stream_writable.js")
if (process.env.READABLE_STREAM === 'disable') {
module.exports = Stream && Stream.Writable || Writable
} else {
module.exports = Writable
}
2.3.1 / 2018-02-24
==================
* Fix incorrectly replacing non-placeholders in SQL
2.3.0 / 2017-10-01
==================
* Add `.toSqlString()` escape overriding
* Add `raw` method to wrap raw strings for escape overriding
* Small performance improvement on `escapeId`
2.2.0 / 2016-11-01
==================
* Escape invalid `Date` objects as `NULL`
2.1.0 / 2016-09-26
==================
* Accept numbers and other value types in `escapeId`
* Run `buffer.toString()` through escaping
2.0.1 / 2016-06-06
==================
* Fix npm package to include missing `lib/` directory
2.0.0 / 2016-06-06
==================
* Bring repository up-to-date with `mysql` module changes
* Support Node.js 0.6.x
1.0.0 / 2014-11-09
==================
* Support Node.js 0.8.x
0.0.1 / 2014-02-25
==================
* Initial release
Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# sqlstring
[![NPM Version][npm-version-image]][npm-url]
[![NPM Downloads][npm-downloads-image]][npm-url]
[![Node.js Version][node-image]][node-url]
[![Build Status][travis-image]][travis-url]
[![Coverage Status][coveralls-image]][coveralls-url]
Simple SQL escape and format for MySQL
## Install
```sh
$ npm install sqlstring
```
## Usage
<!-- eslint-disable no-unused-vars -->
```js
var SqlString = require('sqlstring');
```
### Escaping query values
**Caution** These methods of escaping values only works when the
[NO_BACKSLASH_ESCAPES](https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_no_backslash_escapes)
SQL mode is disabled (which is the default state for MySQL servers).
In order to avoid SQL Injection attacks, you should always escape any user
provided data before using it inside a SQL query. You can do so using the
`SqlString.escape()` method:
```js
var userId = 'some user provided value';
var sql = 'SELECT * FROM users WHERE id = ' + SqlString.escape(userId);
console.log(sql); // SELECT * FROM users WHERE id = 'some user provided value'
```
Alternatively, you can use `?` characters as placeholders for values you would
like to have escaped like this:
```js
var userId = 1;
var sql = SqlString.format('SELECT * FROM users WHERE id = ?', [userId]);
console.log(sql); // SELECT * FROM users WHERE id = 1
```
Multiple placeholders are mapped to values in the same order as passed. For example,
in the following query `foo` equals `a`, `bar` equals `b`, `baz` equals `c`, and
`id` will be `userId`:
```js
var userId = 1;
var sql = SqlString.format('UPDATE users SET foo = ?, bar = ?, baz = ? WHERE id = ?',
['a', 'b', 'c', userId]);
console.log(sql); // UPDATE users SET foo = 'a', bar = 'b', baz = 'c' WHERE id = 1
```
This looks similar to prepared statements in MySQL, however it really just uses
the same `SqlString.escape()` method internally.
**Caution** This also differs from prepared statements in that all `?` are
replaced, even those contained in comments and strings.
Different value types are escaped differently, here is how:
* Numbers are left untouched
* Booleans are converted to `true` / `false`
* Date objects are converted to `'YYYY-mm-dd HH:ii:ss'` strings
* Buffers are converted to hex strings, e.g. `X'0fa5'`
* Strings are safely escaped
* Arrays are turned into list, e.g. `['a', 'b']` turns into `'a', 'b'`
* Nested arrays are turned into grouped lists (for bulk inserts), e.g. `[['a',
'b'], ['c', 'd']]` turns into `('a', 'b'), ('c', 'd')`
* Objects that have a `toSqlString` method will have `.toSqlString()` called
and the returned value is used as the raw SQL.
* Objects are turned into `key = 'val'` pairs for each enumerable property on
the object. If the property's value is a function, it is skipped; if the
property's value is an object, toString() is called on it and the returned
value is used.
* `undefined` / `null` are converted to `NULL`
* `NaN` / `Infinity` are left as-is. MySQL does not support these, and trying
to insert them as values will trigger MySQL errors until they implement
support.
You may have noticed that this escaping allows you to do neat things like this:
```js
var post = {id: 1, title: 'Hello MySQL'};
var sql = SqlString.format('INSERT INTO posts SET ?', post);
console.log(sql); // INSERT INTO posts SET `id` = 1, `title` = 'Hello MySQL'
```
And the `toSqlString` method allows you to form complex queries with functions:
```js
var CURRENT_TIMESTAMP = { toSqlString: function() { return 'CURRENT_TIMESTAMP()'; } };
var sql = SqlString.format('UPDATE posts SET modified = ? WHERE id = ?', [CURRENT_TIMESTAMP, 42]);
console.log(sql); // UPDATE posts SET modified = CURRENT_TIMESTAMP() WHERE id = 42
```
To generate objects with a `toSqlString` method, the `SqlString.raw()` method can
be used. This creates an object that will be left un-touched when using in a `?`
placeholder, useful for using functions as dynamic values:
**Caution** The string provided to `SqlString.raw()` will skip all escaping
functions when used, so be careful when passing in unvalidated input.
```js
var CURRENT_TIMESTAMP = SqlString.raw('CURRENT_TIMESTAMP()');
var sql = SqlString.format('UPDATE posts SET modified = ? WHERE id = ?', [CURRENT_TIMESTAMP, 42]);
console.log(sql); // UPDATE posts SET modified = CURRENT_TIMESTAMP() WHERE id = 42
```
If you feel the need to escape queries by yourself, you can also use the escaping
function directly:
```js
var sql = 'SELECT * FROM posts WHERE title=' + SqlString.escape('Hello MySQL');
console.log(sql); // SELECT * FROM posts WHERE title='Hello MySQL'
```
### Escaping query identifiers
If you can't trust an SQL identifier (database / table / column name) because it is
provided by a user, you should escape it with `SqlString.escapeId(identifier)` like this:
```js
var sorter = 'date';
var sql = 'SELECT * FROM posts ORDER BY ' + SqlString.escapeId(sorter);
console.log(sql); // SELECT * FROM posts ORDER BY `date`
```
It also supports adding qualified identifiers. It will escape both parts.
```js
var sorter = 'date';
var sql = 'SELECT * FROM posts ORDER BY ' + SqlString.escapeId('posts.' + sorter);
console.log(sql); // SELECT * FROM posts ORDER BY `posts`.`date`
```
If you do not want to treat `.` as qualified identifiers, you can set the second
argument to `true` in order to keep the string as a literal identifier:
```js
var sorter = 'date.2';
var sql = 'SELECT * FROM posts ORDER BY ' + SqlString.escapeId(sorter, true);
console.log(sql); // SELECT * FROM posts ORDER BY `date.2`
```
Alternatively, you can use `??` characters as placeholders for identifiers you would
like to have escaped like this:
```js
var userId = 1;
var columns = ['username', 'email'];
var sql = SqlString.format('SELECT ?? FROM ?? WHERE id = ?', [columns, 'users', userId]);
console.log(sql); // SELECT `username`, `email` FROM `users` WHERE id = 1
```
**Please note that this last character sequence is experimental and syntax might change**
When you pass an Object to `.escape()` or `.format()`, `.escapeId()` is used to avoid SQL injection in object keys.
### Formatting queries
You can use `SqlString.format` to prepare a query with multiple insertion points,
utilizing the proper escaping for ids and values. A simple example of this follows:
```js
var userId = 1;
var inserts = ['users', 'id', userId];
var sql = SqlString.format('SELECT * FROM ?? WHERE ?? = ?', inserts);
console.log(sql); // SELECT * FROM `users` WHERE `id` = 1
```
Following this you then have a valid, escaped query that you can then send to the database safely.
This is useful if you are looking to prepare the query before actually sending it to the database.
You also have the option (but are not required) to pass in `stringifyObject` and `timeZone`,
allowing you provide a custom means of turning objects into strings, as well as a
location-specific/timezone-aware `Date`.
This can be further combined with the `SqlString.raw()` helper to generate SQL
that includes MySQL functions as dynamic vales:
```js
var userId = 1;
var data = { email: 'foobar@example.com', modified: SqlString.raw('NOW()') };
var sql = SqlString.format('UPDATE ?? SET ? WHERE `id` = ?', ['users', data, userId]);
console.log(sql); // UPDATE `users` SET `email` = 'foobar@example.com', `modified` = NOW() WHERE `id` = 1
```
## License
[MIT](LICENSE)
[npm-version-image]: https://img.shields.io/npm/v/sqlstring.svg
[npm-downloads-image]: https://img.shields.io/npm/dm/sqlstring.svg
[npm-url]: https://npmjs.org/package/sqlstring
[travis-image]: https://img.shields.io/travis/mysqljs/sqlstring/master.svg
[travis-url]: https://travis-ci.org/mysqljs/sqlstring
[coveralls-image]: https://img.shields.io/coveralls/mysqljs/sqlstring/master.svg
[coveralls-url]: https://coveralls.io/r/mysqljs/sqlstring?branch=master
[node-image]: https://img.shields.io/node/v/sqlstring.svg
[node-url]: https://nodejs.org/en/download
module.exports = require('./lib/SqlString');
var SqlString = exports;
var ID_GLOBAL_REGEXP = /`/g;
var QUAL_GLOBAL_REGEXP = /\./g;
var CHARS_GLOBAL_REGEXP = /[\0\b\t\n\r\x1a\"\'\\]/g; // eslint-disable-line no-control-regex
var CHARS_ESCAPE_MAP = {
'\0' : '\\0',
'\b' : '\\b',
'\t' : '\\t',
'\n' : '\\n',
'\r' : '\\r',
'\x1a' : '\\Z',
'"' : '\\"',
'\'' : '\\\'',
'\\' : '\\\\'
};
SqlString.escapeId = function escapeId(val, forbidQualified) {
if (Array.isArray(val)) {
var sql = '';
for (var i = 0; i < val.length; i++) {
sql += (i === 0 ? '' : ', ') + SqlString.escapeId(val[i], forbidQualified);
}
return sql;
} else if (forbidQualified) {
return '`' + String(val).replace(ID_GLOBAL_REGEXP, '``') + '`';
} else {
return '`' + String(val).replace(ID_GLOBAL_REGEXP, '``').replace(QUAL_GLOBAL_REGEXP, '`.`') + '`';
}
};
SqlString.escape = function escape(val, stringifyObjects, timeZone) {
if (val === undefined || val === null) {
return 'NULL';
}
switch (typeof val) {
case 'boolean': return (val) ? 'true' : 'false';
case 'number': return val + '';
case 'object':
if (val instanceof Date) {
return SqlString.dateToString(val, timeZone || 'local');
} else if (Array.isArray(val)) {
return SqlString.arrayToList(val, timeZone);
} else if (Buffer.isBuffer(val)) {
return SqlString.bufferToString(val);
} else if (typeof val.toSqlString === 'function') {
return String(val.toSqlString());
} else if (stringifyObjects) {
return escapeString(val.toString());
} else {
return SqlString.objectToValues(val, timeZone);
}
default: return escapeString(val);
}
};
SqlString.arrayToList = function arrayToList(array, timeZone) {
var sql = '';
for (var i = 0; i < array.length; i++) {
var val = array[i];
if (Array.isArray(val)) {
sql += (i === 0 ? '' : ', ') + '(' + SqlString.arrayToList(val, timeZone) + ')';
} else {
sql += (i === 0 ? '' : ', ') + SqlString.escape(val, true, timeZone);
}
}
return sql;
};
SqlString.format = function format(sql, values, stringifyObjects, timeZone) {
if (values == null) {
return sql;
}
if (!(values instanceof Array || Array.isArray(values))) {
values = [values];
}
var chunkIndex = 0;
var placeholdersRegex = /\?+/g;
var result = '';
var valuesIndex = 0;
var match;
while (valuesIndex < values.length && (match = placeholdersRegex.exec(sql))) {
var len = match[0].length;
if (len > 2) {
continue;
}
var value = len === 2
? SqlString.escapeId(values[valuesIndex])
: SqlString.escape(values[valuesIndex], stringifyObjects, timeZone);
result += sql.slice(chunkIndex, match.index) + value;
chunkIndex = placeholdersRegex.lastIndex;
valuesIndex++;
}
if (chunkIndex === 0) {
// Nothing was replaced
return sql;
}
if (chunkIndex < sql.length) {
return result + sql.slice(chunkIndex);
}
return result;
};
SqlString.dateToString = function dateToString(date, timeZone) {
var dt = new Date(date);
if (isNaN(dt.getTime())) {
return 'NULL';
}
var year;
var month;
var day;
var hour;
var minute;
var second;
var millisecond;
if (timeZone === 'local') {
year = dt.getFullYear();
month = dt.getMonth() + 1;
day = dt.getDate();
hour = dt.getHours();
minute = dt.getMinutes();
second = dt.getSeconds();
millisecond = dt.getMilliseconds();
} else {
var tz = convertTimezone(timeZone);
if (tz !== false && tz !== 0) {
dt.setTime(dt.getTime() + (tz * 60000));
}
year = dt.getUTCFullYear();
month = dt.getUTCMonth() + 1;
day = dt.getUTCDate();
hour = dt.getUTCHours();
minute = dt.getUTCMinutes();
second = dt.getUTCSeconds();
millisecond = dt.getUTCMilliseconds();
}
// YYYY-MM-DD HH:mm:ss.mmm
var str = zeroPad(year, 4) + '-' + zeroPad(month, 2) + '-' + zeroPad(day, 2) + ' ' +
zeroPad(hour, 2) + ':' + zeroPad(minute, 2) + ':' + zeroPad(second, 2) + '.' +
zeroPad(millisecond, 3);
return escapeString(str);
};
SqlString.bufferToString = function bufferToString(buffer) {
return 'X' + escapeString(buffer.toString('hex'));
};
SqlString.objectToValues = function objectToValues(object, timeZone) {
var sql = '';
for (var key in object) {
var val = object[key];
if (typeof val === 'function') {
continue;
}
sql += (sql.length === 0 ? '' : ', ') + SqlString.escapeId(key) + ' = ' + SqlString.escape(val, true, timeZone);
}
return sql;
};
SqlString.raw = function raw(sql) {
if (typeof sql !== 'string') {
throw new TypeError('argument sql must be a string');
}
return {
toSqlString: function toSqlString() { return sql; }
};
};
function escapeString(val) {
var chunkIndex = CHARS_GLOBAL_REGEXP.lastIndex = 0;
var escapedVal = '';
var match;
while ((match = CHARS_GLOBAL_REGEXP.exec(val))) {
escapedVal += val.slice(chunkIndex, match.index) + CHARS_ESCAPE_MAP[match[0]];
chunkIndex = CHARS_GLOBAL_REGEXP.lastIndex;
}
if (chunkIndex === 0) {
// Nothing was escaped
return "'" + val + "'";
}
if (chunkIndex < val.length) {
return "'" + escapedVal + val.slice(chunkIndex) + "'";
}
return "'" + escapedVal + "'";
}
function zeroPad(number, length) {
number = number.toString();
while (number.length < length) {
number = '0' + number;
}
return number;
}
function convertTimezone(tz) {
if (tz === 'Z') {
return 0;
}
var m = tz.match(/([\+\-\s])(\d\d):?(\d\d)?/);
if (m) {
return (m[1] === '-' ? -1 : 1) * (parseInt(m[2], 10) + ((m[3] ? parseInt(m[3], 10) : 0) / 60)) * 60;
}
return false;
}
{
"_from": "sqlstring@2.3.1",
"_id": "sqlstring@2.3.1",
"_inBundle": false,
"_integrity": "sha1-R1OT/56RR5rqYtyvDKPRSYOn+0A=",
"_location": "/sqlstring",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "sqlstring@2.3.1",
"name": "sqlstring",
"escapedName": "sqlstring",
"rawSpec": "2.3.1",
"saveSpec": null,
"fetchSpec": "2.3.1"
},
"_requiredBy": [
"/mysql"
],
"_resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz",
"_shasum": "475393ff9e91479aea62dcaf0ca3d14983a7fb40",
"_spec": "sqlstring@2.3.1",
"_where": "C:\\Users\\user\\Desktop\\Singer-Composer\\node_modules\\mysql",
"bugs": {
"url": "https://github.com/mysqljs/sqlstring/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Adri Van Houdt",
"email": "adri.van.houdt@gmail.com"
},
{
"name": "Douglas Christopher Wilson",
"email": "doug@somethingdoug.com"
},
{
"name": "fengmk2",
"email": "fengmk2@gmail.com",
"url": "http://fengmk2.github.com"
},
{
"name": "Kevin Jose Martin",
"email": "kevin@tiliq.com"
},
{
"name": "Nathan Woltman",
"email": "nwoltman@outlook.com"
},
{
"name": "Sergej Sintschilin",
"email": "seregpie@gmail.com"
}
],
"deprecated": false,
"description": "Simple SQL escape and format for MySQL",
"devDependencies": {
"beautify-benchmark": "0.2.4",
"benchmark": "2.1.4",
"eslint": "4.18.1",
"eslint-plugin-markdown": "1.0.0-beta.6",
"nyc": "10.3.2",
"urun": "0.0.8",
"utest": "0.0.8"
},
"engines": {
"node": ">= 0.6"
},
"files": [
"lib/",
"HISTORY.md",
"LICENSE",
"README.md",
"index.js"
],
"homepage": "https://github.com/mysqljs/sqlstring#readme",
"keywords": [
"sqlstring",
"sql",
"escape",
"sql escape"
],
"license": "MIT",
"name": "sqlstring",
"repository": {
"type": "git",
"url": "git+https://github.com/mysqljs/sqlstring.git"
},
"scripts": {
"bench": "node benchmark/index.js",
"lint": "eslint --plugin markdown --ext js,md .",
"test": "node test/run.js",
"test-ci": "nyc --reporter=text npm test",
"test-cov": "nyc --reporter=html --reporter=text npm test"
},
"version": "2.3.1"
}
sudo: false
language: node_js
before_install:
- npm install -g npm@2
- test $NPM_LEGACY && npm install -g npm@latest-3 || npm install npm -g
notifications:
email: false
matrix:
fast_finish: true
include:
- node_js: '0.8'
env:
- TASK=test
- NPM_LEGACY=true
- node_js: '0.10'
env:
- TASK=test
- NPM_LEGACY=true
- node_js: '0.11'
env:
- TASK=test
- NPM_LEGACY=true
- node_js: '0.12'
env:
- TASK=test
- NPM_LEGACY=true
- node_js: 1
env:
- TASK=test
- NPM_LEGACY=true
- node_js: 2
env:
- TASK=test
- NPM_LEGACY=true
- node_js: 3
env:
- TASK=test
- NPM_LEGACY=true
- node_js: 4
env: TASK=test
- node_js: 5
env: TASK=test
- node_js: 6
env: TASK=test
- node_js: 7
env: TASK=test
- node_js: 8
env: TASK=test
- node_js: 9
env: TASK=test
Node.js is licensed for use as follows:
"""
Copyright Node.js contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""
This license applies to parts of Node.js originating from the
https://github.com/joyent/node repository:
"""
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""
# string_decoder
***Node-core v8.9.4 string_decoder for userland***
[![NPM](https://nodei.co/npm/string_decoder.png?downloads=true&downloadRank=true)](https://nodei.co/npm/string_decoder/)
[![NPM](https://nodei.co/npm-dl/string_decoder.png?&months=6&height=3)](https://nodei.co/npm/string_decoder/)
```bash
npm install --save string_decoder
```
***Node-core string_decoder for userland***
This package is a mirror of the string_decoder implementation in Node-core.
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.9.4/docs/api/).
As of version 1.0.0 **string_decoder** uses semantic versioning.
## Previous versions
Previous version numbers match the versions found in Node core, e.g. 0.10.24 matches Node 0.10.24, likewise 0.11.10 matches Node 0.11.10.
## Update
The *build/* directory contains a build script that will scrape the source from the [nodejs/node](https://github.com/nodejs/node) repo given a specific Node version.
## Streams Working Group
`string_decoder` is maintained by the Streams Working Group, which
oversees the development and maintenance of the Streams API within
Node.js. The responsibilities of the Streams Working Group include:
* Addressing stream issues on the Node.js issue tracker.
* Authoring and editing stream documentation within the Node.js project.
* Reviewing changes to stream subclasses within the Node.js project.
* Redirecting changes to streams from the Node.js project to this
project.
* Assisting in the implementation of stream providers within Node.js.
* Recommending versions of `readable-stream` to be included in Node.js.
* Messaging about the future of streams to give the community advance
notice of changes.
See [readable-stream](https://github.com/nodejs/readable-stream) for
more details.
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
/*<replacement>*/
var Buffer = require('safe-buffer').Buffer;
/*</replacement>*/
var isEncoding = Buffer.isEncoding || function (encoding) {
encoding = '' + encoding;
switch (encoding && encoding.toLowerCase()) {
case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
return true;
default:
return false;
}
};
function _normalizeEncoding(enc) {
if (!enc) return 'utf8';
var retried;
while (true) {
switch (enc) {
case 'utf8':
case 'utf-8':
return 'utf8';
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return 'utf16le';
case 'latin1':
case 'binary':
return 'latin1';
case 'base64':
case 'ascii':
case 'hex':
return enc;
default:
if (retried) return; // undefined
enc = ('' + enc).toLowerCase();
retried = true;
}
}
};
// Do not cache `Buffer.isEncoding` when checking encoding names as some
// modules monkey-patch it to support additional encodings
function normalizeEncoding(enc) {
var nenc = _normalizeEncoding(enc);
if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
return nenc || enc;
}
// StringDecoder provides an interface for efficiently splitting a series of
// buffers into a series of JS strings without breaking apart multi-byte
// characters.
exports.StringDecoder = StringDecoder;
function StringDecoder(encoding) {
this.encoding = normalizeEncoding(encoding);
var nb;
switch (this.encoding) {
case 'utf16le':
this.text = utf16Text;
this.end = utf16End;
nb = 4;
break;
case 'utf8':
this.fillLast = utf8FillLast;
nb = 4;
break;
case 'base64':
this.text = base64Text;
this.end = base64End;
nb = 3;
break;
default:
this.write = simpleWrite;
this.end = simpleEnd;
return;
}
this.lastNeed = 0;
this.lastTotal = 0;
this.lastChar = Buffer.allocUnsafe(nb);
}
StringDecoder.prototype.write = function (buf) {
if (buf.length === 0) return '';
var r;
var i;
if (this.lastNeed) {
r = this.fillLast(buf);
if (r === undefined) return '';
i = this.lastNeed;
this.lastNeed = 0;
} else {
i = 0;
}
if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
return r || '';
};
StringDecoder.prototype.end = utf8End;
// Returns only complete characters in a Buffer
StringDecoder.prototype.text = utf8Text;
// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
StringDecoder.prototype.fillLast = function (buf) {
if (this.lastNeed <= buf.length) {
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
}
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
this.lastNeed -= buf.length;
};
// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
// continuation byte. If an invalid byte is detected, -2 is returned.
function utf8CheckByte(byte) {
if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
return byte >> 6 === 0x02 ? -1 : -2;
}
// Checks at most 3 bytes at the end of a Buffer in order to detect an
// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
// needed to complete the UTF-8 character (if applicable) are returned.
function utf8CheckIncomplete(self, buf, i) {
var j = buf.length - 1;
if (j < i) return 0;
var nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) self.lastNeed = nb - 1;
return nb;
}
if (--j < i || nb === -2) return 0;
nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) self.lastNeed = nb - 2;
return nb;
}
if (--j < i || nb === -2) return 0;
nb = utf8CheckByte(buf[j]);
if (nb >= 0) {
if (nb > 0) {
if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
}
return nb;
}
return 0;
}
// Validates as many continuation bytes for a multi-byte UTF-8 character as
// needed or are available. If we see a non-continuation byte where we expect
// one, we "replace" the validated continuation bytes we've seen so far with
// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
// behavior. The continuation byte check is included three times in the case
// where all of the continuation bytes for a character exist in the same buffer.
// It is also done this way as a slight performance increase instead of using a
// loop.
function utf8CheckExtraBytes(self, buf, p) {
if ((buf[0] & 0xC0) !== 0x80) {
self.lastNeed = 0;
return '\ufffd';
}
if (self.lastNeed > 1 && buf.length > 1) {
if ((buf[1] & 0xC0) !== 0x80) {
self.lastNeed = 1;
return '\ufffd';
}
if (self.lastNeed > 2 && buf.length > 2) {
if ((buf[2] & 0xC0) !== 0x80) {
self.lastNeed = 2;
return '\ufffd';
}
}
}
}
// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
function utf8FillLast(buf) {
var p = this.lastTotal - this.lastNeed;
var r = utf8CheckExtraBytes(this, buf, p);
if (r !== undefined) return r;
if (this.lastNeed <= buf.length) {
buf.copy(this.lastChar, p, 0, this.lastNeed);
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
}
buf.copy(this.lastChar, p, 0, buf.length);
this.lastNeed -= buf.length;
}
// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
// partial character, the character's bytes are buffered until the required
// number of bytes are available.
function utf8Text(buf, i) {
var total = utf8CheckIncomplete(this, buf, i);
if (!this.lastNeed) return buf.toString('utf8', i);
this.lastTotal = total;
var end = buf.length - (total - this.lastNeed);
buf.copy(this.lastChar, 0, end);
return buf.toString('utf8', i, end);
}
// For UTF-8, a replacement character is added when ending on a partial
// character.
function utf8End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) return r + '\ufffd';
return r;
}
// UTF-16LE typically needs two bytes per character, but even if we have an even
// number of bytes available, we need to check if we end on a leading/high
// surrogate. In that case, we need to wait for the next two bytes in order to
// decode the last character properly.
function utf16Text(buf, i) {
if ((buf.length - i) % 2 === 0) {
var r = buf.toString('utf16le', i);
if (r) {
var c = r.charCodeAt(r.length - 1);
if (c >= 0xD800 && c <= 0xDBFF) {
this.lastNeed = 2;
this.lastTotal = 4;
this.lastChar[0] = buf[buf.length - 2];
this.lastChar[1] = buf[buf.length - 1];
return r.slice(0, -1);
}
}
return r;
}
this.lastNeed = 1;
this.lastTotal = 2;
this.lastChar[0] = buf[buf.length - 1];
return buf.toString('utf16le', i, buf.length - 1);
}
// For UTF-16LE we do not explicitly append special replacement characters if we
// end on a partial character, we simply let v8 handle that.
function utf16End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) {
var end = this.lastTotal - this.lastNeed;
return r + this.lastChar.toString('utf16le', 0, end);
}
return r;
}
function base64Text(buf, i) {
var n = (buf.length - i) % 3;
if (n === 0) return buf.toString('base64', i);
this.lastNeed = 3 - n;
this.lastTotal = 3;
if (n === 1) {
this.lastChar[0] = buf[buf.length - 1];
} else {
this.lastChar[0] = buf[buf.length - 2];
this.lastChar[1] = buf[buf.length - 1];
}
return buf.toString('base64', i, buf.length - n);
}
function base64End(buf) {
var r = buf && buf.length ? this.write(buf) : '';
if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
return r;
}
// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
function simpleWrite(buf) {
return buf.toString(this.encoding);
}
function simpleEnd(buf) {
return buf && buf.length ? this.write(buf) : '';
}
\ No newline at end of file
{
"_from": "string_decoder@~1.1.1",
"_id": "string_decoder@1.1.1",
"_inBundle": false,
"_integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"_location": "/string_decoder",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "string_decoder@~1.1.1",
"name": "string_decoder",
"escapedName": "string_decoder",
"rawSpec": "~1.1.1",
"saveSpec": null,
"fetchSpec": "~1.1.1"
},
"_requiredBy": [
"/readable-stream"
],
"_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"_shasum": "9cf1611ba62685d7030ae9e4ba34149c3af03fc8",
"_spec": "string_decoder@~1.1.1",
"_where": "C:\\Users\\user\\Desktop\\Singer-Composer\\node_modules\\readable-stream",
"bugs": {
"url": "https://github.com/nodejs/string_decoder/issues"
},
"bundleDependencies": false,
"dependencies": {
"safe-buffer": "~5.1.0"
},
"deprecated": false,
"description": "The string_decoder module from Node core",
"devDependencies": {
"babel-polyfill": "^6.23.0",
"core-util-is": "^1.0.2",
"inherits": "^2.0.3",
"tap": "~0.4.8"
},
"homepage": "https://github.com/nodejs/string_decoder",
"keywords": [
"string",
"decoder",
"browser",
"browserify"
],
"license": "MIT",
"main": "lib/string_decoder.js",
"name": "string_decoder",
"repository": {
"type": "git",
"url": "git://github.com/nodejs/string_decoder.git"
},
"scripts": {
"ci": "tap test/parallel/*.js test/ours/*.js --tap | tee test.tap && node test/verify-dependencies.js",
"test": "tap test/parallel/*.js && node test/verify-dependencies"
},
"version": "1.1.1"
}
1.0.2 / 2015-10-07
==================
* use try/catch when checking `localStorage` (#3, @kumavis)
1.0.1 / 2014-11-25
==================
* browser: use `console.warn()` for deprecation calls
* browser: more jsdocs
1.0.0 / 2014-04-30
==================
* initial commit
(The MIT License)
Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
util-deprecate
==============
### The Node.js `util.deprecate()` function with browser support
In Node.js, this module simply re-exports the `util.deprecate()` function.
In the web browser (i.e. via browserify), a browser-specific implementation
of the `util.deprecate()` function is used.
## API
A `deprecate()` function is the only thing exposed by this module.
``` javascript
// setup:
exports.foo = deprecate(foo, 'foo() is deprecated, use bar() instead');
// users see:
foo();
// foo() is deprecated, use bar() instead
foo();
foo();
```
## License
(The MIT License)
Copyright (c) 2014 Nathan Rajlich <nathan@tootallnate.net>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
/**
* Module exports.
*/
module.exports = deprecate;
/**
* Mark that a method should not be used.
* Returns a modified function which warns once by default.
*
* If `localStorage.noDeprecation = true` is set, then it is a no-op.
*
* If `localStorage.throwDeprecation = true` is set, then deprecated functions
* will throw an Error when invoked.
*
* If `localStorage.traceDeprecation = true` is set, then deprecated functions
* will invoke `console.trace()` instead of `console.error()`.
*
* @param {Function} fn - the function to deprecate
* @param {String} msg - the string to print to the console when `fn` is invoked
* @returns {Function} a new "deprecated" version of `fn`
* @api public
*/
function deprecate (fn, msg) {
if (config('noDeprecation')) {
return fn;
}
var warned = false;
function deprecated() {
if (!warned) {
if (config('throwDeprecation')) {
throw new Error(msg);
} else if (config('traceDeprecation')) {
console.trace(msg);
} else {
console.warn(msg);
}
warned = true;
}
return fn.apply(this, arguments);
}
return deprecated;
}
/**
* Checks `localStorage` for boolean values for the given `name`.
*
* @param {String} name
* @returns {Boolean}
* @api private
*/
function config (name) {
// accessing global.localStorage can trigger a DOMException in sandboxed iframes
try {
if (!global.localStorage) return false;
} catch (_) {
return false;
}
var val = global.localStorage[name];
if (null == val) return false;
return String(val).toLowerCase() === 'true';
}
/**
* For Node.js, simply re-export the core `util.deprecate` function.
*/
module.exports = require('util').deprecate;
{
"_from": "util-deprecate@~1.0.1",
"_id": "util-deprecate@1.0.2",
"_inBundle": false,
"_integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
"_location": "/util-deprecate",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "util-deprecate@~1.0.1",
"name": "util-deprecate",
"escapedName": "util-deprecate",
"rawSpec": "~1.0.1",
"saveSpec": null,
"fetchSpec": "~1.0.1"
},
"_requiredBy": [
"/readable-stream"
],
"_resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"_shasum": "450d4dc9fa70de732762fbd2d4a28981419a0ccf",
"_spec": "util-deprecate@~1.0.1",
"_where": "C:\\Users\\user\\Desktop\\Singer-Composer\\node_modules\\readable-stream",
"author": {
"name": "Nathan Rajlich",
"email": "nathan@tootallnate.net",
"url": "http://n8.io/"
},
"browser": "browser.js",
"bugs": {
"url": "https://github.com/TooTallNate/util-deprecate/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "The Node.js `util.deprecate()` function with browser support",
"homepage": "https://github.com/TooTallNate/util-deprecate",
"keywords": [
"util",
"deprecate",
"browserify",
"browser",
"node"
],
"license": "MIT",
"main": "node.js",
"name": "util-deprecate",
"repository": {
"type": "git",
"url": "git://github.com/TooTallNate/util-deprecate.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.0.2"
}
......@@ -138,6 +138,11 @@
"tweetnacl": "^0.14.3"
}
},
"bignumber.js": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz",
"integrity": "sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A=="
},
"body-parser": {
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
......@@ -250,8 +255,7 @@
"core-util-is": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
"dev": true
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"cssom": {
"version": "0.3.8",
......@@ -652,6 +656,11 @@
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
"dev": true
},
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"isstream": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
......@@ -822,6 +831,17 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"mysql": {
"version": "2.18.1",
"resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz",
"integrity": "sha512-Bca+gk2YWmqp2Uf6k5NFEurwY/0td0cpebAucFpY/3jhrwrVGuxU2uQFCHjU19SJfje0yQvi+rVWdq78hR5lig==",
"requires": {
"bignumber.js": "9.0.0",
"readable-stream": "2.3.7",
"safe-buffer": "5.1.2",
"sqlstring": "2.3.1"
}
},
"negotiator": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
......@@ -932,6 +952,11 @@
"integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=",
"dev": true
},
"process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
},
"proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
......@@ -980,6 +1005,20 @@
"unpipe": "1.0.0"
}
},
"readable-stream": {
"version": "2.3.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
"integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
},
"request": {
"version": "2.88.2",
"resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz",
......@@ -1102,6 +1141,11 @@
"dev": true,
"optional": true
},
"sqlstring": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz",
"integrity": "sha1-R1OT/56RR5rqYtyvDKPRSYOn+0A="
},
"sshpk": {
"version": "1.16.1",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz",
......@@ -1130,6 +1174,14 @@
"integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=",
"dev": true
},
"string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"requires": {
"safe-buffer": "~5.1.0"
}
},
"supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
......@@ -1224,6 +1276,11 @@
"punycode": "^2.1.0"
}
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
......
......@@ -10,7 +10,8 @@
"license": "ISC",
"dependencies": {
"ejs": "^3.1.6",
"express": "^4.17.1"
"express": "^4.17.1",
"mysql": "^2.18.1"
},
"devDependencies": {
"connect-flash": "^0.1.1",
......