primer cambio

This commit is contained in:
beseira13
2026-01-19 12:12:38 -03:00
parent 5f59dba52d
commit 44990f015a
4759 changed files with 588702 additions and 0 deletions

6
node_modules/buffer-more-ints/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,6 @@
language: node_js
node_js:
- "0.11"
- "0.10"
- "0.8"
- "0.6"

19
node_modules/buffer-more-ints/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2012 David Wragg. 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.

69
node_modules/buffer-more-ints/README.md generated vendored Normal file
View File

@@ -0,0 +1,69 @@
# buffer-more-ints: Add support for more integer widths to Buffer
[![Build Status](https://travis-ci.org/dpw/node-buffer-more-ints.png)](https://travis-ci.org/dpw/node-buffer-more-ints)
Node's Buffer only supports reading and writing integers of a limited
range of widths. This module provides support for more widths, so
that integers from 1 to 8 bytes (64 bits) can be accessed. The
support takes two forms. Firstly, as stand-alone functions similar to
the integer reading/writing methods of Buffer:
$ node
> var moreints = require('buffer-more-ints')
undefined
> moreints.readInt64BE(new Buffer("0000deadbeef0000", "hex"), 0).toString(16)
'deadbeef0000'
Read and write functions for the regular widths (8, 16, 32) are also
present in this module, for consistency.
The second form is methods patched into `Buffer.prototype`, installed
by requiring `'buffer-more-ints/polyfill'`:
$ node
> require('buffer-more-ints/polyfill')
{}
> new Buffer("0000deadbeef0000", "hex").readInt64BE(0).toString(16)
'deadbeef0000'
buffer-more-ints/polyfill also adds methods `readIntBE`, `writeIntBE`,
and their LE and UInt counterparts, which take an initial argument
giving the width of the integer in bytes:
> var b = new Buffer(3);
> b.writeIntLE(3, -123456, 0);
> b.toString('hex')
'c01dfe'
> b.readIntLE(3, 0);
-123456
The functions added by buffer-more-ints are all implemented in terms
of the core Buffer functions. Part way through writing the code, I
discovered that node.js currently implements those in JavaScript, so
this doesn't lead to performance benefits. But should node ever
switch to implementing its Buffer operations natively, this
module should get a speed boost.
## Limitations
As JavaScript uses IEEE754 doubles for numbers, the contiguous range
of integers it can represent is [-2^53 - 1, 2^53 - 1]. So only
integer widths up to 6 bytes or 48 bits can be read exactly. Reads of
7 or 8 bytes (56 or 64 bits) will return the closest value that can be
represented as a JavaScript number.
In certain situations it might be important to check that a JavaScript
number was read exactly. The `isContiguousInt` or
`Buffer.isContiguousInt` (polyfill) function will determine this:
> Buffer.isContiguousInt(0x1fffffffffffff);
true
> Buffer.isContiguousInt(0x20000000000000);
false
And `assertContiguousInt` asserts that a number is so:
> Buffer.assertContiguousInt(0x1fffffffffffff);
undefined
> Buffer.assertContiguousInt(0x20000000000000);
AssertionError: number cannot be represented as a contiguous integer

183
node_modules/buffer-more-ints/buffer-more-ints-tests.js generated vendored Normal file
View File

@@ -0,0 +1,183 @@
'use strict';
require('./polyfill');
// A simple abbreviation to obtain a buffer from a hex string
function h2b(str) {
return new Buffer(str, "hex");
}
// Reverse a buffer
function reverse(buf) {
var res = new Buffer(buf.length);
for (var i = 0, j = buf.length - 1; j >= 0; i++, j--) {
res[i] = buf[j];
}
return res;
}
// Fill a buffer with distinctive data
function scrub(buf) {
var pos = 0;
var written;
while ((written = buf.write("deadbeef", pos, 4, "hex")) == 4) {
pos += written;
}
return buf;
}
function xint_case(xint) {
return function (assert, hex, val, inexact) {
var readBE = "read" + xint + "BE";
var writeBE = "write" + xint + "BE";
var readLE = "read" + xint + "LE";
var writeLE = "write" + xint + "LE";
var len = hex.length / 2;
// Straightforward read cases
assert.equal(h2b(hex)[readBE](len, 0), val);
assert.equal(reverse(h2b(hex))[readLE](len, 0), val);
// Test straightforward writes and noAssert writes off the ends of
// the buffer
var buf = scrub(new Buffer(len));
buf[writeBE](len, val, 0);
if (!inexact) {
assert.equal(buf.toString("hex"), hex);
} else {
assert.equal(buf[readBE](len, 0), val);
}
scrub(buf);
buf[writeLE](len, val, 0);
if (!inexact) {
assert.equal(reverse(buf).toString("hex"), hex);
} else {
assert.equal(buf[readLE](len, 0), val);
}
// Accesses off the ends of the buffer should throw.
assert.throws(function () { h2b(hex)[readBE](len, -1); });
assert.throws(function () { h2b(hex)[readBE](len, 1); });
assert.throws(function () { reverse(h2b(hex))[readLE](len, 1); });
assert.throws(function () { reverse(h2b(hex))[readLE](len, -1); });
assert.throws(function () { buf[writeBE](len, val, 1); });
assert.throws(function () { buf[writeBE](len, val, -1); });
assert.throws(function () { buf[writeLE](len, val, 1); });
assert.throws(function () { buf[writeLE](len, val, -1); });
};
}
var uint_case = xint_case("UInt");
var int_case = xint_case("Int");
module.exports.uint = function (assert) {
uint_case(assert, "00", 0x00);
uint_case(assert, "01", 0x01);
uint_case(assert, "ff", 0xff);
uint_case(assert, "0000", 0x0000);
uint_case(assert, "0102", 0x0102);
uint_case(assert, "ffff", 0xffff);
uint_case(assert, "000000", 0x000000);
uint_case(assert, "010203", 0x010203);
uint_case(assert, "ffffff", 0xffffff);
uint_case(assert, "00000000", 0x00000000);
uint_case(assert, "01020304", 0x01020304);
uint_case(assert, "ffffffff", 0xffffffff);
uint_case(assert, "0000000000", 0x0000000000);
uint_case(assert, "0102030405", 0x0102030405);
uint_case(assert, "ffffffffff", 0xffffffffff);
uint_case(assert, "000000000000", 0x000000000000);
uint_case(assert, "010203040506", 0x010203040506);
uint_case(assert, "ffffffffffff", 0xffffffffffff);
uint_case(assert, "00000000000000", 0x00000000000000);
uint_case(assert, "01020304050607", 0x01020304050607);
uint_case(assert, "ffffffffffffff", 0xffffffffffffff);
uint_case(assert, "0000000000000000", 0x0000000000000000);
uint_case(assert, "0102030405060708", 0x0102030405060708, true);
uint_case(assert, "ffffffffffffffff", 0xffffffffffffffff);
assert.done();
};
module.exports.int = function (assert) {
int_case(assert, "00", 0x00);
int_case(assert, "01", 0x01);
int_case(assert, "7f", 0x7f);
int_case(assert, "80", -0x80);
int_case(assert, "ff", -0x01);
int_case(assert, "0000", 0x0000);
int_case(assert, "0102", 0x0102);
int_case(assert, "7fff", 0x7fff);
int_case(assert, "8000", -0x8000);
int_case(assert, "ffff", -0x0001);
int_case(assert, "000000", 0x000000);
int_case(assert, "010203", 0x010203);
int_case(assert, "7fffff", 0x7fffff);
int_case(assert, "800000", -0x800000);
int_case(assert, "ffffff", -0x000001);
int_case(assert, "00000000", 0x00000000);
int_case(assert, "01020304", 0x01020304);
int_case(assert, "7fffffff", 0x7fffffff);
int_case(assert, "80000000", -0x80000000);
int_case(assert, "ffffffff", -0x00000001);
int_case(assert, "0000000000", 0x0000000000);
int_case(assert, "0102030405", 0x0102030405);
int_case(assert, "7fffffffff", 0x7fffffffff);
int_case(assert, "8000000000", -0x8000000000);
int_case(assert, "ffffffffff", -0x0000000001);
int_case(assert, "000000000000", 0x000000000000);
int_case(assert, "010203040506", 0x010203040506);
int_case(assert, "7fffffffffff", 0x7fffffffffff);
int_case(assert, "800000000000", -0x800000000000);
int_case(assert, "ffffffffffff", -0x000000000001);
int_case(assert, "00000000000000", 0x00000000000000);
int_case(assert, "01020304050607", 0x01020304050607);
int_case(assert, "7fffffffffffff", 0x7fffffffffffff);
int_case(assert, "80000000000000", -0x80000000000000);
int_case(assert, "ffffffffffffff", -0x00000000000001);
int_case(assert, "0000000000000000", 0x0000000000000000);
int_case(assert, "0102030405060708", 0x0102030405060708, true);
int_case(assert, "7fffffffffffffff", 0x7fffffffffffffff);
int_case(assert, "8000000000000000", -0x8000000000000000);
int_case(assert, "ffffffffffffffff", -0x0000000000000001);
assert.done();
};
module.exports.isContiguousInt = function (assert) {
assert.equal(Buffer.isContiguousInt(0x1fffffffffffff), true);
assert.equal(Buffer.isContiguousInt(0x20000000000000), false);
assert.equal(Buffer.isContiguousInt(-0x1fffffffffffff), true);
assert.equal(Buffer.isContiguousInt(-0x20000000000000), false);
assert.doesNotThrow(function () {
Buffer.assertContiguousInt(0x1fffffffffffff);
});
assert.throws(function () {
Buffer.assertContiguousInt(0x20000000000000);
});
assert.doesNotThrow(function () {
Buffer.assertContiguousInt(-0x1fffffffffffff);
});
assert.throws(function () {
Buffer.assertContiguousInt(-0x20000000000000);
});
assert.done();
};

432
node_modules/buffer-more-ints/buffer-more-ints.js generated vendored Normal file
View File

@@ -0,0 +1,432 @@
'use strict';
// JavaScript is numerically challenged
var SHIFT_LEFT_32 = (1 << 16) * (1 << 16);
var SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
// The maximum contiguous integer that can be held in a IEEE754 double
var MAX_INT = 0x1fffffffffffff;
function isContiguousInt(val) {
return val <= MAX_INT && val >= -MAX_INT;
}
function assertContiguousInt(val) {
if (!isContiguousInt(val)) {
throw new TypeError("number cannot be represented as a contiguous integer");
}
}
module.exports.isContiguousInt = isContiguousInt;
module.exports.assertContiguousInt = assertContiguousInt;
// Fill in the regular procedures
['UInt', 'Int'].forEach(function (sign) {
var suffix = sign + '8';
module.exports['read' + suffix] =
Buffer.prototype['read' + suffix].call;
module.exports['write' + suffix] =
Buffer.prototype['write' + suffix].call;
['16', '32'].forEach(function (size) {
['LE', 'BE'].forEach(function (endian) {
var suffix = sign + size + endian;
var read = Buffer.prototype['read' + suffix];
module.exports['read' + suffix] =
function (buf, offset) {
return read.call(buf, offset);
};
var write = Buffer.prototype['write' + suffix];
module.exports['write' + suffix] =
function (buf, val, offset) {
return write.call(buf, val, offset);
};
});
});
});
// Check that a value is an integer within the given range
function check_value(val, min, max) {
val = +val;
if (typeof(val) != 'number' || val < min || val > max || Math.floor(val) !== val) {
throw new TypeError("\"value\" argument is out of bounds");
}
return val;
}
// Check that something is within the Buffer bounds
function check_bounds(buf, offset, len) {
if (offset < 0 || offset + len > buf.length) {
throw new RangeError("Index out of range");
}
}
function readUInt24BE(buf, offset) {
return buf.readUInt8(offset) << 16 | buf.readUInt16BE(offset + 1);
}
module.exports.readUInt24BE = readUInt24BE;
function writeUInt24BE(buf, val, offset) {
val = check_value(val, 0, 0xffffff);
check_bounds(buf, offset, 3);
buf.writeUInt8(val >>> 16, offset);
buf.writeUInt16BE(val & 0xffff, offset + 1);
}
module.exports.writeUInt24BE = writeUInt24BE;
function readUInt40BE(buf, offset) {
return (buf.readUInt8(offset) || 0) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 1);
}
module.exports.readUInt40BE = readUInt40BE;
function writeUInt40BE(buf, val, offset) {
val = check_value(val, 0, 0xffffffffff);
check_bounds(buf, offset, 5);
buf.writeUInt8(Math.floor(val * SHIFT_RIGHT_32), offset);
buf.writeInt32BE(val & -1, offset + 1);
}
module.exports.writeUInt40BE = writeUInt40BE;
function readUInt48BE(buf, offset) {
return buf.readUInt16BE(offset) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 2);
}
module.exports.readUInt48BE = readUInt48BE;
function writeUInt48BE(buf, val, offset) {
val = check_value(val, 0, 0xffffffffffff);
check_bounds(buf, offset, 6);
buf.writeUInt16BE(Math.floor(val * SHIFT_RIGHT_32), offset);
buf.writeInt32BE(val & -1, offset + 2);
}
module.exports.writeUInt48BE = writeUInt48BE;
function readUInt56BE(buf, offset) {
return ((buf.readUInt8(offset) || 0) << 16 | buf.readUInt16BE(offset + 1)) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 3);
}
module.exports.readUInt56BE = readUInt56BE;
function writeUInt56BE(buf, val, offset) {
val = check_value(val, 0, 0xffffffffffffff);
check_bounds(buf, offset, 7);
if (val < 0x100000000000000) {
var hi = Math.floor(val * SHIFT_RIGHT_32);
buf.writeUInt8(hi >>> 16, offset);
buf.writeUInt16BE(hi & 0xffff, offset + 1);
buf.writeInt32BE(val & -1, offset + 3);
} else {
// Special case because 2^56-1 gets rounded up to 2^56
buf[offset] = 0xff;
buf[offset+1] = 0xff;
buf[offset+2] = 0xff;
buf[offset+3] = 0xff;
buf[offset+4] = 0xff;
buf[offset+5] = 0xff;
buf[offset+6] = 0xff;
}
}
module.exports.writeUInt56BE = writeUInt56BE;
function readUInt64BE(buf, offset) {
return buf.readUInt32BE(offset) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 4);
}
module.exports.readUInt64BE = readUInt64BE;
function writeUInt64BE(buf, val, offset) {
val = check_value(val, 0, 0xffffffffffffffff);
check_bounds(buf, offset, 8);
if (val < 0x10000000000000000) {
buf.writeUInt32BE(Math.floor(val * SHIFT_RIGHT_32), offset);
buf.writeInt32BE(val & -1, offset + 4);
} else {
// Special case because 2^64-1 gets rounded up to 2^64
buf[offset] = 0xff;
buf[offset+1] = 0xff;
buf[offset+2] = 0xff;
buf[offset+3] = 0xff;
buf[offset+4] = 0xff;
buf[offset+5] = 0xff;
buf[offset+6] = 0xff;
buf[offset+7] = 0xff;
}
}
module.exports.writeUInt64BE = writeUInt64BE;
function readUInt24LE(buf, offset) {
return buf.readUInt8(offset + 2) << 16 | buf.readUInt16LE(offset);
}
module.exports.readUInt24LE = readUInt24LE;
function writeUInt24LE(buf, val, offset) {
val = check_value(val, 0, 0xffffff);
check_bounds(buf, offset, 3);
buf.writeUInt16LE(val & 0xffff, offset);
buf.writeUInt8(val >>> 16, offset + 2);
}
module.exports.writeUInt24LE = writeUInt24LE;
function readUInt40LE(buf, offset) {
return (buf.readUInt8(offset + 4) || 0) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
}
module.exports.readUInt40LE = readUInt40LE;
function writeUInt40LE(buf, val, offset) {
val = check_value(val, 0, 0xffffffffff);
check_bounds(buf, offset, 5);
buf.writeInt32LE(val & -1, offset);
buf.writeUInt8(Math.floor(val * SHIFT_RIGHT_32), offset + 4);
}
module.exports.writeUInt40LE = writeUInt40LE;
function readUInt48LE(buf, offset) {
return buf.readUInt16LE(offset + 4) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
}
module.exports.readUInt48LE = readUInt48LE;
function writeUInt48LE(buf, val, offset) {
val = check_value(val, 0, 0xffffffffffff);
check_bounds(buf, offset, 6);
buf.writeInt32LE(val & -1, offset);
buf.writeUInt16LE(Math.floor(val * SHIFT_RIGHT_32), offset + 4);
}
module.exports.writeUInt48LE = writeUInt48LE;
function readUInt56LE(buf, offset) {
return ((buf.readUInt8(offset + 6) || 0) << 16 | buf.readUInt16LE(offset + 4)) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
}
module.exports.readUInt56LE = readUInt56LE;
function writeUInt56LE(buf, val, offset) {
val = check_value(val, 0, 0xffffffffffffff);
check_bounds(buf, offset, 7);
if (val < 0x100000000000000) {
buf.writeInt32LE(val & -1, offset);
var hi = Math.floor(val * SHIFT_RIGHT_32);
buf.writeUInt16LE(hi & 0xffff, offset + 4);
buf.writeUInt8(hi >>> 16, offset + 6);
} else {
// Special case because 2^56-1 gets rounded up to 2^56
buf[offset] = 0xff;
buf[offset+1] = 0xff;
buf[offset+2] = 0xff;
buf[offset+3] = 0xff;
buf[offset+4] = 0xff;
buf[offset+5] = 0xff;
buf[offset+6] = 0xff;
}
}
module.exports.writeUInt56LE = writeUInt56LE;
function readUInt64LE(buf, offset) {
return buf.readUInt32LE(offset + 4) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
}
module.exports.readUInt64LE = readUInt64LE;
function writeUInt64LE(buf, val, offset) {
val = check_value(val, 0, 0xffffffffffffffff);
check_bounds(buf, offset, 8);
if (val < 0x10000000000000000) {
buf.writeInt32LE(val & -1, offset);
buf.writeUInt32LE(Math.floor(val * SHIFT_RIGHT_32), offset + 4);
} else {
// Special case because 2^64-1 gets rounded up to 2^64
buf[offset] = 0xff;
buf[offset+1] = 0xff;
buf[offset+2] = 0xff;
buf[offset+3] = 0xff;
buf[offset+4] = 0xff;
buf[offset+5] = 0xff;
buf[offset+6] = 0xff;
buf[offset+7] = 0xff;
}
}
module.exports.writeUInt64LE = writeUInt64LE;
function readInt24BE(buf, offset) {
return (buf.readInt8(offset) << 16) + buf.readUInt16BE(offset + 1);
}
module.exports.readInt24BE = readInt24BE;
function writeInt24BE(buf, val, offset) {
val = check_value(val, -0x800000, 0x7fffff);
check_bounds(buf, offset, 3);
buf.writeInt8(val >> 16, offset);
buf.writeUInt16BE(val & 0xffff, offset + 1);
}
module.exports.writeInt24BE = writeInt24BE;
function readInt40BE(buf, offset) {
return (buf.readInt8(offset) || 0) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 1);
}
module.exports.readInt40BE = readInt40BE;
function writeInt40BE(buf, val, offset) {
val = check_value(val, -0x8000000000, 0x7fffffffff);
check_bounds(buf, offset, 5);
buf.writeInt8(Math.floor(val * SHIFT_RIGHT_32), offset);
buf.writeInt32BE(val & -1, offset + 1);
}
module.exports.writeInt40BE = writeInt40BE;
function readInt48BE(buf, offset) {
return buf.readInt16BE(offset) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 2);
}
module.exports.readInt48BE = readInt48BE;
function writeInt48BE(buf, val, offset) {
val = check_value(val, -0x800000000000, 0x7fffffffffff);
check_bounds(buf, offset, 6);
buf.writeInt16BE(Math.floor(val * SHIFT_RIGHT_32), offset);
buf.writeInt32BE(val & -1, offset + 2);
}
module.exports.writeInt48BE = writeInt48BE;
function readInt56BE(buf, offset) {
return (((buf.readInt8(offset) || 0) << 16) + buf.readUInt16BE(offset + 1)) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 3);
}
module.exports.readInt56BE = readInt56BE;
function writeInt56BE(buf, val, offset) {
val = check_value(val, -0x800000000000000, 0x7fffffffffffff);
check_bounds(buf, offset, 7);
if (val < 0x80000000000000) {
var hi = Math.floor(val * SHIFT_RIGHT_32);
buf.writeInt8(hi >> 16, offset);
buf.writeUInt16BE(hi & 0xffff, offset + 1);
buf.writeInt32BE(val & -1, offset + 3);
} else {
// Special case because 2^55-1 gets rounded up to 2^55
buf[offset] = 0x7f;
buf[offset+1] = 0xff;
buf[offset+2] = 0xff;
buf[offset+3] = 0xff;
buf[offset+4] = 0xff;
buf[offset+5] = 0xff;
buf[offset+6] = 0xff;
}
}
module.exports.writeInt56BE = writeInt56BE;
function readInt64BE(buf, offset) {
return buf.readInt32BE(offset) * SHIFT_LEFT_32 + buf.readUInt32BE(offset + 4);
}
module.exports.readInt64BE = readInt64BE;
function writeInt64BE(buf, val, offset) {
val = check_value(val, -0x800000000000000000, 0x7fffffffffffffff);
check_bounds(buf, offset, 8);
if (val < 0x8000000000000000) {
buf.writeInt32BE(Math.floor(val * SHIFT_RIGHT_32), offset);
buf.writeInt32BE(val & -1, offset + 4);
} else {
// Special case because 2^63-1 gets rounded up to 2^63
buf[offset] = 0x7f;
buf[offset+1] = 0xff;
buf[offset+2] = 0xff;
buf[offset+3] = 0xff;
buf[offset+4] = 0xff;
buf[offset+5] = 0xff;
buf[offset+6] = 0xff;
buf[offset+7] = 0xff;
}
}
module.exports.writeInt64BE = writeInt64BE;
function readInt24LE(buf, offset) {
return (buf.readInt8(offset + 2) << 16) + buf.readUInt16LE(offset);
}
module.exports.readInt24LE = readInt24LE;
function writeInt24LE(buf, val, offset) {
val = check_value(val, -0x800000, 0x7fffff);
check_bounds(buf, offset, 3);
buf.writeUInt16LE(val & 0xffff, offset);
buf.writeInt8(val >> 16, offset + 2);
}
module.exports.writeInt24LE = writeInt24LE;
function readInt40LE(buf, offset) {
return (buf.readInt8(offset + 4) || 0) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
}
module.exports.readInt40LE = readInt40LE;
function writeInt40LE(buf, val, offset) {
val = check_value(val, -0x8000000000, 0x7fffffffff);
check_bounds(buf, offset, 5);
buf.writeInt32LE(val & -1, offset);
buf.writeInt8(Math.floor(val * SHIFT_RIGHT_32), offset + 4);
}
module.exports.writeInt40LE = writeInt40LE;
function readInt48LE(buf, offset) {
return buf.readInt16LE(offset + 4) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
}
module.exports.readInt48LE = readInt48LE;
function writeInt48LE(buf, val, offset) {
val = check_value(val, -0x800000000000, 0x7fffffffffff);
check_bounds(buf, offset, 6);
buf.writeInt32LE(val & -1, offset);
buf.writeInt16LE(Math.floor(val * SHIFT_RIGHT_32), offset + 4);
}
module.exports.writeInt48LE = writeInt48LE;
function readInt56LE(buf, offset) {
return (((buf.readInt8(offset + 6) || 0) << 16) + buf.readUInt16LE(offset + 4)) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
}
module.exports.readInt56LE = readInt56LE;
function writeInt56LE(buf, val, offset) {
val = check_value(val, -0x80000000000000, 0x7fffffffffffff);
check_bounds(buf, offset, 7);
if (val < 0x80000000000000) {
buf.writeInt32LE(val & -1, offset);
var hi = Math.floor(val * SHIFT_RIGHT_32);
buf.writeUInt16LE(hi & 0xffff, offset + 4);
buf.writeInt8(hi >> 16, offset + 6);
} else {
// Special case because 2^55-1 gets rounded up to 2^55
buf[offset] = 0xff;
buf[offset+1] = 0xff;
buf[offset+2] = 0xff;
buf[offset+3] = 0xff;
buf[offset+4] = 0xff;
buf[offset+5] = 0xff;
buf[offset+6] = 0x7f;
}
}
module.exports.writeInt56LE = writeInt56LE;
function readInt64LE(buf, offset) {
return buf.readInt32LE(offset + 4) * SHIFT_LEFT_32 + buf.readUInt32LE(offset);
}
module.exports.readInt64LE = readInt64LE;
function writeInt64LE(buf, val, offset) {
val = check_value(val, -0x8000000000000000, 0x7fffffffffffffff);
check_bounds(buf, offset, 8);
if (val < 0x8000000000000000) {
buf.writeInt32LE(val & -1, offset);
buf.writeInt32LE(Math.floor(val * SHIFT_RIGHT_32), offset + 4);
} else {
// Special case because 2^55-1 gets rounded up to 2^55
buf[offset] = 0xff;
buf[offset+1] = 0xff;
buf[offset+2] = 0xff;
buf[offset+3] = 0xff;
buf[offset+4] = 0xff;
buf[offset+5] = 0xff;
buf[offset+6] = 0xff;
buf[offset+7] = 0x7f;
}
}
module.exports.writeInt64LE = writeInt64LE;

19
node_modules/buffer-more-ints/package.json generated vendored Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "buffer-more-ints",
"version": "1.0.0",
"author": "David Wragg <david@wragg.org>",
"description": "Add support for more integer widths to Buffer",
"homepage": "https://github.com/dpw/node-buffer-more-ints",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/dpw/node-buffer-more-ints.git"
},
"main": "buffer-more-ints.js",
"devDependencies": {
"nodeunit": ""
},
"scripts": {
"test": "node ./node_modules/nodeunit/bin/nodeunit buffer-more-ints-tests.js"
}
}

71
node_modules/buffer-more-ints/polyfill.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
'use strict';
var bmi = require('./buffer-more-ints');
Buffer.isContiguousInt = bmi.isContiguousInt;
Buffer.assertContiguousInt = bmi.assertContiguousInt;
['UInt', 'Int'].forEach(function (signed) {
['24', '40', '48', '56', '64'].forEach(function (size) {
['BE', 'LE'].forEach(function (endian) {
var read = 'read' + signed + size + endian;
var reader = bmi[read];
Buffer.prototype[read] = function(offset) {
return reader(this, offset);
};
var write = 'write' + signed + size + endian;
var writer = bmi[write];
Buffer.prototype[write] = function(val, offset) {
writer(this, val, offset);
};
});
});
});
// Buffer.prototype.read{UInt,Int}8 returns undefined if the offset is
// outside of the buffer, unlike for other widths. These functions
// make it consistent with the others.
var consistent_readX8 = {
readUInt8: function (offset) {
return this.readUInt8(offset) || 0;
},
readInt8: function (offset) {
return this.readInt8(offset) || 0;
}
};
function make_accessor(read, prefix, suffix) {
var accessors = [false,
(read ? consistent_readX8 : Buffer.prototype)[prefix + 8]];
for (var i = 16; i <= 64; i += 8) {
accessors.push(Buffer.prototype[prefix + i + suffix]);
}
if (read) {
Buffer.prototype[prefix + suffix] = function (len, offset) {
var reader = accessors[len];
if (reader) {
return reader.call(this, offset);
} else {
throw new Error("Cannot read integer of length " + len);
}
};
} else {
Buffer.prototype[prefix + suffix] = function (len, val, offset) {
var writer = accessors[len];
if (writer) {
return writer.call(this, val, offset);
} else {
throw new Error("Cannot write integer of length " + len);
}
}
}
}
['UInt', 'Int'].forEach(function (t) {
['BE', 'LE'].forEach(function (e) {
make_accessor(true, "read" + t, e);
make_accessor(false, "write" + t, e);
});
});