91 lines
4.9 KiB
JSON
91 lines
4.9 KiB
JSON
{
|
|
"_args": [
|
|
[
|
|
{
|
|
"raw": "node-int64@^0.4.0",
|
|
"scope": null,
|
|
"escapedName": "node-int64",
|
|
"name": "node-int64",
|
|
"rawSpec": "^0.4.0",
|
|
"spec": ">=0.4.0 <0.5.0",
|
|
"type": "range"
|
|
},
|
|
"/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/bser"
|
|
]
|
|
],
|
|
"_from": "node-int64@>=0.4.0 <0.5.0",
|
|
"_id": "node-int64@0.4.0",
|
|
"_inCache": true,
|
|
"_location": "/node-int64",
|
|
"_npmUser": {
|
|
"name": "broofa",
|
|
"email": "robert@broofa.com"
|
|
},
|
|
"_npmVersion": "1.4.28",
|
|
"_phantomChildren": {},
|
|
"_requested": {
|
|
"raw": "node-int64@^0.4.0",
|
|
"scope": null,
|
|
"escapedName": "node-int64",
|
|
"name": "node-int64",
|
|
"rawSpec": "^0.4.0",
|
|
"spec": ">=0.4.0 <0.5.0",
|
|
"type": "range"
|
|
},
|
|
"_requiredBy": [
|
|
"/bser"
|
|
],
|
|
"_resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
|
|
"_shasum": "87a9065cdb355d3182d8f94ce11188b825c68a3b",
|
|
"_shrinkwrap": null,
|
|
"_spec": "node-int64@^0.4.0",
|
|
"_where": "/Volumes/2009-SSD/GT2/GT2-iOS/node_modules/bser",
|
|
"author": {
|
|
"name": "Robert Kieffer",
|
|
"email": "robert@broofa.com"
|
|
},
|
|
"bugs": {
|
|
"url": "https://github.com/broofa/node-int64/issues"
|
|
},
|
|
"contributors": [],
|
|
"dependencies": {},
|
|
"description": "Support for representing 64-bit integers in JavaScript",
|
|
"devDependencies": {
|
|
"nodeunit": "^0.9.0"
|
|
},
|
|
"directories": {},
|
|
"dist": {
|
|
"shasum": "87a9065cdb355d3182d8f94ce11188b825c68a3b",
|
|
"tarball": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz"
|
|
},
|
|
"gitHead": "c1567475712cb1cfe100c96813c2a2a92e2b42ce",
|
|
"homepage": "https://github.com/broofa/node-int64#readme",
|
|
"keywords": [
|
|
"math",
|
|
"integer",
|
|
"int64"
|
|
],
|
|
"lib": ".",
|
|
"license": "MIT",
|
|
"main": "./Int64.js",
|
|
"maintainers": [
|
|
{
|
|
"name": "broofa",
|
|
"email": "robert@broofa.com"
|
|
}
|
|
],
|
|
"name": "node-int64",
|
|
"optionalDependencies": {},
|
|
"readme": "JavaScript Numbers are represented as [IEEE 754 double-precision floats](http://steve.hollasch.net/cgindex/coding/ieeefloat.html). Unfortunately, this means they lose integer precision for values beyond +/- 2^^53. For projects that need to accurately handle 64-bit ints, such as [node-thrift](https://github.com/wadey/node-thrift), a performant, Number-like class is needed. Int64 is that class.\n\nInt64 instances look and feel much like JS-native Numbers. By way of example ...\n```js\n// First, let's illustrate the problem ...\n> (0x123456789).toString(16)\n'123456789' // <- what we expect.\n> (0x123456789abcdef0).toString(16)\n'123456789abcdf00' // <- Ugh! JS doesn't do big ints. :(\n\n// So let's create a couple Int64s using the above values ...\n\n// Require, of course\n> Int64 = require('node-int64')\n\n// x's value is what we expect (the decimal value of 0x123456789)\n> x = new Int64(0x123456789)\n[Int64 value:4886718345 octets:00 00 00 01 23 45 67 89]\n\n// y's value is Infinity because it's outside the range of integer\n// precision. But that's okay - it's still useful because it's internal\n// representation (octets) is what we passed in\n> y = new Int64('123456789abcdef0')\n[Int64 value:Infinity octets:12 34 56 78 9a bc de f0]\n\n// Let's do some math. Int64's behave like Numbers. (Sorry, Int64 isn't\n// for doing 64-bit integer arithmetic (yet) - it's just for carrying\n// around int64 values\n> x + 1\n4886718346\n> y + 1\nInfinity\n\n// Int64 string operations ...\n> 'value: ' + x\n'value: 4886718345'\n> 'value: ' + y\n'value: Infinity'\n> x.toString(2)\n'100100011010001010110011110001001'\n> y.toString(2)\n'Infinity'\n\n// Use JS's isFinite() method to see if the Int64 value is in the\n// integer-precise range of JS values\n> isFinite(x)\ntrue\n> isFinite(y)\nfalse\n\n// Get an octet string representation. (Yay, y is what we put in!)\n> x.toOctetString()\n'0000000123456789'\n> y.toOctetString()\n'123456789abcdef0'\n\n// Finally, some other ways to create Int64s ...\n\n// Pass hi/lo words\n> new Int64(0x12345678, 0x9abcdef0)\n[Int64 value:Infinity octets:12 34 56 78 9a bc de f0]\n\n// Pass a Buffer\n> new Int64(new Buffer([0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0]))\n[Int64 value:Infinity octets:12 34 56 78 9a bc de f0]\n\n// Pass a Buffer and offset\n> new Int64(new Buffer([0,0,0,0,0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0]), 4)\n[Int64 value:Infinity octets:12 34 56 78 9a bc de f0]\n\n// Pull out into a buffer\n> new Int64(new Buffer([0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0])).toBuffer()\n<Buffer 12 34 56 78 9a bc de f0>\n\n// Or copy into an existing one (at an offset)\n> var buf = new Buffer(1024);\n> new Int64(new Buffer([0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0])).copy(buf, 512);\n```\n",
|
|
"readmeFilename": "README.md",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/broofa/node-int64.git"
|
|
},
|
|
"scripts": {
|
|
"test": "nodeunit test.js"
|
|
},
|
|
"url": "http://github.com/broofa/node-int64",
|
|
"version": "0.4.0"
|
|
}
|