415gotit
This commit is contained in:
6
node_modules/int64-buffer/.npmignore
generated
vendored
Normal file
6
node_modules/int64-buffer/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
*~
|
||||
node_modules
|
||||
gh-pages
|
||||
.idea
|
||||
.DS_Store
|
||||
*.min.js.gz
|
||||
16
node_modules/int64-buffer/.travis.yml
generated
vendored
Normal file
16
node_modules/int64-buffer/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
sudo: false
|
||||
|
||||
language: node_js
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- node_js: "4"
|
||||
- node_js: "6"
|
||||
- node_js: "8"
|
||||
- node_js: "6"
|
||||
env: BROWSER=1
|
||||
|
||||
env:
|
||||
global:
|
||||
- secure: uuvkx4v/Mvz0wvRV99j3HwJLeD8Dl1LC6Ks3YMlwamY08T0mb75cDnIgNp8nNBf6qW2aGkCiio/IDxMOQJDF3UPPUnaUWa6tgFCJr13acnC/alZaQvK8VMSFE8p9UryWgGTHQ3iBCjaXu8VaqZBSK7N05laPohQvD/vLC8043M8Ct0+C7RQNje7IHbAizH9mCJ2WlLlvu7EaOfkl8rtQDnCQoFv5vZalzoPiV/WaYHeUf2+mbnQIKbN5bd8PZzw6RvG/QVs5D9w7C5+46JTvuHS4tMUWvn8WyxHOsYzlWCEKOzM0SsDpfDV/+f6VzNyIWjcRn7GqXzQyvdE638XLrk+pPPvM/HZCwT9FaPgG9fi0uSp+AGanHseUUASx7z/wukxhZGgdbMdU6ptLZPUBAstmc5SxnheA5l47c8joZ5fyuYquVqT62RNNKG8s7Pf6htsmhMu47dzsgoByFsIiuuGqiWZkXVHhw8pOBk2Xm8ytIjklQtEwK/Q5+TSSCQCJKfRMB2uTyJCEZwFC7uwnvMHuD8wcIPpWqT47CTOPeOLQF3pETfRK0oF7Fc2/GxrY62AIGx6AfKkXzYZDk36Rg1JqX2fRKWJOi8OnzfPVXqOI7Tjz5J9583/O5ycrQfqX5oA9o9Izm0QG9t3yfqbJ2MX4YKbCE1rLpRnovP/z3YI=
|
||||
- secure: YEp79etw/SsvEKt/u9isQk2xIi0mHVSQrJybUZh7k3oDLwHr5/fv8q889+Q5rSXgv6UIrCK/18AVPyEaxmev+zPCaipAIRIvrp+ok3Dc5XOD9T8DptkQIMdd+C+NjU1sHd1cq31sdh8RLVhGbnA+HeQcyV9DVha0YyBM9F0Hhc+GiiaXrLa4Jk1U7Cs/hY/p+Vc2n7lbIQiYN6f8R8vS3KUWUJ5PTYfENMo7TMWJoXQPZit6cG8jKRDF7rWSSmlphszxzwANOy5A1ZyFJO2pzR1SLQ6cq3fm6wPC8Mjmlv5bn7gSZ4LxXn69PRXt3JN3zaSLw8thcVbBOBPY48UQLuctGdJNjIr+z2iKDAHFmoXavgpOtT89cApJdaYi+dhhdMpoNYDUTRJGUnrsdxr3d/tTfLWjqMOlnLJPETjwKRByYx1bGeQjM6NQ5dlHMZCpmvnHvVGx+qoBBPF+rulgM4mgfJ6TKdEAnz8upkmWqSm7O2EEgMwSfL2r8UQ0yTKP0QX80O599GkWi8F1/KoioMk82d4+NAbIieqtjju2KgNnBOYcyJ2EZXWRrsjgiDVFDhsJXAr/QTuUnpSaddxYuCMRx2DRRQil3amIv0uEnGtbVlAGplqdGvxinNJqdmDlTOESqFWvoNnNTCOp0UkN4F8UAs51sn1q2DLJyM5eNdw=
|
||||
18
node_modules/int64-buffer/.zuul.yml
generated
vendored
Normal file
18
node_modules/int64-buffer/.zuul.yml
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
sauce_username: int64-buffer
|
||||
sauce_key: "0588456e-cfb6-4001-8bdf-9a3f043b4528"
|
||||
name: int64-buffer
|
||||
ui: mocha-bdd
|
||||
html: "test/zuul/ie.html"
|
||||
browsers:
|
||||
- name: ie
|
||||
version: "9..latest"
|
||||
- name: chrome
|
||||
version: "latest"
|
||||
- name: firefox
|
||||
version: "latest"
|
||||
- name: safari
|
||||
version: "latest"
|
||||
- name: iphone
|
||||
version: ["8.4", "9.3", "10.3..latest"]
|
||||
- name: android
|
||||
version: ["4.4", "5.1", "6.0..latest"]
|
||||
22
node_modules/int64-buffer/LICENSE
generated
vendored
Normal file
22
node_modules/int64-buffer/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2016 Yusuke Kawasaki
|
||||
|
||||
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.
|
||||
|
||||
43
node_modules/int64-buffer/Makefile
generated
vendored
Executable file
43
node_modules/int64-buffer/Makefile
generated
vendored
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash -c make
|
||||
|
||||
SRC=./int64-buffer.js
|
||||
TESTS=*.json ./test/*.js
|
||||
HINTS=$(SRC) $(TESTS)
|
||||
DIST=./dist
|
||||
JSDEST=./dist/int64-buffer.min.js
|
||||
JSGZIP=./dist/int64-buffer.min.js.gz
|
||||
|
||||
all: test $(JSGZIP)
|
||||
|
||||
clean:
|
||||
rm -fr $(JSDEST)
|
||||
|
||||
$(DIST):
|
||||
mkdir -p $(DIST)
|
||||
|
||||
$(JSDEST): $(SRC) $(DIST)
|
||||
./node_modules/.bin/uglifyjs $(SRC) -c -m -o $(JSDEST)
|
||||
|
||||
$(JSGZIP): $(JSDEST)
|
||||
gzip -9 < $(JSDEST) > $(JSGZIP)
|
||||
ls -l $(JSDEST) $(JSGZIP)
|
||||
|
||||
test:
|
||||
@if [ "x$(BROWSER)" = "x" ]; then make test-node; else make test-browser; fi
|
||||
|
||||
test-node: jshint mocha
|
||||
|
||||
test-browser:
|
||||
./node_modules/.bin/zuul -- $(TESTS)
|
||||
|
||||
test-browser-local:
|
||||
node -e 'process.exit(process.platform === "darwin" ? 0 : 1)' && sleep 1 && open http://localhost:4000/__zuul &
|
||||
./node_modules/.bin/zuul --local 4000 -- $(TESTS)
|
||||
|
||||
mocha:
|
||||
./node_modules/.bin/mocha -R spec $(TESTS)
|
||||
|
||||
jshint:
|
||||
./node_modules/.bin/jshint $(HINTS)
|
||||
|
||||
.PHONY: all clean test jshint mocha
|
||||
250
node_modules/int64-buffer/README.md
generated
vendored
Normal file
250
node_modules/int64-buffer/README.md
generated
vendored
Normal file
@@ -0,0 +1,250 @@
|
||||
# int64-buffer
|
||||
|
||||
64bit Long Integer on Buffer/Array/ArrayBuffer in Pure JavaScript
|
||||
|
||||
[](http://badge.fury.io/js/int64-buffer) [](https://travis-ci.org/kawanet/int64-buffer)
|
||||
|
||||
[](https://saucelabs.com/u/int64-buffer)
|
||||
|
||||
JavaScript's number based on IEEE-754 could only handle [53 bits](https://en.wikipedia.org/wiki/Double-precision_floating-point_format) precision.
|
||||
This module provides two pair of classes: `Int64BE`/`Uint64BE` and `Int64LE`/`Uint64LE` which could hold 64 bits long integer and loose no bit.
|
||||
|
||||
### Features
|
||||
|
||||
- `Int64BE`/`Int64LE` for signed integer, `Uint64BE`/`Uint64LE` for unsigned.
|
||||
- `Int64BE`/`Uint64BE` for big-endian, `Uint64BE`/`Uint64LE` for little-endian.
|
||||
- `Buffer`/`Uint8Array`/`Array`/`Array`-like storage of 8 bytes length with offset.
|
||||
- No mathematical methods provided, such as `add()`, `sub()`, `mul()`, `div()` etc.
|
||||
- Optimized only for 64 bits. If you need Int128, use [bignum](https://www.npmjs.com/package/bignum) etc.
|
||||
- Small. 3KB when minified. No other module required. Portable pure JavaScript.
|
||||
- [Tested](https://travis-ci.org/kawanet/int64-buffer) on node.js v4, v6, v8 and [Web browsers](https://saucelabs.com/u/int64-buffer).
|
||||
|
||||
### Usage
|
||||
|
||||
`Int64BE` is the class to host a 64 bit signed long integer `int64_t`.
|
||||
|
||||
```js
|
||||
var Int64BE = require("int64-buffer").Int64BE;
|
||||
|
||||
var big = new Int64BE(-1);
|
||||
|
||||
console.log(big - 0); // -1
|
||||
|
||||
console.log(big.toBuffer()); // <Buffer ff ff ff ff ff ff ff ff>
|
||||
```
|
||||
|
||||
It uses `Buffer` on Node.js and `Uint8Array` on modern Web browsers.
|
||||
|
||||
`Uint64BE` is the class to host a 64 bit unsigned positive long integer `uint64_t`.
|
||||
|
||||
```js
|
||||
var Uint64BE = require("int64-buffer").Uint64BE;
|
||||
|
||||
var big = new Uint64BE(Math.pow(2, 63)); // a big number with 64 bits
|
||||
|
||||
console.log(big - 0); // 9223372036854776000 = IEEE-754 loses last bits
|
||||
|
||||
console.log(big + ""); // "9223372036854775808" = perfectly correct
|
||||
```
|
||||
|
||||
`Int64LE` and `Uint64LE` work as same as above but with little-endian storage.
|
||||
|
||||
### Input Constructor
|
||||
|
||||
- new Uint64BE(number)
|
||||
|
||||
```js
|
||||
var big = new Uint64BE(1234567890);
|
||||
console.log(big - 0); // 1234567890
|
||||
```
|
||||
|
||||
- new Uint64BE(high, low)
|
||||
|
||||
```js
|
||||
var big = new Uint64BE(0x12345678, 0x9abcdef0);
|
||||
console.log(big.toString(16)); // "123456789abcdef0"
|
||||
```
|
||||
|
||||
- new Uint64BE(string, radix)
|
||||
|
||||
```js
|
||||
var big = new Uint64BE("123456789abcdef0", 16);
|
||||
console.log(big.toString(16)); // "123456789abcdef0"
|
||||
```
|
||||
|
||||
- new Uint64BE(buffer)
|
||||
|
||||
```js
|
||||
var buffer = new Buffer([1,2,3,4,5,6,7,8]);
|
||||
var big = new Uint64BE(buffer);
|
||||
console.log(big.toString(16)); // "102030405060708"
|
||||
```
|
||||
|
||||
- new Uint64BE(uint8array)
|
||||
|
||||
```js
|
||||
var uint8array = new Uint8Array([1,2,3,4,5,6,7,8]);
|
||||
var big = new Uint64BE(uint8array);
|
||||
console.log(big.toString(16)); // "102030405060708"
|
||||
```
|
||||
|
||||
- new Uint64BE(arraybuffer)
|
||||
|
||||
```js
|
||||
var arraybuffer = (new Uint8Array([1,2,3,4,5,6,7,8])).buffer;
|
||||
var big = new Uint64BE(arraybuffer);
|
||||
console.log(big.toString(16)); // "102030405060708"
|
||||
```
|
||||
|
||||
- new Uint64BE(array)
|
||||
|
||||
```js
|
||||
var array = [1,2,3,4,5,6,7,8];
|
||||
var big = new Uint64BE(array);
|
||||
console.log(big.toString(16)); // "102030405060708"
|
||||
```
|
||||
|
||||
- new Uint64BE(buffer, offset)
|
||||
|
||||
```js
|
||||
var buffer = new Buffer([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]);
|
||||
var big = new Uint64BE(buffer, 8);
|
||||
console.log(big.toString(16)); // "90a0b0c0d0e0f10"
|
||||
```
|
||||
|
||||
- new Uint64BE(buffer, offset, number)
|
||||
|
||||
```js
|
||||
var buffer = new Buffer(16);
|
||||
var big = new Uint64BE(buffer, 8, 0x1234567890);
|
||||
console.log(big.toString(16)); // "1234567890"
|
||||
console.log(buffer[15].toString(16)); // "90"
|
||||
```
|
||||
|
||||
- new Uint64BE(buffer, offset, high, low)
|
||||
|
||||
```js
|
||||
var buffer = new Uint8Array(16);
|
||||
var big = new Uint64BE(buffer, 8, 0x12345678, 0x9abcdef0);
|
||||
console.log(big.toString(16)); // "123456789abcdef0"
|
||||
console.log(buffer[15].toString(16)); // "f0"
|
||||
```
|
||||
|
||||
- new Uint64BE(buffer, offset, string, radix)
|
||||
|
||||
```js
|
||||
var buffer = new Array(16);
|
||||
var big = new Uint64BE(buffer, 8, "123456789abcdef0", 16);
|
||||
console.log(big.toString(16)); // "123456789abcdef0"
|
||||
console.log(buffer[15].toString(16)); // "f0"
|
||||
```
|
||||
|
||||
### Output Methods
|
||||
|
||||
- Number context
|
||||
|
||||
```js
|
||||
var big = Uint64BE(1234567890);
|
||||
console.log(big - 0); // 1234567890
|
||||
```
|
||||
|
||||
- String context
|
||||
|
||||
```js
|
||||
var big = Uint64BE(1234567890);
|
||||
console.log(big + ""); // "1234567890"
|
||||
```
|
||||
|
||||
- JSON context
|
||||
|
||||
```js
|
||||
var big = Uint64BE();
|
||||
console.log(JSON.stringify({big: big})); // {"big":1234567890}
|
||||
```
|
||||
|
||||
- toNumber()
|
||||
|
||||
```js
|
||||
var big = Uint64BE(1234567890);
|
||||
console.log(big.toNumber()); // 1234567890
|
||||
```
|
||||
|
||||
- toString(radix)
|
||||
|
||||
```js
|
||||
var big = Uint64BE(0x1234567890);
|
||||
console.log(big.toString()); // "78187493520"
|
||||
console.log(big.toString(16)); // "1234567890"
|
||||
```
|
||||
|
||||
- toBuffer()
|
||||
|
||||
```js
|
||||
var big = Uint64BE([1,2,3,4,5,6,7,8]);
|
||||
console.log(big.toBuffer()); // <Buffer 01 02 03 04 05 06 07 08>
|
||||
```
|
||||
|
||||
- toArrayBuffer()
|
||||
|
||||
```js
|
||||
var big = Uint64BE(0);
|
||||
var buf = new Int8Array(big.toArrayBuffer());
|
||||
console.log(buf); // Int8Array { '0': 1, '1': 2, '2': 3, '3': 4, '4': 5, '5': 6, '6': 7, '7': 8 }
|
||||
```
|
||||
|
||||
- toArray()
|
||||
|
||||
```js
|
||||
var big = Uint64BE([1,2,3,4,5,6,7,8]);
|
||||
console.log(big.toArray()); // [ 1, 2, 3, 4, 5, 6, 7, 8 ]
|
||||
```
|
||||
|
||||
### Browsers Build
|
||||
|
||||
[int64-buffer.min.js](https://rawgit.com/kawanet/int64-buffer/master/dist/int64-buffer.min.js) is [tested](https://saucelabs.com/u/int64-buffer) on major Web browsers.
|
||||
|
||||
```html
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<script src="https://rawgit.com/kawanet/int64-buffer/master/dist/int64-buffer.min.js"></script>
|
||||
<script>
|
||||
|
||||
var i = Int64BE("1234567890123456789");
|
||||
console.log(i.toString(10)); // "1234567890123456789"
|
||||
|
||||
var u = new Uint64BE([0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF]);
|
||||
console.log(u.toString(16)); // "123456789abcdef"
|
||||
|
||||
</script>
|
||||
```
|
||||
|
||||
### Installation
|
||||
|
||||
```sh
|
||||
npm install int64-buffer --save
|
||||
```
|
||||
|
||||
### GitHub
|
||||
|
||||
- [https://github.com/kawanet/int64-buffer](https://github.com/kawanet/int64-buffer)
|
||||
|
||||
### The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2017 Yusuke Kawasaki
|
||||
|
||||
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.
|
||||
31
node_modules/int64-buffer/bower.json
generated
vendored
Normal file
31
node_modules/int64-buffer/bower.json
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "int64-buffer",
|
||||
"description": "64bit Long Integer on Buffer/Array/ArrayBuffer in Pure JavaScript",
|
||||
"authors": [
|
||||
"@kawanet"
|
||||
],
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"64bit",
|
||||
"IEEE-754",
|
||||
"buffer",
|
||||
"arraybuffer",
|
||||
"int8array",
|
||||
"int",
|
||||
"int64",
|
||||
"integer",
|
||||
"long",
|
||||
"longlong",
|
||||
"signed",
|
||||
"uint64",
|
||||
"unsinged"
|
||||
],
|
||||
"homepage": "https://github.com/kawanet/int64-buffer",
|
||||
"ignore": [
|
||||
".*",
|
||||
"Makefile",
|
||||
"bower_components",
|
||||
"node_modules",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
1
node_modules/int64-buffer/dist/int64-buffer.min.js
generated
vendored
Normal file
1
node_modules/int64-buffer/dist/int64-buffer.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var Uint64BE,Int64BE,Uint64LE,Int64LE;!function(r){function t(t,p,B){function E(r,t,n,f){return this instanceof E?function(r,t,n,f,e){y&&v&&(t instanceof v&&(t=new y(t)),f instanceof v&&(f=new y(f)));if(!(t||n||f||a))return void(r.buffer=u(h,0));if(!o(t,n)){var c=a||Array;e=n,f=t,n=0,t=new c(8)}if(r.buffer=t,r.offset=n|=0,s===typeof f)return;"string"==typeof f?function(r,t,n,f){var e=0,o=n.length,i=0,u=0;"-"===n[0]&&e++;var a=e;for(;e<o;){var s=parseInt(n[e++],f);if(!(s>=0))break;u=u*f+s,i=i*f+Math.floor(u/b),u%=b}a&&(i=~i,u?u=b-u:i++);A(r,t+I,i),A(r,t+L,u)}(t,n,f,e||10):o(f,e)?i(t,n,f,e):"number"==typeof e?(A(t,n+I,f),A(t,n+L,e)):f>0?m(t,n,f):f<0?x(t,n,f):i(t,n,h,0)}(this,r,t,n,f):new E(r,t,n,f)}function g(){var r=this.buffer,t=this.offset,n=U(r,t+I),f=U(r,t+L);return B||(n|=0),n?n*b+f:f}function A(r,t,n){r[t+j]=255&n,n>>=8,r[t+S]=255&n,n>>=8,r[t+d]=255&n,n>>=8,r[t+w]=255&n}function U(r,t){return r[t+w]*l+(r[t+d]<<16)+(r[t+S]<<8)+r[t+j]}var I=p?0:4,L=p?4:0,w=p?0:3,d=p?1:2,S=p?2:1,j=p?3:0,m=p?function(r,t,n){var f=t+8;for(;f>t;)r[--f]=255&n,n/=256}:function(r,t,n){var f=t+8;for(;t<f;)r[t++]=255&n,n/=256},x=p?function(r,t,n){var f=t+8;n++;for(;f>t;)r[--f]=255&-n^255,n/=256}:function(r,t,n){var f=t+8;n++;for(;t<f;)r[t++]=255&-n^255,n/=256},M=E.prototype,N="is"+t,k="_"+N;return M.buffer=void 0,M.offset=0,M[k]=!0,M.toNumber=g,M.toString=function(r){var t=this.buffer,n=this.offset,f=U(t,n+I),e=U(t,n+L),o="",i=!B&&2147483648&f;for(i&&(f=~f,e=b-e),r=r||10;;){var u=f%r*b+e;if(f=Math.floor(f/r),e=Math.floor(u/r),o=(u%r).toString(r)+o,!f&&!e)break}return i&&(o="-"+o),o},M.toJSON=g,M.toArray=n,c&&(M.toBuffer=f),y&&(M.toArrayBuffer=e),E[N]=function(r){return!(!r||!r[k])},r[t]=E,E}function n(r){var t=this.buffer,n=this.offset;return a=null,!1!==r&&0===n&&8===t.length&&p(t)?t:u(t,n)}function f(r){var t=this.buffer,n=this.offset;if(a=c,!1!==r&&0===n&&8===t.length&&Buffer.isBuffer(t))return t;var f=new c(8);return i(f,0,t,n),f}function e(r){var t=this.buffer,n=this.offset,f=t.buffer;if(a=y,!1!==r&&0===n&&f instanceof v&&8===f.byteLength)return f;var e=new y(8);return i(e,0,t,n),e.buffer}function o(r,t){var n=r&&r.length;return t|=0,n&&t+8<=n&&"string"!=typeof r[t]}function i(r,t,n,f){t|=0,f|=0;for(var e=0;e<8;e++)r[t++]=255&n[f++]}function u(r,t){return Array.prototype.slice.call(r,t,t+8)}var a,s="undefined",c=s!==typeof Buffer&&Buffer,y=s!==typeof Uint8Array&&Uint8Array,v=s!==typeof ArrayBuffer&&ArrayBuffer,h=[0,0,0,0,0,0,0,0],p=Array.isArray||function(r){return!!r&&"[object Array]"==Object.prototype.toString.call(r)},b=4294967296,l=16777216;Uint64BE=t("Uint64BE",!0,!0),Int64BE=t("Int64BE",!0,!1),Uint64LE=t("Uint64LE",!1,!0),Int64LE=t("Int64LE",!1,!1)}("object"==typeof exports&&"string"!=typeof exports.nodeName?exports:this||{});
|
||||
50
node_modules/int64-buffer/int64-buffer.d.ts
generated
vendored
Normal file
50
node_modules/int64-buffer/int64-buffer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
// TypeScript type definitions
|
||||
|
||||
type ArrayType = Uint8Array | ArrayBuffer | number[];
|
||||
|
||||
declare abstract class Int64
|
||||
{
|
||||
constructor(value?: number);
|
||||
constructor(high: number, low: number);
|
||||
constructor(value: string, radix?: number);
|
||||
constructor(buf: Buffer);
|
||||
constructor(buf: Buffer, offset: number, value?: number);
|
||||
constructor(buf: Buffer, offset: number, high: number, low: number);
|
||||
constructor(buf: Buffer, offset: number, value: string, radix?: number);
|
||||
constructor(array: ArrayType);
|
||||
constructor(array: ArrayType, offset: number, value?: number);
|
||||
constructor(array: ArrayType, offset: number, high: number, low: number);
|
||||
constructor(array: ArrayType, offset: number, value: string, radix?: number);
|
||||
|
||||
toNumber(): number;
|
||||
|
||||
toJSON(): number;
|
||||
|
||||
toString(radix?: number): string;
|
||||
|
||||
toBuffer(raw?: boolean): Buffer;
|
||||
|
||||
toArrayBuffer(raw?: boolean): ArrayBuffer;
|
||||
|
||||
toArray(raw?: boolean): number[];
|
||||
}
|
||||
|
||||
export declare class Int64BE extends Int64
|
||||
{
|
||||
static isInt64BE(obj: any): obj is Int64BE;
|
||||
}
|
||||
|
||||
export declare class Uint64BE extends Int64
|
||||
{
|
||||
static isUint64BE(obj: any): obj is Uint64BE;
|
||||
}
|
||||
|
||||
export declare class Int64LE extends Int64
|
||||
{
|
||||
static isInt64LE(obj: any): obj is Int64LE;
|
||||
}
|
||||
|
||||
export declare class Uint64LE extends Int64
|
||||
{
|
||||
static isUint64LE(obj: any): obj is Uint64LE;
|
||||
}
|
||||
293
node_modules/int64-buffer/int64-buffer.js
generated
vendored
Normal file
293
node_modules/int64-buffer/int64-buffer.js
generated
vendored
Normal file
@@ -0,0 +1,293 @@
|
||||
// int64-buffer.js
|
||||
|
||||
/*jshint -W018 */ // Confusing use of '!'.
|
||||
/*jshint -W030 */ // Expected an assignment or function call and instead saw an expression.
|
||||
/*jshint -W093 */ // Did you mean to return a conditional instead of an assignment?
|
||||
|
||||
var Uint64BE, Int64BE, Uint64LE, Int64LE;
|
||||
|
||||
!function(exports) {
|
||||
// constants
|
||||
|
||||
var UNDEFINED = "undefined";
|
||||
var BUFFER = (UNDEFINED !== typeof Buffer) && Buffer;
|
||||
var UINT8ARRAY = (UNDEFINED !== typeof Uint8Array) && Uint8Array;
|
||||
var ARRAYBUFFER = (UNDEFINED !== typeof ArrayBuffer) && ArrayBuffer;
|
||||
var ZERO = [0, 0, 0, 0, 0, 0, 0, 0];
|
||||
var isArray = Array.isArray || _isArray;
|
||||
var BIT32 = 4294967296;
|
||||
var BIT24 = 16777216;
|
||||
|
||||
// storage class
|
||||
|
||||
var storage; // Array;
|
||||
|
||||
// generate classes
|
||||
|
||||
Uint64BE = factory("Uint64BE", true, true);
|
||||
Int64BE = factory("Int64BE", true, false);
|
||||
Uint64LE = factory("Uint64LE", false, true);
|
||||
Int64LE = factory("Int64LE", false, false);
|
||||
|
||||
// class factory
|
||||
|
||||
function factory(name, bigendian, unsigned) {
|
||||
var posH = bigendian ? 0 : 4;
|
||||
var posL = bigendian ? 4 : 0;
|
||||
var pos0 = bigendian ? 0 : 3;
|
||||
var pos1 = bigendian ? 1 : 2;
|
||||
var pos2 = bigendian ? 2 : 1;
|
||||
var pos3 = bigendian ? 3 : 0;
|
||||
var fromPositive = bigendian ? fromPositiveBE : fromPositiveLE;
|
||||
var fromNegative = bigendian ? fromNegativeBE : fromNegativeLE;
|
||||
var proto = Int64.prototype;
|
||||
var isName = "is" + name;
|
||||
var _isInt64 = "_" + isName;
|
||||
|
||||
// properties
|
||||
proto.buffer = void 0;
|
||||
proto.offset = 0;
|
||||
proto[_isInt64] = true;
|
||||
|
||||
// methods
|
||||
proto.toNumber = toNumber;
|
||||
proto.toString = toString;
|
||||
proto.toJSON = toNumber;
|
||||
proto.toArray = toArray;
|
||||
|
||||
// add .toBuffer() method only when Buffer available
|
||||
if (BUFFER) proto.toBuffer = toBuffer;
|
||||
|
||||
// add .toArrayBuffer() method only when Uint8Array available
|
||||
if (UINT8ARRAY) proto.toArrayBuffer = toArrayBuffer;
|
||||
|
||||
// isUint64BE, isInt64BE
|
||||
Int64[isName] = isInt64;
|
||||
|
||||
// CommonJS
|
||||
exports[name] = Int64;
|
||||
|
||||
return Int64;
|
||||
|
||||
// constructor
|
||||
function Int64(buffer, offset, value, raddix) {
|
||||
if (!(this instanceof Int64)) return new Int64(buffer, offset, value, raddix);
|
||||
return init(this, buffer, offset, value, raddix);
|
||||
}
|
||||
|
||||
// isUint64BE, isInt64BE
|
||||
function isInt64(b) {
|
||||
return !!(b && b[_isInt64]);
|
||||
}
|
||||
|
||||
// initializer
|
||||
function init(that, buffer, offset, value, raddix) {
|
||||
if (UINT8ARRAY && ARRAYBUFFER) {
|
||||
if (buffer instanceof ARRAYBUFFER) buffer = new UINT8ARRAY(buffer);
|
||||
if (value instanceof ARRAYBUFFER) value = new UINT8ARRAY(value);
|
||||
}
|
||||
|
||||
// Int64BE() style
|
||||
if (!buffer && !offset && !value && !storage) {
|
||||
// shortcut to initialize with zero
|
||||
that.buffer = newArray(ZERO, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Int64BE(value, raddix) style
|
||||
if (!isValidBuffer(buffer, offset)) {
|
||||
var _storage = storage || Array;
|
||||
raddix = offset;
|
||||
value = buffer;
|
||||
offset = 0;
|
||||
buffer = new _storage(8);
|
||||
}
|
||||
|
||||
that.buffer = buffer;
|
||||
that.offset = offset |= 0;
|
||||
|
||||
// Int64BE(buffer, offset) style
|
||||
if (UNDEFINED === typeof value) return;
|
||||
|
||||
// Int64BE(buffer, offset, value, raddix) style
|
||||
if ("string" === typeof value) {
|
||||
fromString(buffer, offset, value, raddix || 10);
|
||||
} else if (isValidBuffer(value, raddix)) {
|
||||
fromArray(buffer, offset, value, raddix);
|
||||
} else if ("number" === typeof raddix) {
|
||||
writeInt32(buffer, offset + posH, value); // high
|
||||
writeInt32(buffer, offset + posL, raddix); // low
|
||||
} else if (value > 0) {
|
||||
fromPositive(buffer, offset, value); // positive
|
||||
} else if (value < 0) {
|
||||
fromNegative(buffer, offset, value); // negative
|
||||
} else {
|
||||
fromArray(buffer, offset, ZERO, 0); // zero, NaN and others
|
||||
}
|
||||
}
|
||||
|
||||
function fromString(buffer, offset, str, raddix) {
|
||||
var pos = 0;
|
||||
var len = str.length;
|
||||
var high = 0;
|
||||
var low = 0;
|
||||
if (str[0] === "-") pos++;
|
||||
var sign = pos;
|
||||
while (pos < len) {
|
||||
var chr = parseInt(str[pos++], raddix);
|
||||
if (!(chr >= 0)) break; // NaN
|
||||
low = low * raddix + chr;
|
||||
high = high * raddix + Math.floor(low / BIT32);
|
||||
low %= BIT32;
|
||||
}
|
||||
if (sign) {
|
||||
high = ~high;
|
||||
if (low) {
|
||||
low = BIT32 - low;
|
||||
} else {
|
||||
high++;
|
||||
}
|
||||
}
|
||||
writeInt32(buffer, offset + posH, high);
|
||||
writeInt32(buffer, offset + posL, low);
|
||||
}
|
||||
|
||||
function toNumber() {
|
||||
var buffer = this.buffer;
|
||||
var offset = this.offset;
|
||||
var high = readInt32(buffer, offset + posH);
|
||||
var low = readInt32(buffer, offset + posL);
|
||||
if (!unsigned) high |= 0; // a trick to get signed
|
||||
return high ? (high * BIT32 + low) : low;
|
||||
}
|
||||
|
||||
function toString(radix) {
|
||||
var buffer = this.buffer;
|
||||
var offset = this.offset;
|
||||
var high = readInt32(buffer, offset + posH);
|
||||
var low = readInt32(buffer, offset + posL);
|
||||
var str = "";
|
||||
var sign = !unsigned && (high & 0x80000000);
|
||||
if (sign) {
|
||||
high = ~high;
|
||||
low = BIT32 - low;
|
||||
}
|
||||
radix = radix || 10;
|
||||
while (1) {
|
||||
var mod = (high % radix) * BIT32 + low;
|
||||
high = Math.floor(high / radix);
|
||||
low = Math.floor(mod / radix);
|
||||
str = (mod % radix).toString(radix) + str;
|
||||
if (!high && !low) break;
|
||||
}
|
||||
if (sign) {
|
||||
str = "-" + str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function writeInt32(buffer, offset, value) {
|
||||
buffer[offset + pos3] = value & 255;
|
||||
value = value >> 8;
|
||||
buffer[offset + pos2] = value & 255;
|
||||
value = value >> 8;
|
||||
buffer[offset + pos1] = value & 255;
|
||||
value = value >> 8;
|
||||
buffer[offset + pos0] = value & 255;
|
||||
}
|
||||
|
||||
function readInt32(buffer, offset) {
|
||||
return (buffer[offset + pos0] * BIT24) +
|
||||
(buffer[offset + pos1] << 16) +
|
||||
(buffer[offset + pos2] << 8) +
|
||||
buffer[offset + pos3];
|
||||
}
|
||||
}
|
||||
|
||||
function toArray(raw) {
|
||||
var buffer = this.buffer;
|
||||
var offset = this.offset;
|
||||
storage = null; // Array
|
||||
if (raw !== false && offset === 0 && buffer.length === 8 && isArray(buffer)) return buffer;
|
||||
return newArray(buffer, offset);
|
||||
}
|
||||
|
||||
function toBuffer(raw) {
|
||||
var buffer = this.buffer;
|
||||
var offset = this.offset;
|
||||
storage = BUFFER;
|
||||
if (raw !== false && offset === 0 && buffer.length === 8 && Buffer.isBuffer(buffer)) return buffer;
|
||||
var dest = new BUFFER(8);
|
||||
fromArray(dest, 0, buffer, offset);
|
||||
return dest;
|
||||
}
|
||||
|
||||
function toArrayBuffer(raw) {
|
||||
var buffer = this.buffer;
|
||||
var offset = this.offset;
|
||||
var arrbuf = buffer.buffer;
|
||||
storage = UINT8ARRAY;
|
||||
if (raw !== false && offset === 0 && (arrbuf instanceof ARRAYBUFFER) && arrbuf.byteLength === 8) return arrbuf;
|
||||
var dest = new UINT8ARRAY(8);
|
||||
fromArray(dest, 0, buffer, offset);
|
||||
return dest.buffer;
|
||||
}
|
||||
|
||||
function isValidBuffer(buffer, offset) {
|
||||
var len = buffer && buffer.length;
|
||||
offset |= 0;
|
||||
return len && (offset + 8 <= len) && ("string" !== typeof buffer[offset]);
|
||||
}
|
||||
|
||||
function fromArray(destbuf, destoff, srcbuf, srcoff) {
|
||||
destoff |= 0;
|
||||
srcoff |= 0;
|
||||
for (var i = 0; i < 8; i++) {
|
||||
destbuf[destoff++] = srcbuf[srcoff++] & 255;
|
||||
}
|
||||
}
|
||||
|
||||
function newArray(buffer, offset) {
|
||||
return Array.prototype.slice.call(buffer, offset, offset + 8);
|
||||
}
|
||||
|
||||
function fromPositiveBE(buffer, offset, value) {
|
||||
var pos = offset + 8;
|
||||
while (pos > offset) {
|
||||
buffer[--pos] = value & 255;
|
||||
value /= 256;
|
||||
}
|
||||
}
|
||||
|
||||
function fromNegativeBE(buffer, offset, value) {
|
||||
var pos = offset + 8;
|
||||
value++;
|
||||
while (pos > offset) {
|
||||
buffer[--pos] = ((-value) & 255) ^ 255;
|
||||
value /= 256;
|
||||
}
|
||||
}
|
||||
|
||||
function fromPositiveLE(buffer, offset, value) {
|
||||
var end = offset + 8;
|
||||
while (offset < end) {
|
||||
buffer[offset++] = value & 255;
|
||||
value /= 256;
|
||||
}
|
||||
}
|
||||
|
||||
function fromNegativeLE(buffer, offset, value) {
|
||||
var end = offset + 8;
|
||||
value++;
|
||||
while (offset < end) {
|
||||
buffer[offset++] = ((-value) & 255) ^ 255;
|
||||
value /= 256;
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/retrofox/is-array
|
||||
function _isArray(val) {
|
||||
return !!val && "[object Array]" == Object.prototype.toString.call(val);
|
||||
}
|
||||
|
||||
}(typeof exports === 'object' && typeof exports.nodeName !== 'string' ? exports : (this || {}));
|
||||
57
node_modules/int64-buffer/package.json
generated
vendored
Normal file
57
node_modules/int64-buffer/package.json
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "int64-buffer",
|
||||
"description": "64bit Long Integer on Buffer/Array/ArrayBuffer in Pure JavaScript",
|
||||
"version": "0.1.10",
|
||||
"author": "@kawanet",
|
||||
"bugs": {
|
||||
"url": "https://github.com/kawanet/int64-buffer/issues"
|
||||
},
|
||||
"contributors": [
|
||||
"kawanet <u-suke@kawa.net>",
|
||||
"pizza2code <christopher.guinnup@jhuapl.edu>",
|
||||
"Jan Krems <jan.krems@groupon.com>"
|
||||
],
|
||||
"devDependencies": {
|
||||
"jshint": "^2.9.5",
|
||||
"mocha": "^4.0.1",
|
||||
"uglify-js": "^3.1.10",
|
||||
"zuul": "^3.11.1"
|
||||
},
|
||||
"homepage": "https://github.com/kawanet/int64-buffer",
|
||||
"jshintConfig": {
|
||||
"globals": {
|
||||
"describe": true,
|
||||
"it": true,
|
||||
"window": true
|
||||
},
|
||||
"node": true,
|
||||
"undef": true,
|
||||
"unused": true
|
||||
},
|
||||
"keywords": [
|
||||
"64bit",
|
||||
"IEEE-754",
|
||||
"arraybuffer",
|
||||
"buffer",
|
||||
"int",
|
||||
"int64",
|
||||
"int8array",
|
||||
"integer",
|
||||
"long",
|
||||
"longlong",
|
||||
"signed",
|
||||
"uint64",
|
||||
"unsinged"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "int64-buffer.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/kawanet/int64-buffer.git"
|
||||
},
|
||||
"scripts": {
|
||||
"fixpack": "fixpack",
|
||||
"test": "make test"
|
||||
},
|
||||
"typings": "int64-buffer.d.ts"
|
||||
}
|
||||
23
node_modules/int64-buffer/test/test.html
generated
vendored
Normal file
23
node_modules/int64-buffer/test/test.html
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>test</title>
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.2.5/mocha.css" rel="stylesheet"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<!--[if lte IE 9]>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.1.10/es5-shim.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"></script>
|
||||
<![endif]-->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.2.5/mocha.min.js"></script>
|
||||
<script>mocha.setup("bdd")</script>
|
||||
<script src="../int64-buffer.js"></script>
|
||||
<script src="./test.js"></script>
|
||||
<script>mocha.checkLeaks();</script>
|
||||
<script>mocha.run();</script>
|
||||
</body>
|
||||
</html>
|
||||
656
node_modules/int64-buffer/test/test.js
generated
vendored
Executable file
656
node_modules/int64-buffer/test/test.js
generated
vendored
Executable file
@@ -0,0 +1,656 @@
|
||||
// #!/usr/bin/env mocha -R spec
|
||||
|
||||
assert.equal = equal;
|
||||
assert.ok = assert;
|
||||
|
||||
var exported = ("undefined" !== typeof require) ? require("../int64-buffer") : window;
|
||||
var Uint64LE = exported.Uint64LE;
|
||||
var Int64LE = exported.Int64LE;
|
||||
var Uint64BE = exported.Uint64BE;
|
||||
var Int64BE = exported.Int64BE;
|
||||
var reduce = Array.prototype.reduce;
|
||||
var forEach = Array.prototype.forEach;
|
||||
var BUFFER = ("undefined" !== typeof Buffer) && Buffer;
|
||||
var ARRAYBUFFER = ("undefined" !== typeof ArrayBuffer) && ArrayBuffer;
|
||||
var UINT8ARRAY = ("undefined" !== typeof Uint8Array) && Uint8Array;
|
||||
var STORAGES = {array: Array, buffer: BUFFER, uint8array: UINT8ARRAY, arraybuffer: ARRAYBUFFER, arraylike: ArrayLike};
|
||||
var itBuffer = BUFFER ? it : it.skip;
|
||||
var itArrayBuffer = ARRAYBUFFER ? it : it.skip;
|
||||
|
||||
allTests("Uint64BE", "Int64BE");
|
||||
allTests("Uint64LE", "Int64LE");
|
||||
miscTests();
|
||||
|
||||
function allTests(uint64Name, int64Name) {
|
||||
var LE = uint64Name.indexOf("LE") > -1;
|
||||
|
||||
var ZERO = [0, 0, 0, 0, 0, 0, 0, 0];
|
||||
var POS1 = [0, 0, 0, 0, 0, 0, 0, 1];
|
||||
var NEG1 = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF];
|
||||
var POSB = [0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0];
|
||||
var NEGB = [0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10];
|
||||
var POS7 = [0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; // INT64_MAX
|
||||
var NEG7 = [0x80, 0, 0, 0, 0, 0, 0, 1]; // -INT64_MAX
|
||||
var NEG8 = [0x80, 0, 0, 0, 0, 0, 0, 0]; // INT64_MIN
|
||||
var H0LF = [0, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF];
|
||||
var H1L0 = [0, 0, 0, 1, 0, 0, 0, 0];
|
||||
var H1LF = [0, 0, 0, 1, 0xFF, 0xFF, 0xFF, 0xFF];
|
||||
var HFL0 = [0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0];
|
||||
var SAMPLES = [ZERO, POS1, NEG1, POSB, NEGB, POS7, NEG7, NEG8, H0LF, H1L0, H1LF, HFL0];
|
||||
var INPUT0 = [0, 0.5, "0", "-0", NaN, Infinity, null, "X"];
|
||||
var INPUT1 = [1, 1.5, "1", "1.5", true];
|
||||
var FLOAT_MAX = Math.pow(2, 53);
|
||||
|
||||
// BE -> LE
|
||||
SAMPLES.forEach(function(array) {
|
||||
if (LE) array.reverse();
|
||||
});
|
||||
|
||||
uint64BasicTests();
|
||||
int64BasicTests();
|
||||
uintMoreTests();
|
||||
intMoreTests();
|
||||
bufferTest(uint64Name);
|
||||
bufferTest(int64Name);
|
||||
|
||||
function uint64BasicTests() {
|
||||
var Uint64Class = exported[uint64Name];
|
||||
describe(uint64Name, function() {
|
||||
it(uint64Name + "()", function() {
|
||||
assert.equal(Uint64Class() - 0, 0);
|
||||
});
|
||||
|
||||
it(uint64Name + "(number)", function() {
|
||||
assert.equal(Uint64Class(123456789) - 0, 123456789);
|
||||
});
|
||||
|
||||
it(uint64Name + "(high,low)", function() {
|
||||
assert.equal(Uint64Class(0x12345678, 0x90abcdef).toString(16), "1234567890abcdef");
|
||||
assert.equal(Uint64Class(0x90abcdef, 0x12345678).toString(16), "90abcdef12345678");
|
||||
});
|
||||
|
||||
it(uint64Name + "(string,raddix)", function() {
|
||||
assert.equal(Uint64Class("1234567890123456").toString(), "1234567890123456");
|
||||
assert.equal(Uint64Class("1234567890123456", 10).toString(10), "1234567890123456");
|
||||
assert.equal(Uint64Class("1234567890abcdef", 16).toString(16), "1234567890abcdef");
|
||||
});
|
||||
|
||||
it(uint64Name + "().toNumber()", function() {
|
||||
var val = Uint64Class(1).toNumber();
|
||||
assert.ok("number" === typeof val);
|
||||
assert.equal(val, 1);
|
||||
});
|
||||
|
||||
it(uint64Name + "().toString()", function() {
|
||||
var val = Uint64Class(1).toString();
|
||||
assert.ok("string" === typeof val);
|
||||
assert.equal(val, "1");
|
||||
});
|
||||
|
||||
it(uint64Name + "().toString(10)", function() {
|
||||
var col = 1;
|
||||
var val = 1;
|
||||
var str = "1";
|
||||
while (val < FLOAT_MAX) {
|
||||
assert.equal(Uint64Class(val).toString(10), str);
|
||||
col = (col + 1) % 10;
|
||||
val = val * 10 + col;
|
||||
str += col;
|
||||
}
|
||||
});
|
||||
|
||||
it(uint64Name + "().toString(16)", function() {
|
||||
var val = 1;
|
||||
var col = 1;
|
||||
var str = "1";
|
||||
while (val < FLOAT_MAX) {
|
||||
assert.equal(Uint64Class(val).toString(16), str);
|
||||
col = (col + 1) % 10;
|
||||
val = val * 16 + col;
|
||||
str += col;
|
||||
}
|
||||
});
|
||||
|
||||
it(uint64Name + "().toJSON()", function() {
|
||||
SAMPLES.forEach(function(array) {
|
||||
var c = Uint64Class(array);
|
||||
assert.equal(c.toJSON(), c.toString(10));
|
||||
});
|
||||
});
|
||||
|
||||
it(uint64Name + "().toArray()", function() {
|
||||
var val = Uint64Class(1).toArray();
|
||||
assert.ok(val instanceof Array);
|
||||
assert.equal(toHex(val), toHex(POS1));
|
||||
});
|
||||
|
||||
itBuffer(uint64Name + "().toBuffer()", function() {
|
||||
var val = Uint64Class(1).toBuffer();
|
||||
assert.ok(BUFFER.isBuffer(val));
|
||||
assert.equal(toHex(val), toHex(POS1));
|
||||
});
|
||||
|
||||
itArrayBuffer(uint64Name + "().toArrayBuffer()", function() {
|
||||
var val = Uint64Class(1).toArrayBuffer();
|
||||
assert.ok(val instanceof ArrayBuffer);
|
||||
assert.equal(val.byteLength, 8);
|
||||
assert.equal(toHex(new Uint8Array(val)), toHex(POS1));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function int64BasicTests() {
|
||||
var Int64Class = exported[int64Name];
|
||||
|
||||
describe(int64Name, function() {
|
||||
it(int64Name + "()", function() {
|
||||
assert.equal(Int64Class() - 0, 0);
|
||||
});
|
||||
|
||||
it(int64Name + "(number)", function() {
|
||||
assert.equal(Int64Class(-123456789) - 0, -123456789);
|
||||
});
|
||||
|
||||
it(int64Name + "(high,low)", function() {
|
||||
assert.equal(Int64Class(0x12345678, 0x90abcdef).toString(16), "1234567890abcdef");
|
||||
assert.equal(Int64Class(0xFFFFFFFF, 0xFFFFFFFF) - 0, -1);
|
||||
});
|
||||
|
||||
it(int64Name + "(string,raddix)", function() {
|
||||
assert.equal(Int64Class("1234567890123456").toString(), "1234567890123456");
|
||||
assert.equal(Int64Class("1234567890123456", 10).toString(10), "1234567890123456");
|
||||
assert.equal(Int64Class("1234567890abcdef", 16).toString(16), "1234567890abcdef");
|
||||
});
|
||||
|
||||
it(int64Name + "(array,offset)", function() {
|
||||
var buf = [].concat(NEG1, NEG1);
|
||||
var val = Int64Class(buf, 4, -2);
|
||||
assert.equal(val.toString(16), "-2");
|
||||
assert.equal(val.toNumber(), -2);
|
||||
});
|
||||
|
||||
it(int64Name + "().toNumber()", function() {
|
||||
var val = Int64Class(-1).toNumber();
|
||||
assert.ok("number" === typeof val);
|
||||
assert.equal(val, -1);
|
||||
});
|
||||
|
||||
it(int64Name + "().toString()", function() {
|
||||
var val = Int64Class(-1).toString();
|
||||
assert.ok("string" === typeof val);
|
||||
assert.equal(val, "-1");
|
||||
});
|
||||
|
||||
it(int64Name + "().toString(10)", function() {
|
||||
var col = 1;
|
||||
var val = -1;
|
||||
var str = "-1";
|
||||
while (val > FLOAT_MAX) {
|
||||
assert.equal(Int64Class(val).toString(10), str);
|
||||
col = (col + 1) % 10;
|
||||
val = val * 10 - col;
|
||||
str += col;
|
||||
}
|
||||
});
|
||||
|
||||
it(int64Name + "().toString(16)", function() {
|
||||
var col = 1;
|
||||
var val = -1;
|
||||
var str = "-1";
|
||||
while (val > FLOAT_MAX) {
|
||||
assert.equal(Int64Class(val).toString(16), str);
|
||||
col = (col + 1) % 10;
|
||||
val = val * 16 - col;
|
||||
str += col;
|
||||
}
|
||||
});
|
||||
|
||||
it(int64Name + "().toJSON()", function() {
|
||||
SAMPLES.forEach(function(array) {
|
||||
var c = Int64Class(array);
|
||||
assert.equal(c.toJSON(), c.toString(10));
|
||||
});
|
||||
});
|
||||
|
||||
it(int64Name + "().toArray()", function() {
|
||||
var val = Int64Class(-1).toArray();
|
||||
assert.ok(val instanceof Array);
|
||||
assert.equal(toHex(val), toHex(NEG1));
|
||||
|
||||
val = Int64Class(val, 0, 1).toArray();
|
||||
assert.ok(val instanceof Array);
|
||||
assert.equal(toHex(val), toHex(POS1));
|
||||
});
|
||||
|
||||
itBuffer(int64Name + "().toBuffer()", function() {
|
||||
var val = Int64Class(-1).toBuffer();
|
||||
assert.ok(BUFFER.isBuffer(val));
|
||||
assert.equal(toHex(val), toHex(NEG1));
|
||||
|
||||
val = Int64Class(val, 0, 1).toBuffer();
|
||||
assert.ok(BUFFER.isBuffer(val));
|
||||
assert.equal(toHex(val), toHex(POS1));
|
||||
});
|
||||
|
||||
itArrayBuffer(int64Name + "().toArrayBuffer()", function() {
|
||||
var val = Int64Class(-1).toArrayBuffer();
|
||||
assert.ok(val instanceof ArrayBuffer);
|
||||
assert.equal(val.byteLength, 8);
|
||||
assert.equal(toHex(new Uint8Array(val)), toHex(NEG1));
|
||||
|
||||
val = Int64Class(val, 0, 1).toArrayBuffer();
|
||||
assert.ok(val instanceof ArrayBuffer);
|
||||
assert.equal(val.byteLength, 8);
|
||||
assert.equal(toHex(new Uint8Array(val)), toHex(POS1));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function bufferTest(className) {
|
||||
describe(className, function() {
|
||||
Object.keys(STORAGES).forEach(function(storageName) {
|
||||
storageTests(className, storageName);
|
||||
});
|
||||
|
||||
Object.keys(STORAGES).forEach(function(storageName) {
|
||||
if (storageName === "array") return;
|
||||
storageSourceTests(className, storageName);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function storageTests(className, storageName) {
|
||||
var Int64Class = exported[className];
|
||||
var StorageClass = STORAGES[storageName];
|
||||
var itSkip = StorageClass ? it : it.skip;
|
||||
var highpos = LE ? 15 : 8;
|
||||
var lowpos = LE ? 8 : 15;
|
||||
|
||||
itSkip(className + "(" + storageName + ",offset)", function() {
|
||||
var buffer = new StorageClass(24);
|
||||
var raw = buffer;
|
||||
if (isArrayBuffer(buffer)) buffer = (raw = new Uint8Array(buffer)).buffer;
|
||||
for (var i = 0; i < 24; i++) {
|
||||
raw[i] = i;
|
||||
}
|
||||
var val = new Int64Class(buffer, 8);
|
||||
var higher = LE ? 0x0f0e0d0c0b : 0x08090A0B0C;
|
||||
assert.equal(Math.round(val.toNumber() / 0x1000000), higher); // check only higher 48bits
|
||||
var hex = LE ? "f0e0d0c0b0a0908" : "8090a0b0c0d0e0f";
|
||||
assert.equal(val.toString(16), hex);
|
||||
var out = val.toArray();
|
||||
assert.equal(toHex(out), "08090a0b0c0d0e0f");
|
||||
assert.ok(out instanceof Array);
|
||||
if (BUFFER) {
|
||||
out = val.toBuffer();
|
||||
assert.equal(toHex(out), "08090a0b0c0d0e0f");
|
||||
assert.ok(BUFFER.isBuffer(out));
|
||||
}
|
||||
if (UINT8ARRAY) {
|
||||
out = val.toArrayBuffer();
|
||||
assert.equal(toHex(new Uint8Array(out)), "08090a0b0c0d0e0f");
|
||||
assert.ok(out instanceof ArrayBuffer);
|
||||
}
|
||||
});
|
||||
|
||||
itSkip(className + "(" + storageName + ",offset,number)", function() {
|
||||
var buffer = new StorageClass(24);
|
||||
var val = new Int64Class(buffer, 8, 1234567890);
|
||||
assert.equal(val.toNumber(), 1234567890);
|
||||
assert.equal(val.toString(), "1234567890");
|
||||
assert.equal(val.toJSON(), "1234567890");
|
||||
if (isArrayBuffer(buffer)) buffer = new Uint8Array(buffer);
|
||||
assert.equal(buffer[highpos], 0);
|
||||
assert.equal(buffer[lowpos], 1234567890 & 255);
|
||||
});
|
||||
|
||||
itSkip(className + "(" + storageName + ",offset,high,low)", function() {
|
||||
var buffer = new StorageClass(24);
|
||||
var val = new Int64Class(buffer, 8, 0x12345678, 0x90abcdef);
|
||||
assert.equal(val.toString(16), "1234567890abcdef");
|
||||
if (isArrayBuffer(buffer)) buffer = new Uint8Array(buffer);
|
||||
assert.equal(buffer[highpos], 0x12);
|
||||
assert.equal(buffer[lowpos], 0xef);
|
||||
});
|
||||
|
||||
itSkip(className + "(" + storageName + ",offset,string,raddix)", function() {
|
||||
var buffer = new StorageClass(24);
|
||||
var val = new Int64Class(buffer, 8, "1234567890", 16);
|
||||
assert.equal(val.toNumber(), 0x1234567890);
|
||||
assert.equal(val.toString(16), "1234567890");
|
||||
assert.equal(val.toJSON(), (0x1234567890).toString());
|
||||
if (isArrayBuffer(buffer)) buffer = new Uint8Array(buffer);
|
||||
assert.equal(buffer[highpos], 0);
|
||||
assert.equal(buffer[lowpos], 0x1234567890 & 255);
|
||||
});
|
||||
|
||||
itSkip(className + "(" + storageName + ",offset,array,offset)", function() {
|
||||
var buffer = new StorageClass(16);
|
||||
var src = LE ? [].concat(POSB, NEGB) : [].concat(NEGB, POSB);
|
||||
var val = Int64Class(buffer, 8, src, 4);
|
||||
assert.equal(val.toString(16), "7654321012345678");
|
||||
if (isArrayBuffer(buffer)) buffer = new Uint8Array(buffer);
|
||||
assert.equal(buffer[8], src[4]);
|
||||
assert.equal(buffer[15], src[11]);
|
||||
});
|
||||
}
|
||||
|
||||
function storageSourceTests(className, storageName) {
|
||||
var Int64Class = exported[className];
|
||||
var StorageClass = STORAGES[storageName];
|
||||
var itSkip = StorageClass ? it : it.skip;
|
||||
|
||||
itSkip(className + "(array,offset," + storageName + ",offset)", function() {
|
||||
var buffer = new Array(16);
|
||||
var src = LE ? [].concat(POSB, NEGB) : [].concat(NEGB, POSB);
|
||||
var copy = src.slice();
|
||||
if (storageName === "buffer") {
|
||||
src = new BUFFER(src);
|
||||
} else if (storageName === "uint8array") {
|
||||
src = new UINT8ARRAY(src);
|
||||
} else if (storageName === "arraybuffer") {
|
||||
src = (new UINT8ARRAY(src)).buffer;
|
||||
} else if (storageName === "arraylike") {
|
||||
src = new ArrayLike(src);
|
||||
}
|
||||
var val = Int64Class(buffer, 8, src, 4);
|
||||
assert.ok(val.buffer instanceof Array);
|
||||
assert.equal(val.toString(16), "7654321012345678");
|
||||
if (isArrayBuffer(buffer)) buffer = new Uint8Array(buffer);
|
||||
assert.equal(buffer[8], copy[4]);
|
||||
assert.equal(buffer[15], copy[11]);
|
||||
});
|
||||
}
|
||||
|
||||
function uintMoreTests() {
|
||||
var Uint64Class = exported[uint64Name];
|
||||
|
||||
describe(uint64Name + "(string)", function() {
|
||||
// rount-trip by string
|
||||
it(uint64Name + "(''+" + uint64Name + "())", function() {
|
||||
SAMPLES.forEach(function(array) {
|
||||
var c = "" + Uint64Class(array);
|
||||
var d = "" + Uint64Class(c);
|
||||
assert.equal(d, c);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe(uint64Name + "(array)", function() {
|
||||
forEach.call([
|
||||
[0x0000000000000000, 0, 0, 0, 0, 0, 0, 0, 0], // 0
|
||||
[0x0000000000000001, 0, 0, 0, 0, 0, 0, 0, 1], // 1
|
||||
[0x00000000FFFFFFFF, 0, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF],
|
||||
[0x4000000000000000, 0x40, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0x7FFFFFFF00000000, 0x7F, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0],
|
||||
[0x8000000000000000, 0x80, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0x8000000100000000, 0x80, 0, 0, 1, 0, 0, 0, 0],
|
||||
[0xFFFFFFFF00000000, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0]
|
||||
], function(exp) {
|
||||
var val = exp.shift();
|
||||
if (LE) exp.reverse();
|
||||
it(toHex(exp), function() {
|
||||
var c = new Uint64Class(exp);
|
||||
assert.equal(toHex(c.buffer), toHex(exp));
|
||||
assert.equal(c - 0, val);
|
||||
assert.equal(c.toNumber(), val);
|
||||
assert.equal(c.toString(16), toString16(val));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe(uint64Name + "(high1)", function() {
|
||||
reduce.call([
|
||||
[0, 0, 0, 0, 0, 0, 0, 1], // 1
|
||||
[0, 0, 0, 0, 0, 0, 1, 0], // 256
|
||||
[0, 0, 0, 0, 0, 1, 0, 0], // 65536
|
||||
[0, 0, 0, 0, 1, 0, 0, 0],
|
||||
[0, 0, 0, 1, 0, 0, 0, 0],
|
||||
[0, 0, 1, 0, 0, 0, 0, 0],
|
||||
[0, 1, 0, 0, 0, 0, 0, 0],
|
||||
[1, 0, 0, 0, 0, 0, 0, 0]
|
||||
], function(val, exp) {
|
||||
if (LE) exp.reverse();
|
||||
it(toHex(exp), function() {
|
||||
var c = new Uint64Class(val);
|
||||
assert.equal(toHex(c.buffer), toHex(exp));
|
||||
assert.equal(c - 0, val);
|
||||
assert.equal(c.toNumber(), val);
|
||||
assert.equal(c.toString(16), toString16(val));
|
||||
});
|
||||
return val * 256;
|
||||
}, 1);
|
||||
});
|
||||
|
||||
describe(uint64Name + "(high32)", function() {
|
||||
reduce.call([
|
||||
[0, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF],
|
||||
[0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0],
|
||||
[0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0],
|
||||
[0, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0],
|
||||
[0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0]
|
||||
], function(val, exp) {
|
||||
if (LE) exp.reverse();
|
||||
it(toHex(exp), function() {
|
||||
var c = new Uint64Class(val);
|
||||
assert.equal(toHex(c.buffer), toHex(exp));
|
||||
assert.equal(c - 0, val);
|
||||
assert.equal(c.toNumber(), val);
|
||||
assert.equal(c.toString(16), toString16(val));
|
||||
});
|
||||
return val * 256;
|
||||
}, 0xFFFFFFFF);
|
||||
});
|
||||
}
|
||||
|
||||
function intMoreTests() {
|
||||
var Int64Class = exported[int64Name];
|
||||
|
||||
describe(int64Name + "(array)", function() {
|
||||
forEach.call([
|
||||
[0x0000000000000000, 0, 0, 0, 0, 0, 0, 0, 0], // 0
|
||||
[0x0000000000000001, 0, 0, 0, 0, 0, 0, 0, 1], // 1
|
||||
[0x00000000FFFFFFFF, 0, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF],
|
||||
[-0x00000000FFFFFFFF, 0xFF, 0xFF, 0xFF, 0xFF, 0, 0, 0, 1],
|
||||
[0x4000000000000000, 0x40, 0, 0, 0, 0, 0, 0, 0],
|
||||
[-0x4000000000000000, 0xC0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0x7FFFFFFF00000000, 0x7F, 0xFF, 0xFF, 0xFF, 0, 0, 0, 0],
|
||||
[-0x7FFFFFFF00000000, 0x80, 0, 0, 1, 0, 0, 0, 0],
|
||||
[-1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
|
||||
], function(exp) {
|
||||
var val = exp.shift();
|
||||
if (LE) exp.reverse();
|
||||
it(toHex(exp), function() {
|
||||
var c = new Int64Class(exp);
|
||||
assert.equal(toHex(c.buffer), toHex(exp));
|
||||
assert.equal(c - 0, val);
|
||||
assert.equal(c.toNumber(), val);
|
||||
assert.equal(c.toString(16), toString16(val));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe(int64Name + "(low1)", function() {
|
||||
reduce.call([
|
||||
[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE], // -2
|
||||
[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF], // -257
|
||||
[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF], // -65537
|
||||
[0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF],
|
||||
[0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF],
|
||||
[0xFF, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
|
||||
[0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF],
|
||||
[0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
|
||||
], function(val, exp) {
|
||||
if (LE) exp.reverse();
|
||||
it(toHex(exp), function() {
|
||||
var c = new Int64Class(val);
|
||||
assert.equal(toHex(c.buffer), toHex(exp));
|
||||
assert.equal(c - 0, val);
|
||||
assert.equal(c.toNumber(), val);
|
||||
});
|
||||
return (val * 256) + 255;
|
||||
}, -2);
|
||||
});
|
||||
|
||||
describe(int64Name + "(low31)", function() {
|
||||
reduce.call([
|
||||
[0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0, 0, 0],
|
||||
[0xFF, 0xFF, 0xFF, 0x80, 0, 0, 0, 0xFF],
|
||||
[0xFF, 0xFF, 0x80, 0, 0, 0, 0xFF, 0xFF],
|
||||
[0xFF, 0x80, 0, 0, 0, 0xFF, 0xFF, 0xFF],
|
||||
[0x80, 0, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF]
|
||||
], function(val, exp) {
|
||||
if (LE) exp.reverse();
|
||||
it(toHex(exp), function() {
|
||||
var c = new Int64Class(val);
|
||||
assert.equal(toHex(c.buffer), toHex(exp));
|
||||
assert.equal(c - 0, val);
|
||||
assert.equal(c.toNumber(), val);
|
||||
});
|
||||
return (val * 256) + 255;
|
||||
}, -2147483648);
|
||||
});
|
||||
|
||||
describe(int64Name + "(0)", function() {
|
||||
INPUT0.forEach(function(val) {
|
||||
var view = ("string" === typeof val) ? '"' + val + '"' : val;
|
||||
var hex = toHex(ZERO);
|
||||
it(toHex(ZERO) + " = " + view, function() {
|
||||
var c = new Uint64LE(val);
|
||||
assert.equal(toHex(c.toArray()), hex);
|
||||
assert.equal(c.toString(), "0");
|
||||
assert.equal(c.toNumber(), 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe(int64Name + "(array,offset,0)", function() {
|
||||
INPUT0.forEach(function(val) {
|
||||
var view = ("string" === typeof val) ? '"' + val + '"' : val;
|
||||
var hex = toHex(ZERO);
|
||||
var buf = [].concat(POSB, NEGB);
|
||||
it(toHex(ZERO) + " = " + view, function() {
|
||||
var c = new Int64Class(buf, 4, val);
|
||||
assert.equal(toHex(c.toArray()), hex);
|
||||
assert.equal(c.toString(), "0");
|
||||
assert.equal(c.toNumber(), 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe(int64Name + "(1)", function() {
|
||||
INPUT1.forEach(function(val) {
|
||||
var view = ("string" === typeof val) ? '"' + val + '"' : val;
|
||||
var hex = toHex(POS1);
|
||||
it(toHex(POS1) + " = " + view, function() {
|
||||
var c = new Int64Class(val);
|
||||
assert.equal(toHex(c.toArray()), hex);
|
||||
assert.equal(c.toString(), "1");
|
||||
assert.equal(c.toNumber(), 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe(int64Name + "(array,offset,1)", function() {
|
||||
INPUT1.forEach(function(val) {
|
||||
var view = ("string" === typeof val) ? '"' + val + '"' : val;
|
||||
var hex = toHex(POS1);
|
||||
var buf = [].concat(POSB, NEGB);
|
||||
it(toHex(POS1) + " = " + view, function() {
|
||||
var c = new Int64Class(buf, 4, val);
|
||||
assert.equal(toHex(c.toArray()), hex);
|
||||
assert.equal(c.toString(), "1");
|
||||
assert.equal(c.toNumber(), 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe(int64Name + "(string)", function() {
|
||||
// rount-trip by string
|
||||
it(int64Name + "(''+" + int64Name + "())", function() {
|
||||
SAMPLES.forEach(function(array) {
|
||||
var c = "" + Int64Class(array);
|
||||
var d = "" + Int64Class(c);
|
||||
assert.equal(d, c);
|
||||
});
|
||||
});
|
||||
|
||||
// round-trip with negative value
|
||||
it(int64Name + "('-'+" + int64Name + "())", function() {
|
||||
SAMPLES.forEach(function(array) {
|
||||
if (array === NEG8) return; // skip -INT64_MIN overflow
|
||||
var c = "" + Int64Class(array);
|
||||
var d = (c === "0") ? c : (c[0] === "-") ? c.substr(1) : "-" + c;
|
||||
var e = "" + Int64Class(d);
|
||||
var f = (e === "0") ? e : (e[0] === "-") ? e.substr(1) : "-" + e;
|
||||
assert.equal(f, c);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function miscTests() {
|
||||
describe("Misc", function() {
|
||||
it("Uint64BE.isUint64BE(Uint64BE())", function() {
|
||||
assert.ok(Uint64BE.isUint64BE(Uint64BE()));
|
||||
assert.ok(!Uint64BE.isUint64BE(Int64BE()));
|
||||
});
|
||||
|
||||
it("Int64BE.isInt64BE(Int64BE())", function() {
|
||||
assert.ok(Int64BE.isInt64BE(Int64BE()));
|
||||
assert.ok(!Int64BE.isInt64BE(Uint64BE()));
|
||||
});
|
||||
|
||||
it("Uint64LE.isUint64LE(Uint64LE())", function() {
|
||||
assert.ok(Uint64LE.isUint64LE(Uint64LE()));
|
||||
assert.ok(!Uint64LE.isUint64LE(Int64LE()));
|
||||
});
|
||||
|
||||
it("Int64LE.isInt64LE(Int64LE())", function() {
|
||||
assert.ok(Int64LE.isInt64LE(Int64LE()));
|
||||
assert.ok(!Int64LE.isInt64LE(Uint64LE()));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function ArrayLike(arg) {
|
||||
if (!(this instanceof ArrayLike)) return new ArrayLike(arg);
|
||||
var i;
|
||||
if (arg && arg.length) {
|
||||
this.length = arg.length;
|
||||
for (i = 0; i < this.length; i++) this[i] = arg[i];
|
||||
} else {
|
||||
this.length = arg;
|
||||
for (i = 0; i < this.length; i++) this[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function isArrayBuffer(buffer) {
|
||||
return (ARRAYBUFFER && buffer instanceof ArrayBuffer);
|
||||
}
|
||||
|
||||
function toHex(array) {
|
||||
return Array.prototype.map.call(array, function(val) {
|
||||
return val > 15 ? val.toString(16) : "0" + val.toString(16);
|
||||
}).join("");
|
||||
}
|
||||
|
||||
function toString16(val) {
|
||||
var str = val.toString(16);
|
||||
if (str.indexOf("e+") < 0) return str;
|
||||
// IE8-10 may return "4(e+15)" style of string
|
||||
return Math.floor(val / 0x100000000).toString(16) + lpad((val % 0x100000000).toString(16), 8);
|
||||
}
|
||||
|
||||
function lpad(str, len) {
|
||||
return "00000000".substr(0, len - str.length) + str;
|
||||
}
|
||||
|
||||
function assert(value) {
|
||||
if (!value) throw new Error(value + " = " + true);
|
||||
}
|
||||
|
||||
function equal(actual, expected) {
|
||||
if (actual != expected) throw new Error(actual + " = " + expected);
|
||||
}
|
||||
4
node_modules/int64-buffer/test/zuul/ie.html
generated
vendored
Normal file
4
node_modules/int64-buffer/test/zuul/ie.html
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<!--[if lte IE 8]>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.1.10/es5-shim.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"></script>
|
||||
<![endif]-->
|
||||
Reference in New Issue
Block a user