{"name":"integer","version":"1.0.7","description":"Native 64-bit integers with overflow protection.","main":"lib/index.js","scripts":{"install-debug":"node-gyp rebuild --debug","test":"$(npm bin)/mocha --bail --timeout 1000 --slow 500","install":"node-gyp rebuild"},"repository":{"type":"git","url":"git://github.com/JoshuaWise/integer.git"},"keywords":["integer","64-bit","64bit","int","overflow","native"],"author":{"name":"Joshua Wise","email":"joshuathomaswise@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/JoshuaWise/integer/issues"},"homepage":"https://github.com/JoshuaWise/integer#readme","dependencies":{"bindings":"^1.3.0"},"devDependencies":{"chai":"^4.1.2","mocha":"^3.5.3"},"gypfile":true,"gitHead":"3c31767dcbd2905f47576ae057c28a5930f90d3e","_id":"integer@1.0.7","_shasum":"28b4aa59412bcd7159c337020ba9aed939ab4467","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.10.3","_npmUser":{"name":"joshuawise","email":"joshuathomaswise@gmail.com"},"dist":{"shasum":"28b4aa59412bcd7159c337020ba9aed939ab4467","tarball":"http://registry-npm.ywwl.com/integer/download/integer-1.0.7.tgz","integrity":"sha512-V/HQn/gkGjY5La5r1bzOkCSwnmrk+DmiZ8jWJMiW2zwLhU9plNvOSh1jcYUHa5ee/7u6DXKjws5b2I7QPW1+Nw==","fileCount":26,"unpackedSize":80695,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbnwjdCRA9TVsSAnZWagAAWdcP+QBGftT1SZE5aV1PugKx\ngopbgZ4VU13cABXIf7KV3/zXrOVJ7tm3seJZHVvBWk5a52EOiP1V4mo4Z7zX\neWcnBbRTakHBh5rsJcTcSaMSosrwOHVQGi8LpgCWMWCcXLu1pfnQ+ecFzj3V\nHc1HPTyfGTQrLYeXDp40ElT+VTlsvNcjfuEZlKccuCrpflp5kCLl2+SI5BNu\nJQTwxmVF2gWpC7NZiwdIMP3ljIt1t82YnCTNMgztpXT9YMMrkwOoE1NNr4Iq\nj0ePBK6cpq5w7iGAwFWTGp7gsY87ORnMPDnNg6z96HruJJKlsjXCRng10c7r\nUYOD91Ci0Qsc5079ue33DO0U62TlfuiaX23wM3t09qHvKZOQPL1RR9qBv/Zc\nZ93fZDIA0tEp58QSiiMnHv31orv+SFIP1sBts3aM+V9GhOKJmfC9gm6es9+n\n7Xa1V2bonFIcuKgcylqomUBugzUYV4pp5wTcpl2a6BsjULhD/BMo0Ugv0oir\nLxkn5zFgCIGsEgEEotrWxaANOM5WXio29W/jGwiwEKBy4e1l1ywyxpB0B3ZY\nPEk8tiQrn5PV7aJWzuWDti5cY6O8kJ7rjWExAEdFdFEJoPS78AGJsT29keKD\nb023hqP+caZ+mVzp5rPyF2S4ACPMCeYXNCuiQgt3EYwgeFzx6euhOClVy9QN\nakRF\r\n=1hBc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDsiBJDu+63akZf65h2/audKOb2awyQpk9ZAf4FqqDbVgIhAN4kBtnX8lmR1q/XFrrhkP4vtsZB8IW8fcw/iV+Nh2/+"}],"size":16110,"noattachment":false,"key":"/integer/-/integer-1.0.7.tgz"},"maintainers":[{"email":"joshuathomaswise@gmail.com","name":"joshuawise"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/integer_1.0.7_1537149149308_0.7692700196418516"},"_hasShrinkwrap":false,"readme":"# integer [![Build Status](https://travis-ci.org/JoshuaWise/integer.svg?branch=master)](https://travis-ci.org/JoshuaWise/integer)\n\nNative 64-bit signed integers in Node.js.\n\n- All standard operators (arithmetic, bitwise, logical)\n- Protection from overflow and unsafe numbers\n- Always immutable\n- Other useful utilities\n\n## Installation\n\n```bash\nnpm install --save integer\n```\n\n> You must be using Node.js v10 or above. Prebuilt binaries are available for [LTS versions](https://nodejs.org/en/about/releases/) + Linux/OSX.\n\n## Usage\n\n```js\nvar Integer = require('integer');\n\nvar a = Integer('7129837312139827189');\nvar b = a.subtract(1).shiftRight(3);\nassert(b.equals('891229664017478398'));\n```\n\n## Overflow protection\n\nWe will not let you perform operations that would result in overflow. If you try to create an `Integer` that cannot be represented in 64-bits (signed), we will throw a `RangeError`.\n\n```js\n// These will each throw a RangeError\nvar tooBig = Integer(13897283129).multiply(13897283129);\nvar tooSmall = Integer.MIN_VALUE.subtract(1);\nvar divideByZero = Integer(123).divide(0);\nvar alsoTooBig = Integer('4029384203948203948923');\n\n// You are also protected against two's complement overflow (this will throw a RangeError)\nvar twosComplement = Integer.MIN_VALUE.divide(-1);\n```\n\n## Unsafe number protection\n\nIt's easy to convert between me and regular JavaScript numbers.\n\n```js\nvar int = Integer(12345);\nassert(int instanceof Integer);\n\nvar num = Number(int); // same as int.toNumber()\nassert(typeof num === 'number');\n```\n\nHowever, we will prevent you from converting an `Integer` to an unsafe number, and vice-versa. To learn more about unsafe numbers, [click here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).\n\n```js\n// This will throw a RangeError\nvar unsafe = Integer(Number.MAX_SAFE_INTEGER + 1);\n\n// This is okay\nvar int = Integer(Number.MAX_SAFE_INTEGER).plus(1);\n\n// But this will throw a RangeError\nvar unsafe = int.toNumber();\n```\n\n# API\n\n### Integer(*value*) -> *Integer*\n\nCasts a value to an `Integer`. If the value cannot be converted safely and losslessly, a `RangeError` is thrown.\n\n```js\nvar a = Integer();\nvar b = Integer(12345);\nvar c = Integer('12345');\nassert(a.equals(0));\nassert(b.equals(c));\n```\n\n### Integer.fromNumber(*number*, [*defaultValue*]) -> *Integer*\n\nCasts a regular number to an `Integer`.\n\nIf the number is unsafe the `defaultValue` is used instead (or a `RangeError` is thrown if no `defaultValue` was provided).\n\n```js\nInteger.fromNumber(12345, 0); // results in Integer(12345)\nInteger.fromNumber(Number.MAX_SAFE_INTEGER + 1, 0); // results in Integer(0)\n```\n\n### Integer.fromString(*string*, [*radix*, [*defaultValue*]]) -> *Integer*\n\nCasts a string to an `Integer`. The string is assumed to be [base-10](https://en.wikipedia.org/wiki/Radix) unless a different `radix` is specified.\n\nIf conversions fails the `defaultValue` is used instead (or a `RangeError` is thrown if no `defaultValue` was provided).\n\n```js\nvar hexColor = 'ff55dd';\nvar int = Integer.fromString(hexColor, 16, 'ffffff');\n```\n\n### Integer.fromBits(*lowBits*, [*highBits*]) -> *Integer*\n\nCreates an `Integer` by concatenating two regular 32-bit signed integers. The `highBits` are optional and default to `0`.\n\n```js\nvar int = Integer.fromBits(0x40, 0x20);\nint.toString(16); // => '2000000040'\n```\n\n## Arithmetic operations\n\n#### &nbsp;&nbsp;&nbsp;&nbsp;.add/plus(*other*) -> *Integer*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.subtract/sub/minus(*other*) -> *Integer*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.multiply/mul/times(*other*) -> *Integer*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.divide/div/divideBy/dividedBy/over(*other*) -> *Integer*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.modulo/mod(*other*) -> *Integer*\n\nPerforms the arithmetic operation and returns a new `Integer`. The argument must either be a number, a base-10 string, or an `Integer`. If the operation results in overflow, a `RangeError` is thrown.\n\n#### &nbsp;&nbsp;&nbsp;&nbsp;.negate/neg() -> *Integer*\n\nReturns the unary negation (`-value`) of the `Integer`.\n\n#### &nbsp;&nbsp;&nbsp;&nbsp;.abs/absoluteValue() -> *Integer*\n\nReturns the absolute value of the `Integer`.\n\n## Bitwise operations\n\n#### &nbsp;&nbsp;&nbsp;&nbsp;.and(*other*) -> *Integer*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.or(*other*) -> *Integer*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.xor(*other*) -> *Integer*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.not() -> *Integer*\n\nPerforms the bitwise operation and returns a new `Integer`. The argument must either be a number, a base-10 string, or an `Integer`.\n\n#### &nbsp;&nbsp;&nbsp;&nbsp;.shiftLeft/shl(*numberOfBits*) -> *Integer*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.shiftRight/shr(*numberOfBits*) -> *Integer*\n\nShifts the `Integer` by specified number of bits and returns the result.\n\n## Logical operations\n\n#### &nbsp;&nbsp;&nbsp;&nbsp;.equals/eq/isEqualTo(*other*) -> *boolean*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.notEquals/neq/isNotEqualTo/doesNotEqual(*other*) -> *boolean*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.greaterThan/gt/isGreaterThan(*other*) -> *boolean*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.lessThan/lt/isLessThan(*other*) -> *boolean*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.greaterThanOrEquals/gte/isGreaterThanOrEqualTo(*other*) -> *boolean*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.lessThanOrEquals/lte/isLessThanOrEqualTo(*other*) -> *boolean*\n\nPerforms the logical operation and returns `true` or `false`. The argument must either be a number, a base-10 string, or an `Integer`.\n\n#### &nbsp;&nbsp;&nbsp;&nbsp;.compare(*other*) -> *number*\n\nCompares the value of the `Integer` and `other`, resulting in:\n- `-1` if `this` is less than `other`\n- `1` if `this` is greater than `other`\n- `0` if `this` is equal to `other`\n\n## Converting to other values\n\n#### &nbsp;&nbsp;&nbsp;&nbsp;.toString([*radix*]) -> *string*\n\nConverts the `Integer` to a string. A base-10 string is returned unless a different `radix` is specified.\n\n#### &nbsp;&nbsp;&nbsp;&nbsp;.valueOf/toNumber() -> *number*\n\nConverts the `Integer` to a regular number. If the `Integer` is not within the safe range, a `RangeError` is thrown.\n\n#### &nbsp;&nbsp;&nbsp;&nbsp;.toNumberUnsafe() -> *number*\n\nConverts the `Integer` to a regular number, **even if the conversion would result in a loss of precision**. This method will never throw an error.\n\n## Other utility\n\n#### &nbsp;&nbsp;&nbsp;&nbsp;.bitSizeAbs() -> *number*\n\nReturns the number of bits necessary to hold the absolute value of the `Integer`.\n\n```js\nInteger(0).bitSizeAbs(); // => 1\nInteger(128).bitSizeAbs(); // => 8\nInteger(-255).bitSizeAbs(); // => 8\nInteger.fromString('4fffffffffff', 16).bitSizeAbs(); // => 47\n```\n\n#### &nbsp;&nbsp;&nbsp;&nbsp;.isEven() -> *boolean*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.isOdd() -> *boolean*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.isPositive() -> *boolean*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.isNegative() -> *boolean*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.isZero() -> *boolean*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.isNonZero/isNotZero() -> *boolean*\n\nThese methods are self-explanatory.\n\n#### &nbsp;&nbsp;&nbsp;&nbsp;.isSafe() -> *boolean*\n#### &nbsp;&nbsp;&nbsp;&nbsp;.isUnsafe() -> *boolean*\n\nReturns whether or not the `Integer` is within the safe range. If it's not within the safe range, trying to convert it to a regular number would result in a `RangeError` being thrown.\n\nThe safe range is defined as `n >= Number.MIN_SAFE_INTEGER && n <= Number.MAX_SAFE_INTEGER`.\n\n#### Integer.isInstance(*value*) -> *boolean*\n\nDetermines if the given value is an `Integer` object.\n\n#### Getters\n\n- **.low -> _number_** - the lower 32-bits of the `Integer`\n- **.high -> _number_** - the upper 32-bits of the `Integer`\n\n#### Constants\n\n- **Integer.MAX_VALUE** - maximum value of an `Integer`\n- **Integer.MIN_VALUE** - minimum value of an `Integer`\n- **Integer.ZERO** - an `Integer` with a value of `0`\n- **Integer.ONE** - an `Integer` with a value of `1`\n- **Integer.NEG_ONE** - an `Integer` with a value of `-1`\n\n## License\n\n[MIT](https://github.com/JoshuaWise/integer/blob/master/LICENSE)\n","publish_time":1537149149472,"_cnpm_publish_time":1537149149472,"dist-tags":{"latest":"4.0.0"}}