scratch-vm 5.0.90 → 5.0.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/node/scratch-vm.js +1 -1
- package/dist/web/scratch-vm.js +760 -458
- package/dist/web/scratch-vm.js.map +1 -1
- package/package.json +5 -4
- package/src/playground/benchmark.js +1 -1
- package/webpack.config.js +3 -3
package/dist/web/scratch-vm.js
CHANGED
@@ -34445,89 +34445,88 @@ module.exports = "AAEAAAARAQAABAAQRFNJRwAAAAEAAHTYAAAACEZGVE1flIgzAACYwAAAABxHRE
|
|
34445
34445
|
/*!
|
34446
34446
|
* The buffer module from node.js, for the browser.
|
34447
34447
|
*
|
34448
|
-
* @author Feross Aboukhadijeh <
|
34448
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
34449
34449
|
* @license MIT
|
34450
34450
|
*/
|
34451
34451
|
/* eslint-disable no-proto */
|
34452
34452
|
|
34453
34453
|
|
34454
34454
|
|
34455
|
-
|
34456
|
-
|
34457
|
-
|
34455
|
+
const base64 = __webpack_require__(/*! base64-js */ "./node_modules/buffer/node_modules/base64-js/index.js")
|
34456
|
+
const ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
|
34457
|
+
const customInspectSymbol =
|
34458
|
+
(typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
|
34459
|
+
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
34460
|
+
: null
|
34458
34461
|
|
34459
34462
|
exports.Buffer = Buffer
|
34460
34463
|
exports.SlowBuffer = SlowBuffer
|
34461
34464
|
exports.INSPECT_MAX_BYTES = 50
|
34462
34465
|
|
34466
|
+
const K_MAX_LENGTH = 0x7fffffff
|
34467
|
+
exports.kMaxLength = K_MAX_LENGTH
|
34468
|
+
|
34463
34469
|
/**
|
34464
34470
|
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
34465
34471
|
* === true Use Uint8Array implementation (fastest)
|
34466
|
-
* === false
|
34472
|
+
* === false Print warning and recommend using `buffer` v4.x which has an Object
|
34473
|
+
* implementation (most compatible, even IE6)
|
34467
34474
|
*
|
34468
34475
|
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
34469
34476
|
* Opera 11.6+, iOS 4.2+.
|
34470
34477
|
*
|
34471
|
-
*
|
34472
|
-
*
|
34473
|
-
*
|
34474
|
-
*
|
34475
|
-
*
|
34476
|
-
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
|
34477
|
-
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
|
34478
|
-
*
|
34479
|
-
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
|
34480
|
-
*
|
34481
|
-
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
|
34482
|
-
* incorrect length in some situations.
|
34483
|
-
|
34484
|
-
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
|
34485
|
-
* get the Object implementation, which is slower but behaves correctly.
|
34478
|
+
* We report that the browser does not support typed arrays if the are not subclassable
|
34479
|
+
* using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
|
34480
|
+
* (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
|
34481
|
+
* for __proto__ and has a buggy typed array implementation.
|
34486
34482
|
*/
|
34487
|
-
Buffer.TYPED_ARRAY_SUPPORT =
|
34488
|
-
? __webpack_require__.g.TYPED_ARRAY_SUPPORT
|
34489
|
-
: typedArraySupport()
|
34483
|
+
Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
|
34490
34484
|
|
34491
|
-
|
34492
|
-
|
34493
|
-
|
34494
|
-
|
34485
|
+
if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
|
34486
|
+
typeof console.error === 'function') {
|
34487
|
+
console.error(
|
34488
|
+
'This browser lacks typed array (Uint8Array) support which is required by ' +
|
34489
|
+
'`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
|
34490
|
+
)
|
34491
|
+
}
|
34495
34492
|
|
34496
34493
|
function typedArraySupport () {
|
34494
|
+
// Can typed array instances can be augmented?
|
34497
34495
|
try {
|
34498
|
-
|
34499
|
-
|
34500
|
-
|
34501
|
-
|
34502
|
-
|
34496
|
+
const arr = new Uint8Array(1)
|
34497
|
+
const proto = { foo: function () { return 42 } }
|
34498
|
+
Object.setPrototypeOf(proto, Uint8Array.prototype)
|
34499
|
+
Object.setPrototypeOf(arr, proto)
|
34500
|
+
return arr.foo() === 42
|
34503
34501
|
} catch (e) {
|
34504
34502
|
return false
|
34505
34503
|
}
|
34506
34504
|
}
|
34507
34505
|
|
34508
|
-
|
34509
|
-
|
34510
|
-
|
34511
|
-
|
34512
|
-
|
34513
|
-
|
34514
|
-
function createBuffer (that, length) {
|
34515
|
-
if (kMaxLength() < length) {
|
34516
|
-
throw new RangeError('Invalid typed array length')
|
34506
|
+
Object.defineProperty(Buffer.prototype, 'parent', {
|
34507
|
+
enumerable: true,
|
34508
|
+
get: function () {
|
34509
|
+
if (!Buffer.isBuffer(this)) return undefined
|
34510
|
+
return this.buffer
|
34517
34511
|
}
|
34518
|
-
|
34519
|
-
|
34520
|
-
|
34521
|
-
|
34522
|
-
|
34523
|
-
|
34524
|
-
|
34525
|
-
that = new Buffer(length)
|
34526
|
-
}
|
34527
|
-
that.length = length
|
34512
|
+
})
|
34513
|
+
|
34514
|
+
Object.defineProperty(Buffer.prototype, 'offset', {
|
34515
|
+
enumerable: true,
|
34516
|
+
get: function () {
|
34517
|
+
if (!Buffer.isBuffer(this)) return undefined
|
34518
|
+
return this.byteOffset
|
34528
34519
|
}
|
34520
|
+
})
|
34529
34521
|
|
34530
|
-
|
34522
|
+
function createBuffer (length) {
|
34523
|
+
if (length > K_MAX_LENGTH) {
|
34524
|
+
throw new RangeError('The value "' + length + '" is invalid for option "size"')
|
34525
|
+
}
|
34526
|
+
// Return an augmented `Uint8Array` instance
|
34527
|
+
const buf = new Uint8Array(length)
|
34528
|
+
Object.setPrototypeOf(buf, Buffer.prototype)
|
34529
|
+
return buf
|
34531
34530
|
}
|
34532
34531
|
|
34533
34532
|
/**
|
@@ -34541,44 +34540,70 @@ function createBuffer (that, length) {
|
|
34541
34540
|
*/
|
34542
34541
|
|
34543
34542
|
function Buffer (arg, encodingOrOffset, length) {
|
34544
|
-
if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
|
34545
|
-
return new Buffer(arg, encodingOrOffset, length)
|
34546
|
-
}
|
34547
|
-
|
34548
34543
|
// Common case.
|
34549
34544
|
if (typeof arg === 'number') {
|
34550
34545
|
if (typeof encodingOrOffset === 'string') {
|
34551
|
-
throw new
|
34552
|
-
'
|
34546
|
+
throw new TypeError(
|
34547
|
+
'The "string" argument must be of type string. Received type number'
|
34553
34548
|
)
|
34554
34549
|
}
|
34555
|
-
return allocUnsafe(
|
34550
|
+
return allocUnsafe(arg)
|
34556
34551
|
}
|
34557
|
-
return from(
|
34552
|
+
return from(arg, encodingOrOffset, length)
|
34558
34553
|
}
|
34559
34554
|
|
34560
34555
|
Buffer.poolSize = 8192 // not used by this implementation
|
34561
34556
|
|
34562
|
-
|
34563
|
-
|
34564
|
-
|
34565
|
-
|
34566
|
-
|
34557
|
+
function from (value, encodingOrOffset, length) {
|
34558
|
+
if (typeof value === 'string') {
|
34559
|
+
return fromString(value, encodingOrOffset)
|
34560
|
+
}
|
34561
|
+
|
34562
|
+
if (ArrayBuffer.isView(value)) {
|
34563
|
+
return fromArrayView(value)
|
34564
|
+
}
|
34565
|
+
|
34566
|
+
if (value == null) {
|
34567
|
+
throw new TypeError(
|
34568
|
+
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
34569
|
+
'or Array-like Object. Received type ' + (typeof value)
|
34570
|
+
)
|
34571
|
+
}
|
34572
|
+
|
34573
|
+
if (isInstance(value, ArrayBuffer) ||
|
34574
|
+
(value && isInstance(value.buffer, ArrayBuffer))) {
|
34575
|
+
return fromArrayBuffer(value, encodingOrOffset, length)
|
34576
|
+
}
|
34577
|
+
|
34578
|
+
if (typeof SharedArrayBuffer !== 'undefined' &&
|
34579
|
+
(isInstance(value, SharedArrayBuffer) ||
|
34580
|
+
(value && isInstance(value.buffer, SharedArrayBuffer)))) {
|
34581
|
+
return fromArrayBuffer(value, encodingOrOffset, length)
|
34582
|
+
}
|
34567
34583
|
|
34568
|
-
function from (that, value, encodingOrOffset, length) {
|
34569
34584
|
if (typeof value === 'number') {
|
34570
|
-
throw new TypeError(
|
34585
|
+
throw new TypeError(
|
34586
|
+
'The "value" argument must not be of type number. Received type number'
|
34587
|
+
)
|
34571
34588
|
}
|
34572
34589
|
|
34573
|
-
|
34574
|
-
|
34590
|
+
const valueOf = value.valueOf && value.valueOf()
|
34591
|
+
if (valueOf != null && valueOf !== value) {
|
34592
|
+
return Buffer.from(valueOf, encodingOrOffset, length)
|
34575
34593
|
}
|
34576
34594
|
|
34577
|
-
|
34578
|
-
|
34595
|
+
const b = fromObject(value)
|
34596
|
+
if (b) return b
|
34597
|
+
|
34598
|
+
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
|
34599
|
+
typeof value[Symbol.toPrimitive] === 'function') {
|
34600
|
+
return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)
|
34579
34601
|
}
|
34580
34602
|
|
34581
|
-
|
34603
|
+
throw new TypeError(
|
34604
|
+
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
34605
|
+
'or Array-like Object. Received type ' + (typeof value)
|
34606
|
+
)
|
34582
34607
|
}
|
34583
34608
|
|
34584
34609
|
/**
|
@@ -34590,44 +34615,36 @@ function from (that, value, encodingOrOffset, length) {
|
|
34590
34615
|
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
34591
34616
|
**/
|
34592
34617
|
Buffer.from = function (value, encodingOrOffset, length) {
|
34593
|
-
return from(
|
34594
|
-
}
|
34595
|
-
|
34596
|
-
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
34597
|
-
Buffer.prototype.__proto__ = Uint8Array.prototype
|
34598
|
-
Buffer.__proto__ = Uint8Array
|
34599
|
-
if (typeof Symbol !== 'undefined' && Symbol.species &&
|
34600
|
-
Buffer[Symbol.species] === Buffer) {
|
34601
|
-
// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
|
34602
|
-
Object.defineProperty(Buffer, Symbol.species, {
|
34603
|
-
value: null,
|
34604
|
-
configurable: true
|
34605
|
-
})
|
34606
|
-
}
|
34618
|
+
return from(value, encodingOrOffset, length)
|
34607
34619
|
}
|
34608
34620
|
|
34621
|
+
// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
|
34622
|
+
// https://github.com/feross/buffer/pull/148
|
34623
|
+
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)
|
34624
|
+
Object.setPrototypeOf(Buffer, Uint8Array)
|
34625
|
+
|
34609
34626
|
function assertSize (size) {
|
34610
34627
|
if (typeof size !== 'number') {
|
34611
|
-
throw new TypeError('"size" argument must be
|
34628
|
+
throw new TypeError('"size" argument must be of type number')
|
34612
34629
|
} else if (size < 0) {
|
34613
|
-
throw new RangeError('"size"
|
34630
|
+
throw new RangeError('The value "' + size + '" is invalid for option "size"')
|
34614
34631
|
}
|
34615
34632
|
}
|
34616
34633
|
|
34617
|
-
function alloc (
|
34634
|
+
function alloc (size, fill, encoding) {
|
34618
34635
|
assertSize(size)
|
34619
34636
|
if (size <= 0) {
|
34620
|
-
return createBuffer(
|
34637
|
+
return createBuffer(size)
|
34621
34638
|
}
|
34622
34639
|
if (fill !== undefined) {
|
34623
34640
|
// Only pay attention to encoding if it's a string. This
|
34624
34641
|
// prevents accidentally sending in a number that would
|
34625
|
-
// be
|
34642
|
+
// be interpreted as a start offset.
|
34626
34643
|
return typeof encoding === 'string'
|
34627
|
-
? createBuffer(
|
34628
|
-
: createBuffer(
|
34644
|
+
? createBuffer(size).fill(fill, encoding)
|
34645
|
+
: createBuffer(size).fill(fill)
|
34629
34646
|
}
|
34630
|
-
return createBuffer(
|
34647
|
+
return createBuffer(size)
|
34631
34648
|
}
|
34632
34649
|
|
34633
34650
|
/**
|
@@ -34635,132 +34652,123 @@ function alloc (that, size, fill, encoding) {
|
|
34635
34652
|
* alloc(size[, fill[, encoding]])
|
34636
34653
|
**/
|
34637
34654
|
Buffer.alloc = function (size, fill, encoding) {
|
34638
|
-
return alloc(
|
34655
|
+
return alloc(size, fill, encoding)
|
34639
34656
|
}
|
34640
34657
|
|
34641
|
-
function allocUnsafe (
|
34658
|
+
function allocUnsafe (size) {
|
34642
34659
|
assertSize(size)
|
34643
|
-
|
34644
|
-
if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
34645
|
-
for (var i = 0; i < size; ++i) {
|
34646
|
-
that[i] = 0
|
34647
|
-
}
|
34648
|
-
}
|
34649
|
-
return that
|
34660
|
+
return createBuffer(size < 0 ? 0 : checked(size) | 0)
|
34650
34661
|
}
|
34651
34662
|
|
34652
34663
|
/**
|
34653
34664
|
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
34654
34665
|
* */
|
34655
34666
|
Buffer.allocUnsafe = function (size) {
|
34656
|
-
return allocUnsafe(
|
34667
|
+
return allocUnsafe(size)
|
34657
34668
|
}
|
34658
34669
|
/**
|
34659
34670
|
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
34660
34671
|
*/
|
34661
34672
|
Buffer.allocUnsafeSlow = function (size) {
|
34662
|
-
return allocUnsafe(
|
34673
|
+
return allocUnsafe(size)
|
34663
34674
|
}
|
34664
34675
|
|
34665
|
-
function fromString (
|
34676
|
+
function fromString (string, encoding) {
|
34666
34677
|
if (typeof encoding !== 'string' || encoding === '') {
|
34667
34678
|
encoding = 'utf8'
|
34668
34679
|
}
|
34669
34680
|
|
34670
34681
|
if (!Buffer.isEncoding(encoding)) {
|
34671
|
-
throw new TypeError('
|
34682
|
+
throw new TypeError('Unknown encoding: ' + encoding)
|
34672
34683
|
}
|
34673
34684
|
|
34674
|
-
|
34675
|
-
|
34685
|
+
const length = byteLength(string, encoding) | 0
|
34686
|
+
let buf = createBuffer(length)
|
34676
34687
|
|
34677
|
-
|
34688
|
+
const actual = buf.write(string, encoding)
|
34678
34689
|
|
34679
34690
|
if (actual !== length) {
|
34680
34691
|
// Writing a hex string, for example, that contains invalid characters will
|
34681
34692
|
// cause everything after the first invalid character to be ignored. (e.g.
|
34682
34693
|
// 'abxxcd' will be treated as 'ab')
|
34683
|
-
|
34694
|
+
buf = buf.slice(0, actual)
|
34684
34695
|
}
|
34685
34696
|
|
34686
|
-
return
|
34697
|
+
return buf
|
34687
34698
|
}
|
34688
34699
|
|
34689
|
-
function fromArrayLike (
|
34690
|
-
|
34691
|
-
|
34692
|
-
for (
|
34693
|
-
|
34700
|
+
function fromArrayLike (array) {
|
34701
|
+
const length = array.length < 0 ? 0 : checked(array.length) | 0
|
34702
|
+
const buf = createBuffer(length)
|
34703
|
+
for (let i = 0; i < length; i += 1) {
|
34704
|
+
buf[i] = array[i] & 255
|
34694
34705
|
}
|
34695
|
-
return
|
34706
|
+
return buf
|
34696
34707
|
}
|
34697
34708
|
|
34698
|
-
function
|
34699
|
-
|
34709
|
+
function fromArrayView (arrayView) {
|
34710
|
+
if (isInstance(arrayView, Uint8Array)) {
|
34711
|
+
const copy = new Uint8Array(arrayView)
|
34712
|
+
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
|
34713
|
+
}
|
34714
|
+
return fromArrayLike(arrayView)
|
34715
|
+
}
|
34700
34716
|
|
34717
|
+
function fromArrayBuffer (array, byteOffset, length) {
|
34701
34718
|
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
34702
|
-
throw new RangeError('
|
34719
|
+
throw new RangeError('"offset" is outside of buffer bounds')
|
34703
34720
|
}
|
34704
34721
|
|
34705
34722
|
if (array.byteLength < byteOffset + (length || 0)) {
|
34706
|
-
throw new RangeError('
|
34723
|
+
throw new RangeError('"length" is outside of buffer bounds')
|
34707
34724
|
}
|
34708
34725
|
|
34726
|
+
let buf
|
34709
34727
|
if (byteOffset === undefined && length === undefined) {
|
34710
|
-
|
34728
|
+
buf = new Uint8Array(array)
|
34711
34729
|
} else if (length === undefined) {
|
34712
|
-
|
34730
|
+
buf = new Uint8Array(array, byteOffset)
|
34713
34731
|
} else {
|
34714
|
-
|
34732
|
+
buf = new Uint8Array(array, byteOffset, length)
|
34715
34733
|
}
|
34716
34734
|
|
34717
|
-
|
34718
|
-
|
34719
|
-
|
34720
|
-
|
34721
|
-
} else {
|
34722
|
-
// Fallback: Return an object instance of the Buffer class
|
34723
|
-
that = fromArrayLike(that, array)
|
34724
|
-
}
|
34725
|
-
return that
|
34735
|
+
// Return an augmented `Uint8Array` instance
|
34736
|
+
Object.setPrototypeOf(buf, Buffer.prototype)
|
34737
|
+
|
34738
|
+
return buf
|
34726
34739
|
}
|
34727
34740
|
|
34728
|
-
function fromObject (
|
34741
|
+
function fromObject (obj) {
|
34729
34742
|
if (Buffer.isBuffer(obj)) {
|
34730
|
-
|
34731
|
-
|
34743
|
+
const len = checked(obj.length) | 0
|
34744
|
+
const buf = createBuffer(len)
|
34732
34745
|
|
34733
|
-
if (
|
34734
|
-
return
|
34746
|
+
if (buf.length === 0) {
|
34747
|
+
return buf
|
34735
34748
|
}
|
34736
34749
|
|
34737
|
-
obj.copy(
|
34738
|
-
return
|
34750
|
+
obj.copy(buf, 0, 0, len)
|
34751
|
+
return buf
|
34739
34752
|
}
|
34740
34753
|
|
34741
|
-
if (obj) {
|
34742
|
-
if (
|
34743
|
-
|
34744
|
-
if (typeof obj.length !== 'number' || isnan(obj.length)) {
|
34745
|
-
return createBuffer(that, 0)
|
34746
|
-
}
|
34747
|
-
return fromArrayLike(that, obj)
|
34748
|
-
}
|
34749
|
-
|
34750
|
-
if (obj.type === 'Buffer' && isArray(obj.data)) {
|
34751
|
-
return fromArrayLike(that, obj.data)
|
34754
|
+
if (obj.length !== undefined) {
|
34755
|
+
if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
|
34756
|
+
return createBuffer(0)
|
34752
34757
|
}
|
34758
|
+
return fromArrayLike(obj)
|
34753
34759
|
}
|
34754
34760
|
|
34755
|
-
|
34761
|
+
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
|
34762
|
+
return fromArrayLike(obj.data)
|
34763
|
+
}
|
34756
34764
|
}
|
34757
34765
|
|
34758
34766
|
function checked (length) {
|
34759
|
-
// Note: cannot use `length <
|
34767
|
+
// Note: cannot use `length < K_MAX_LENGTH` here because that fails when
|
34760
34768
|
// length is NaN (which is otherwise coerced to zero.)
|
34761
|
-
if (length >=
|
34769
|
+
if (length >= K_MAX_LENGTH) {
|
34762
34770
|
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
34763
|
-
'size: 0x' +
|
34771
|
+
'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
|
34764
34772
|
}
|
34765
34773
|
return length | 0
|
34766
34774
|
}
|
@@ -34773,20 +34781,25 @@ function SlowBuffer (length) {
|
|
34773
34781
|
}
|
34774
34782
|
|
34775
34783
|
Buffer.isBuffer = function isBuffer (b) {
|
34776
|
-
return
|
34784
|
+
return b != null && b._isBuffer === true &&
|
34785
|
+
b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
|
34777
34786
|
}
|
34778
34787
|
|
34779
34788
|
Buffer.compare = function compare (a, b) {
|
34789
|
+
if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
|
34790
|
+
if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
|
34780
34791
|
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
34781
|
-
throw new TypeError(
|
34792
|
+
throw new TypeError(
|
34793
|
+
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
34794
|
+
)
|
34782
34795
|
}
|
34783
34796
|
|
34784
34797
|
if (a === b) return 0
|
34785
34798
|
|
34786
|
-
|
34787
|
-
|
34799
|
+
let x = a.length
|
34800
|
+
let y = b.length
|
34788
34801
|
|
34789
|
-
for (
|
34802
|
+
for (let i = 0, len = Math.min(x, y); i < len; ++i) {
|
34790
34803
|
if (a[i] !== b[i]) {
|
34791
34804
|
x = a[i]
|
34792
34805
|
y = b[i]
|
@@ -34819,7 +34832,7 @@ Buffer.isEncoding = function isEncoding (encoding) {
|
|
34819
34832
|
}
|
34820
34833
|
|
34821
34834
|
Buffer.concat = function concat (list, length) {
|
34822
|
-
if (!isArray(list)) {
|
34835
|
+
if (!Array.isArray(list)) {
|
34823
34836
|
throw new TypeError('"list" argument must be an Array of Buffers')
|
34824
34837
|
}
|
34825
34838
|
|
@@ -34827,7 +34840,7 @@ Buffer.concat = function concat (list, length) {
|
|
34827
34840
|
return Buffer.alloc(0)
|
34828
34841
|
}
|
34829
34842
|
|
34830
|
-
|
34843
|
+
let i
|
34831
34844
|
if (length === undefined) {
|
34832
34845
|
length = 0
|
34833
34846
|
for (i = 0; i < list.length; ++i) {
|
@@ -34835,14 +34848,26 @@ Buffer.concat = function concat (list, length) {
|
|
34835
34848
|
}
|
34836
34849
|
}
|
34837
34850
|
|
34838
|
-
|
34839
|
-
|
34851
|
+
const buffer = Buffer.allocUnsafe(length)
|
34852
|
+
let pos = 0
|
34840
34853
|
for (i = 0; i < list.length; ++i) {
|
34841
|
-
|
34842
|
-
if (
|
34854
|
+
let buf = list[i]
|
34855
|
+
if (isInstance(buf, Uint8Array)) {
|
34856
|
+
if (pos + buf.length > buffer.length) {
|
34857
|
+
if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)
|
34858
|
+
buf.copy(buffer, pos)
|
34859
|
+
} else {
|
34860
|
+
Uint8Array.prototype.set.call(
|
34861
|
+
buffer,
|
34862
|
+
buf,
|
34863
|
+
pos
|
34864
|
+
)
|
34865
|
+
}
|
34866
|
+
} else if (!Buffer.isBuffer(buf)) {
|
34843
34867
|
throw new TypeError('"list" argument must be an Array of Buffers')
|
34868
|
+
} else {
|
34869
|
+
buf.copy(buffer, pos)
|
34844
34870
|
}
|
34845
|
-
buf.copy(buffer, pos)
|
34846
34871
|
pos += buf.length
|
34847
34872
|
}
|
34848
34873
|
return buffer
|
@@ -34852,19 +34877,22 @@ function byteLength (string, encoding) {
|
|
34852
34877
|
if (Buffer.isBuffer(string)) {
|
34853
34878
|
return string.length
|
34854
34879
|
}
|
34855
|
-
if (
|
34856
|
-
(ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
|
34880
|
+
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
34857
34881
|
return string.byteLength
|
34858
34882
|
}
|
34859
34883
|
if (typeof string !== 'string') {
|
34860
|
-
|
34884
|
+
throw new TypeError(
|
34885
|
+
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
|
34886
|
+
'Received type ' + typeof string
|
34887
|
+
)
|
34861
34888
|
}
|
34862
34889
|
|
34863
|
-
|
34864
|
-
|
34890
|
+
const len = string.length
|
34891
|
+
const mustMatch = (arguments.length > 2 && arguments[2] === true)
|
34892
|
+
if (!mustMatch && len === 0) return 0
|
34865
34893
|
|
34866
34894
|
// Use a for loop to avoid recursion
|
34867
|
-
|
34895
|
+
let loweredCase = false
|
34868
34896
|
for (;;) {
|
34869
34897
|
switch (encoding) {
|
34870
34898
|
case 'ascii':
|
@@ -34873,7 +34901,6 @@ function byteLength (string, encoding) {
|
|
34873
34901
|
return len
|
34874
34902
|
case 'utf8':
|
34875
34903
|
case 'utf-8':
|
34876
|
-
case undefined:
|
34877
34904
|
return utf8ToBytes(string).length
|
34878
34905
|
case 'ucs2':
|
34879
34906
|
case 'ucs-2':
|
@@ -34885,7 +34912,9 @@ function byteLength (string, encoding) {
|
|
34885
34912
|
case 'base64':
|
34886
34913
|
return base64ToBytes(string).length
|
34887
34914
|
default:
|
34888
|
-
if (loweredCase)
|
34915
|
+
if (loweredCase) {
|
34916
|
+
return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
|
34917
|
+
}
|
34889
34918
|
encoding = ('' + encoding).toLowerCase()
|
34890
34919
|
loweredCase = true
|
34891
34920
|
}
|
@@ -34894,7 +34923,7 @@ function byteLength (string, encoding) {
|
|
34894
34923
|
Buffer.byteLength = byteLength
|
34895
34924
|
|
34896
34925
|
function slowToString (encoding, start, end) {
|
34897
|
-
|
34926
|
+
let loweredCase = false
|
34898
34927
|
|
34899
34928
|
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
|
34900
34929
|
// property of a typed array.
|
@@ -34920,7 +34949,7 @@ function slowToString (encoding, start, end) {
|
|
34920
34949
|
return ''
|
34921
34950
|
}
|
34922
34951
|
|
34923
|
-
// Force
|
34952
|
+
// Force coercion to uint32. This will also coerce falsey/NaN values to 0.
|
34924
34953
|
end >>>= 0
|
34925
34954
|
start >>>= 0
|
34926
34955
|
|
@@ -34963,33 +34992,37 @@ function slowToString (encoding, start, end) {
|
|
34963
34992
|
}
|
34964
34993
|
}
|
34965
34994
|
|
34966
|
-
//
|
34967
|
-
// Buffer
|
34995
|
+
// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
|
34996
|
+
// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
|
34997
|
+
// reliably in a browserify context because there could be multiple different
|
34998
|
+
// copies of the 'buffer' package in use. This method works even for Buffer
|
34999
|
+
// instances that were created from another copy of the `buffer` package.
|
35000
|
+
// See: https://github.com/feross/buffer/issues/154
|
34968
35001
|
Buffer.prototype._isBuffer = true
|
34969
35002
|
|
34970
35003
|
function swap (b, n, m) {
|
34971
|
-
|
35004
|
+
const i = b[n]
|
34972
35005
|
b[n] = b[m]
|
34973
35006
|
b[m] = i
|
34974
35007
|
}
|
34975
35008
|
|
34976
35009
|
Buffer.prototype.swap16 = function swap16 () {
|
34977
|
-
|
35010
|
+
const len = this.length
|
34978
35011
|
if (len % 2 !== 0) {
|
34979
35012
|
throw new RangeError('Buffer size must be a multiple of 16-bits')
|
34980
35013
|
}
|
34981
|
-
for (
|
35014
|
+
for (let i = 0; i < len; i += 2) {
|
34982
35015
|
swap(this, i, i + 1)
|
34983
35016
|
}
|
34984
35017
|
return this
|
34985
35018
|
}
|
34986
35019
|
|
34987
35020
|
Buffer.prototype.swap32 = function swap32 () {
|
34988
|
-
|
35021
|
+
const len = this.length
|
34989
35022
|
if (len % 4 !== 0) {
|
34990
35023
|
throw new RangeError('Buffer size must be a multiple of 32-bits')
|
34991
35024
|
}
|
34992
|
-
for (
|
35025
|
+
for (let i = 0; i < len; i += 4) {
|
34993
35026
|
swap(this, i, i + 3)
|
34994
35027
|
swap(this, i + 1, i + 2)
|
34995
35028
|
}
|
@@ -34997,11 +35030,11 @@ Buffer.prototype.swap32 = function swap32 () {
|
|
34997
35030
|
}
|
34998
35031
|
|
34999
35032
|
Buffer.prototype.swap64 = function swap64 () {
|
35000
|
-
|
35033
|
+
const len = this.length
|
35001
35034
|
if (len % 8 !== 0) {
|
35002
35035
|
throw new RangeError('Buffer size must be a multiple of 64-bits')
|
35003
35036
|
}
|
35004
|
-
for (
|
35037
|
+
for (let i = 0; i < len; i += 8) {
|
35005
35038
|
swap(this, i, i + 7)
|
35006
35039
|
swap(this, i + 1, i + 6)
|
35007
35040
|
swap(this, i + 2, i + 5)
|
@@ -35011,12 +35044,14 @@ Buffer.prototype.swap64 = function swap64 () {
|
|
35011
35044
|
}
|
35012
35045
|
|
35013
35046
|
Buffer.prototype.toString = function toString () {
|
35014
|
-
|
35047
|
+
const length = this.length
|
35015
35048
|
if (length === 0) return ''
|
35016
35049
|
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
35017
35050
|
return slowToString.apply(this, arguments)
|
35018
35051
|
}
|
35019
35052
|
|
35053
|
+
Buffer.prototype.toLocaleString = Buffer.prototype.toString
|
35054
|
+
|
35020
35055
|
Buffer.prototype.equals = function equals (b) {
|
35021
35056
|
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
35022
35057
|
if (this === b) return true
|
@@ -35024,18 +35059,25 @@ Buffer.prototype.equals = function equals (b) {
|
|
35024
35059
|
}
|
35025
35060
|
|
35026
35061
|
Buffer.prototype.inspect = function inspect () {
|
35027
|
-
|
35028
|
-
|
35029
|
-
|
35030
|
-
|
35031
|
-
if (this.length > max) str += ' ... '
|
35032
|
-
}
|
35062
|
+
let str = ''
|
35063
|
+
const max = exports.INSPECT_MAX_BYTES
|
35064
|
+
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
|
35065
|
+
if (this.length > max) str += ' ... '
|
35033
35066
|
return '<Buffer ' + str + '>'
|
35034
35067
|
}
|
35068
|
+
if (customInspectSymbol) {
|
35069
|
+
Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect
|
35070
|
+
}
|
35035
35071
|
|
35036
35072
|
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
35073
|
+
if (isInstance(target, Uint8Array)) {
|
35074
|
+
target = Buffer.from(target, target.offset, target.byteLength)
|
35075
|
+
}
|
35037
35076
|
if (!Buffer.isBuffer(target)) {
|
35038
|
-
throw new TypeError(
|
35077
|
+
throw new TypeError(
|
35078
|
+
'The "target" argument must be one of type Buffer or Uint8Array. ' +
|
35079
|
+
'Received type ' + (typeof target)
|
35080
|
+
)
|
35039
35081
|
}
|
35040
35082
|
|
35041
35083
|
if (start === undefined) {
|
@@ -35072,14 +35114,14 @@ Buffer.prototype.compare = function compare (target, start, end, thisStart, this
|
|
35072
35114
|
|
35073
35115
|
if (this === target) return 0
|
35074
35116
|
|
35075
|
-
|
35076
|
-
|
35077
|
-
|
35117
|
+
let x = thisEnd - thisStart
|
35118
|
+
let y = end - start
|
35119
|
+
const len = Math.min(x, y)
|
35078
35120
|
|
35079
|
-
|
35080
|
-
|
35121
|
+
const thisCopy = this.slice(thisStart, thisEnd)
|
35122
|
+
const targetCopy = target.slice(start, end)
|
35081
35123
|
|
35082
|
-
for (
|
35124
|
+
for (let i = 0; i < len; ++i) {
|
35083
35125
|
if (thisCopy[i] !== targetCopy[i]) {
|
35084
35126
|
x = thisCopy[i]
|
35085
35127
|
y = targetCopy[i]
|
@@ -35114,8 +35156,8 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
|
35114
35156
|
} else if (byteOffset < -0x80000000) {
|
35115
35157
|
byteOffset = -0x80000000
|
35116
35158
|
}
|
35117
|
-
byteOffset = +byteOffset
|
35118
|
-
if (
|
35159
|
+
byteOffset = +byteOffset // Coerce to Number.
|
35160
|
+
if (numberIsNaN(byteOffset)) {
|
35119
35161
|
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
35120
35162
|
byteOffset = dir ? 0 : (buffer.length - 1)
|
35121
35163
|
}
|
@@ -35144,24 +35186,23 @@ function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
|
35144
35186
|
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
|
35145
35187
|
} else if (typeof val === 'number') {
|
35146
35188
|
val = val & 0xFF // Search for a byte value [0-255]
|
35147
|
-
if (
|
35148
|
-
typeof Uint8Array.prototype.indexOf === 'function') {
|
35189
|
+
if (typeof Uint8Array.prototype.indexOf === 'function') {
|
35149
35190
|
if (dir) {
|
35150
35191
|
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
|
35151
35192
|
} else {
|
35152
35193
|
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
35153
35194
|
}
|
35154
35195
|
}
|
35155
|
-
return arrayIndexOf(buffer, [
|
35196
|
+
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
|
35156
35197
|
}
|
35157
35198
|
|
35158
35199
|
throw new TypeError('val must be string, number or Buffer')
|
35159
35200
|
}
|
35160
35201
|
|
35161
35202
|
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
35162
|
-
|
35163
|
-
|
35164
|
-
|
35203
|
+
let indexSize = 1
|
35204
|
+
let arrLength = arr.length
|
35205
|
+
let valLength = val.length
|
35165
35206
|
|
35166
35207
|
if (encoding !== undefined) {
|
35167
35208
|
encoding = String(encoding).toLowerCase()
|
@@ -35185,9 +35226,9 @@ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
|
35185
35226
|
}
|
35186
35227
|
}
|
35187
35228
|
|
35188
|
-
|
35229
|
+
let i
|
35189
35230
|
if (dir) {
|
35190
|
-
|
35231
|
+
let foundIndex = -1
|
35191
35232
|
for (i = byteOffset; i < arrLength; i++) {
|
35192
35233
|
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
35193
35234
|
if (foundIndex === -1) foundIndex = i
|
@@ -35200,8 +35241,8 @@ function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
|
35200
35241
|
} else {
|
35201
35242
|
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
|
35202
35243
|
for (i = byteOffset; i >= 0; i--) {
|
35203
|
-
|
35204
|
-
for (
|
35244
|
+
let found = true
|
35245
|
+
for (let j = 0; j < valLength; j++) {
|
35205
35246
|
if (read(arr, i + j) !== read(val, j)) {
|
35206
35247
|
found = false
|
35207
35248
|
break
|
@@ -35228,7 +35269,7 @@ Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding)
|
|
35228
35269
|
|
35229
35270
|
function hexWrite (buf, string, offset, length) {
|
35230
35271
|
offset = Number(offset) || 0
|
35231
|
-
|
35272
|
+
const remaining = buf.length - offset
|
35232
35273
|
if (!length) {
|
35233
35274
|
length = remaining
|
35234
35275
|
} else {
|
@@ -35238,16 +35279,15 @@ function hexWrite (buf, string, offset, length) {
|
|
35238
35279
|
}
|
35239
35280
|
}
|
35240
35281
|
|
35241
|
-
|
35242
|
-
var strLen = string.length
|
35243
|
-
if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
|
35282
|
+
const strLen = string.length
|
35244
35283
|
|
35245
35284
|
if (length > strLen / 2) {
|
35246
35285
|
length = strLen / 2
|
35247
35286
|
}
|
35248
|
-
|
35249
|
-
|
35250
|
-
|
35287
|
+
let i
|
35288
|
+
for (i = 0; i < length; ++i) {
|
35289
|
+
const parsed = parseInt(string.substr(i * 2, 2), 16)
|
35290
|
+
if (numberIsNaN(parsed)) return i
|
35251
35291
|
buf[offset + i] = parsed
|
35252
35292
|
}
|
35253
35293
|
return i
|
@@ -35261,10 +35301,6 @@ function asciiWrite (buf, string, offset, length) {
|
|
35261
35301
|
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
35262
35302
|
}
|
35263
35303
|
|
35264
|
-
function latin1Write (buf, string, offset, length) {
|
35265
|
-
return asciiWrite(buf, string, offset, length)
|
35266
|
-
}
|
35267
|
-
|
35268
35304
|
function base64Write (buf, string, offset, length) {
|
35269
35305
|
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
35270
35306
|
}
|
@@ -35286,22 +35322,21 @@ Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
35286
35322
|
offset = 0
|
35287
35323
|
// Buffer#write(string, offset[, length][, encoding])
|
35288
35324
|
} else if (isFinite(offset)) {
|
35289
|
-
offset = offset
|
35325
|
+
offset = offset >>> 0
|
35290
35326
|
if (isFinite(length)) {
|
35291
|
-
length = length
|
35327
|
+
length = length >>> 0
|
35292
35328
|
if (encoding === undefined) encoding = 'utf8'
|
35293
35329
|
} else {
|
35294
35330
|
encoding = length
|
35295
35331
|
length = undefined
|
35296
35332
|
}
|
35297
|
-
// legacy write(string, encoding, offset, length) - remove in v0.13
|
35298
35333
|
} else {
|
35299
35334
|
throw new Error(
|
35300
35335
|
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
35301
35336
|
)
|
35302
35337
|
}
|
35303
35338
|
|
35304
|
-
|
35339
|
+
const remaining = this.length - offset
|
35305
35340
|
if (length === undefined || length > remaining) length = remaining
|
35306
35341
|
|
35307
35342
|
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
@@ -35310,7 +35345,7 @@ Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
35310
35345
|
|
35311
35346
|
if (!encoding) encoding = 'utf8'
|
35312
35347
|
|
35313
|
-
|
35348
|
+
let loweredCase = false
|
35314
35349
|
for (;;) {
|
35315
35350
|
switch (encoding) {
|
35316
35351
|
case 'hex':
|
@@ -35321,11 +35356,9 @@ Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
35321
35356
|
return utf8Write(this, string, offset, length)
|
35322
35357
|
|
35323
35358
|
case 'ascii':
|
35324
|
-
return asciiWrite(this, string, offset, length)
|
35325
|
-
|
35326
35359
|
case 'latin1':
|
35327
35360
|
case 'binary':
|
35328
|
-
return
|
35361
|
+
return asciiWrite(this, string, offset, length)
|
35329
35362
|
|
35330
35363
|
case 'base64':
|
35331
35364
|
// Warning: maxLength not taken into account in base64Write
|
@@ -35362,19 +35395,22 @@ function base64Slice (buf, start, end) {
|
|
35362
35395
|
|
35363
35396
|
function utf8Slice (buf, start, end) {
|
35364
35397
|
end = Math.min(buf.length, end)
|
35365
|
-
|
35398
|
+
const res = []
|
35366
35399
|
|
35367
|
-
|
35400
|
+
let i = start
|
35368
35401
|
while (i < end) {
|
35369
|
-
|
35370
|
-
|
35371
|
-
|
35372
|
-
|
35373
|
-
: (firstByte >
|
35374
|
-
|
35402
|
+
const firstByte = buf[i]
|
35403
|
+
let codePoint = null
|
35404
|
+
let bytesPerSequence = (firstByte > 0xEF)
|
35405
|
+
? 4
|
35406
|
+
: (firstByte > 0xDF)
|
35407
|
+
? 3
|
35408
|
+
: (firstByte > 0xBF)
|
35409
|
+
? 2
|
35410
|
+
: 1
|
35375
35411
|
|
35376
35412
|
if (i + bytesPerSequence <= end) {
|
35377
|
-
|
35413
|
+
let secondByte, thirdByte, fourthByte, tempCodePoint
|
35378
35414
|
|
35379
35415
|
switch (bytesPerSequence) {
|
35380
35416
|
case 1:
|
@@ -35436,17 +35472,17 @@ function utf8Slice (buf, start, end) {
|
|
35436
35472
|
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
35437
35473
|
// the lowest limit is Chrome, with 0x10000 args.
|
35438
35474
|
// We go 1 magnitude less, for safety
|
35439
|
-
|
35475
|
+
const MAX_ARGUMENTS_LENGTH = 0x1000
|
35440
35476
|
|
35441
35477
|
function decodeCodePointsArray (codePoints) {
|
35442
|
-
|
35478
|
+
const len = codePoints.length
|
35443
35479
|
if (len <= MAX_ARGUMENTS_LENGTH) {
|
35444
35480
|
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
35445
35481
|
}
|
35446
35482
|
|
35447
35483
|
// Decode in chunks to avoid "call stack size exceeded".
|
35448
|
-
|
35449
|
-
|
35484
|
+
let res = ''
|
35485
|
+
let i = 0
|
35450
35486
|
while (i < len) {
|
35451
35487
|
res += String.fromCharCode.apply(
|
35452
35488
|
String,
|
@@ -35457,49 +35493,50 @@ function decodeCodePointsArray (codePoints) {
|
|
35457
35493
|
}
|
35458
35494
|
|
35459
35495
|
function asciiSlice (buf, start, end) {
|
35460
|
-
|
35496
|
+
let ret = ''
|
35461
35497
|
end = Math.min(buf.length, end)
|
35462
35498
|
|
35463
|
-
for (
|
35499
|
+
for (let i = start; i < end; ++i) {
|
35464
35500
|
ret += String.fromCharCode(buf[i] & 0x7F)
|
35465
35501
|
}
|
35466
35502
|
return ret
|
35467
35503
|
}
|
35468
35504
|
|
35469
35505
|
function latin1Slice (buf, start, end) {
|
35470
|
-
|
35506
|
+
let ret = ''
|
35471
35507
|
end = Math.min(buf.length, end)
|
35472
35508
|
|
35473
|
-
for (
|
35509
|
+
for (let i = start; i < end; ++i) {
|
35474
35510
|
ret += String.fromCharCode(buf[i])
|
35475
35511
|
}
|
35476
35512
|
return ret
|
35477
35513
|
}
|
35478
35514
|
|
35479
35515
|
function hexSlice (buf, start, end) {
|
35480
|
-
|
35516
|
+
const len = buf.length
|
35481
35517
|
|
35482
35518
|
if (!start || start < 0) start = 0
|
35483
35519
|
if (!end || end < 0 || end > len) end = len
|
35484
35520
|
|
35485
|
-
|
35486
|
-
for (
|
35487
|
-
out +=
|
35521
|
+
let out = ''
|
35522
|
+
for (let i = start; i < end; ++i) {
|
35523
|
+
out += hexSliceLookupTable[buf[i]]
|
35488
35524
|
}
|
35489
35525
|
return out
|
35490
35526
|
}
|
35491
35527
|
|
35492
35528
|
function utf16leSlice (buf, start, end) {
|
35493
|
-
|
35494
|
-
|
35495
|
-
|
35496
|
-
|
35529
|
+
const bytes = buf.slice(start, end)
|
35530
|
+
let res = ''
|
35531
|
+
// If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
|
35532
|
+
for (let i = 0; i < bytes.length - 1; i += 2) {
|
35533
|
+
res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
|
35497
35534
|
}
|
35498
35535
|
return res
|
35499
35536
|
}
|
35500
35537
|
|
35501
35538
|
Buffer.prototype.slice = function slice (start, end) {
|
35502
|
-
|
35539
|
+
const len = this.length
|
35503
35540
|
start = ~~start
|
35504
35541
|
end = end === undefined ? len : ~~end
|
35505
35542
|
|
@@ -35519,17 +35556,9 @@ Buffer.prototype.slice = function slice (start, end) {
|
|
35519
35556
|
|
35520
35557
|
if (end < start) end = start
|
35521
35558
|
|
35522
|
-
|
35523
|
-
|
35524
|
-
|
35525
|
-
newBuf.__proto__ = Buffer.prototype
|
35526
|
-
} else {
|
35527
|
-
var sliceLen = end - start
|
35528
|
-
newBuf = new Buffer(sliceLen, undefined)
|
35529
|
-
for (var i = 0; i < sliceLen; ++i) {
|
35530
|
-
newBuf[i] = this[i + start]
|
35531
|
-
}
|
35532
|
-
}
|
35559
|
+
const newBuf = this.subarray(start, end)
|
35560
|
+
// Return an augmented `Uint8Array` instance
|
35561
|
+
Object.setPrototypeOf(newBuf, Buffer.prototype)
|
35533
35562
|
|
35534
35563
|
return newBuf
|
35535
35564
|
}
|
@@ -35542,14 +35571,15 @@ function checkOffset (offset, ext, length) {
|
|
35542
35571
|
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
35543
35572
|
}
|
35544
35573
|
|
35574
|
+
Buffer.prototype.readUintLE =
|
35545
35575
|
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
35546
|
-
offset = offset
|
35547
|
-
byteLength = byteLength
|
35576
|
+
offset = offset >>> 0
|
35577
|
+
byteLength = byteLength >>> 0
|
35548
35578
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
35549
35579
|
|
35550
|
-
|
35551
|
-
|
35552
|
-
|
35580
|
+
let val = this[offset]
|
35581
|
+
let mul = 1
|
35582
|
+
let i = 0
|
35553
35583
|
while (++i < byteLength && (mul *= 0x100)) {
|
35554
35584
|
val += this[offset + i] * mul
|
35555
35585
|
}
|
@@ -35557,15 +35587,16 @@ Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert)
|
|
35557
35587
|
return val
|
35558
35588
|
}
|
35559
35589
|
|
35590
|
+
Buffer.prototype.readUintBE =
|
35560
35591
|
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
35561
|
-
offset = offset
|
35562
|
-
byteLength = byteLength
|
35592
|
+
offset = offset >>> 0
|
35593
|
+
byteLength = byteLength >>> 0
|
35563
35594
|
if (!noAssert) {
|
35564
35595
|
checkOffset(offset, byteLength, this.length)
|
35565
35596
|
}
|
35566
35597
|
|
35567
|
-
|
35568
|
-
|
35598
|
+
let val = this[offset + --byteLength]
|
35599
|
+
let mul = 1
|
35569
35600
|
while (byteLength > 0 && (mul *= 0x100)) {
|
35570
35601
|
val += this[offset + --byteLength] * mul
|
35571
35602
|
}
|
@@ -35573,22 +35604,30 @@ Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert)
|
|
35573
35604
|
return val
|
35574
35605
|
}
|
35575
35606
|
|
35607
|
+
Buffer.prototype.readUint8 =
|
35576
35608
|
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
35609
|
+
offset = offset >>> 0
|
35577
35610
|
if (!noAssert) checkOffset(offset, 1, this.length)
|
35578
35611
|
return this[offset]
|
35579
35612
|
}
|
35580
35613
|
|
35614
|
+
Buffer.prototype.readUint16LE =
|
35581
35615
|
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
35616
|
+
offset = offset >>> 0
|
35582
35617
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
35583
35618
|
return this[offset] | (this[offset + 1] << 8)
|
35584
35619
|
}
|
35585
35620
|
|
35621
|
+
Buffer.prototype.readUint16BE =
|
35586
35622
|
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
35623
|
+
offset = offset >>> 0
|
35587
35624
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
35588
35625
|
return (this[offset] << 8) | this[offset + 1]
|
35589
35626
|
}
|
35590
35627
|
|
35628
|
+
Buffer.prototype.readUint32LE =
|
35591
35629
|
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
35630
|
+
offset = offset >>> 0
|
35592
35631
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
35593
35632
|
|
35594
35633
|
return ((this[offset]) |
|
@@ -35597,7 +35636,9 @@ Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
|
35597
35636
|
(this[offset + 3] * 0x1000000)
|
35598
35637
|
}
|
35599
35638
|
|
35639
|
+
Buffer.prototype.readUint32BE =
|
35600
35640
|
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
35641
|
+
offset = offset >>> 0
|
35601
35642
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
35602
35643
|
|
35603
35644
|
return (this[offset] * 0x1000000) +
|
@@ -35606,14 +35647,58 @@ Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
|
35606
35647
|
this[offset + 3])
|
35607
35648
|
}
|
35608
35649
|
|
35650
|
+
Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {
|
35651
|
+
offset = offset >>> 0
|
35652
|
+
validateNumber(offset, 'offset')
|
35653
|
+
const first = this[offset]
|
35654
|
+
const last = this[offset + 7]
|
35655
|
+
if (first === undefined || last === undefined) {
|
35656
|
+
boundsError(offset, this.length - 8)
|
35657
|
+
}
|
35658
|
+
|
35659
|
+
const lo = first +
|
35660
|
+
this[++offset] * 2 ** 8 +
|
35661
|
+
this[++offset] * 2 ** 16 +
|
35662
|
+
this[++offset] * 2 ** 24
|
35663
|
+
|
35664
|
+
const hi = this[++offset] +
|
35665
|
+
this[++offset] * 2 ** 8 +
|
35666
|
+
this[++offset] * 2 ** 16 +
|
35667
|
+
last * 2 ** 24
|
35668
|
+
|
35669
|
+
return BigInt(lo) + (BigInt(hi) << BigInt(32))
|
35670
|
+
})
|
35671
|
+
|
35672
|
+
Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {
|
35673
|
+
offset = offset >>> 0
|
35674
|
+
validateNumber(offset, 'offset')
|
35675
|
+
const first = this[offset]
|
35676
|
+
const last = this[offset + 7]
|
35677
|
+
if (first === undefined || last === undefined) {
|
35678
|
+
boundsError(offset, this.length - 8)
|
35679
|
+
}
|
35680
|
+
|
35681
|
+
const hi = first * 2 ** 24 +
|
35682
|
+
this[++offset] * 2 ** 16 +
|
35683
|
+
this[++offset] * 2 ** 8 +
|
35684
|
+
this[++offset]
|
35685
|
+
|
35686
|
+
const lo = this[++offset] * 2 ** 24 +
|
35687
|
+
this[++offset] * 2 ** 16 +
|
35688
|
+
this[++offset] * 2 ** 8 +
|
35689
|
+
last
|
35690
|
+
|
35691
|
+
return (BigInt(hi) << BigInt(32)) + BigInt(lo)
|
35692
|
+
})
|
35693
|
+
|
35609
35694
|
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
35610
|
-
offset = offset
|
35611
|
-
byteLength = byteLength
|
35695
|
+
offset = offset >>> 0
|
35696
|
+
byteLength = byteLength >>> 0
|
35612
35697
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
35613
35698
|
|
35614
|
-
|
35615
|
-
|
35616
|
-
|
35699
|
+
let val = this[offset]
|
35700
|
+
let mul = 1
|
35701
|
+
let i = 0
|
35617
35702
|
while (++i < byteLength && (mul *= 0x100)) {
|
35618
35703
|
val += this[offset + i] * mul
|
35619
35704
|
}
|
@@ -35625,13 +35710,13 @@ Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
|
35625
35710
|
}
|
35626
35711
|
|
35627
35712
|
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
35628
|
-
offset = offset
|
35629
|
-
byteLength = byteLength
|
35713
|
+
offset = offset >>> 0
|
35714
|
+
byteLength = byteLength >>> 0
|
35630
35715
|
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
35631
35716
|
|
35632
|
-
|
35633
|
-
|
35634
|
-
|
35717
|
+
let i = byteLength
|
35718
|
+
let mul = 1
|
35719
|
+
let val = this[offset + --i]
|
35635
35720
|
while (i > 0 && (mul *= 0x100)) {
|
35636
35721
|
val += this[offset + --i] * mul
|
35637
35722
|
}
|
@@ -35643,24 +35728,28 @@ Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
|
35643
35728
|
}
|
35644
35729
|
|
35645
35730
|
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
35731
|
+
offset = offset >>> 0
|
35646
35732
|
if (!noAssert) checkOffset(offset, 1, this.length)
|
35647
35733
|
if (!(this[offset] & 0x80)) return (this[offset])
|
35648
35734
|
return ((0xff - this[offset] + 1) * -1)
|
35649
35735
|
}
|
35650
35736
|
|
35651
35737
|
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
35738
|
+
offset = offset >>> 0
|
35652
35739
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
35653
|
-
|
35740
|
+
const val = this[offset] | (this[offset + 1] << 8)
|
35654
35741
|
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
35655
35742
|
}
|
35656
35743
|
|
35657
35744
|
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
35745
|
+
offset = offset >>> 0
|
35658
35746
|
if (!noAssert) checkOffset(offset, 2, this.length)
|
35659
|
-
|
35747
|
+
const val = this[offset + 1] | (this[offset] << 8)
|
35660
35748
|
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
35661
35749
|
}
|
35662
35750
|
|
35663
35751
|
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
35752
|
+
offset = offset >>> 0
|
35664
35753
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
35665
35754
|
|
35666
35755
|
return (this[offset]) |
|
@@ -35670,6 +35759,7 @@ Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
|
35670
35759
|
}
|
35671
35760
|
|
35672
35761
|
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
35762
|
+
offset = offset >>> 0
|
35673
35763
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
35674
35764
|
|
35675
35765
|
return (this[offset] << 24) |
|
@@ -35678,22 +35768,68 @@ Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
|
35678
35768
|
(this[offset + 3])
|
35679
35769
|
}
|
35680
35770
|
|
35771
|
+
Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {
|
35772
|
+
offset = offset >>> 0
|
35773
|
+
validateNumber(offset, 'offset')
|
35774
|
+
const first = this[offset]
|
35775
|
+
const last = this[offset + 7]
|
35776
|
+
if (first === undefined || last === undefined) {
|
35777
|
+
boundsError(offset, this.length - 8)
|
35778
|
+
}
|
35779
|
+
|
35780
|
+
const val = this[offset + 4] +
|
35781
|
+
this[offset + 5] * 2 ** 8 +
|
35782
|
+
this[offset + 6] * 2 ** 16 +
|
35783
|
+
(last << 24) // Overflow
|
35784
|
+
|
35785
|
+
return (BigInt(val) << BigInt(32)) +
|
35786
|
+
BigInt(first +
|
35787
|
+
this[++offset] * 2 ** 8 +
|
35788
|
+
this[++offset] * 2 ** 16 +
|
35789
|
+
this[++offset] * 2 ** 24)
|
35790
|
+
})
|
35791
|
+
|
35792
|
+
Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {
|
35793
|
+
offset = offset >>> 0
|
35794
|
+
validateNumber(offset, 'offset')
|
35795
|
+
const first = this[offset]
|
35796
|
+
const last = this[offset + 7]
|
35797
|
+
if (first === undefined || last === undefined) {
|
35798
|
+
boundsError(offset, this.length - 8)
|
35799
|
+
}
|
35800
|
+
|
35801
|
+
const val = (first << 24) + // Overflow
|
35802
|
+
this[++offset] * 2 ** 16 +
|
35803
|
+
this[++offset] * 2 ** 8 +
|
35804
|
+
this[++offset]
|
35805
|
+
|
35806
|
+
return (BigInt(val) << BigInt(32)) +
|
35807
|
+
BigInt(this[++offset] * 2 ** 24 +
|
35808
|
+
this[++offset] * 2 ** 16 +
|
35809
|
+
this[++offset] * 2 ** 8 +
|
35810
|
+
last)
|
35811
|
+
})
|
35812
|
+
|
35681
35813
|
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
35814
|
+
offset = offset >>> 0
|
35682
35815
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
35683
35816
|
return ieee754.read(this, offset, true, 23, 4)
|
35684
35817
|
}
|
35685
35818
|
|
35686
35819
|
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
35820
|
+
offset = offset >>> 0
|
35687
35821
|
if (!noAssert) checkOffset(offset, 4, this.length)
|
35688
35822
|
return ieee754.read(this, offset, false, 23, 4)
|
35689
35823
|
}
|
35690
35824
|
|
35691
35825
|
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
35826
|
+
offset = offset >>> 0
|
35692
35827
|
if (!noAssert) checkOffset(offset, 8, this.length)
|
35693
35828
|
return ieee754.read(this, offset, true, 52, 8)
|
35694
35829
|
}
|
35695
35830
|
|
35696
35831
|
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
35832
|
+
offset = offset >>> 0
|
35697
35833
|
if (!noAssert) checkOffset(offset, 8, this.length)
|
35698
35834
|
return ieee754.read(this, offset, false, 52, 8)
|
35699
35835
|
}
|
@@ -35704,17 +35840,18 @@ function checkInt (buf, value, offset, ext, max, min) {
|
|
35704
35840
|
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
35705
35841
|
}
|
35706
35842
|
|
35843
|
+
Buffer.prototype.writeUintLE =
|
35707
35844
|
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
35708
35845
|
value = +value
|
35709
|
-
offset = offset
|
35710
|
-
byteLength = byteLength
|
35846
|
+
offset = offset >>> 0
|
35847
|
+
byteLength = byteLength >>> 0
|
35711
35848
|
if (!noAssert) {
|
35712
|
-
|
35849
|
+
const maxBytes = Math.pow(2, 8 * byteLength) - 1
|
35713
35850
|
checkInt(this, value, offset, byteLength, maxBytes, 0)
|
35714
35851
|
}
|
35715
35852
|
|
35716
|
-
|
35717
|
-
|
35853
|
+
let mul = 1
|
35854
|
+
let i = 0
|
35718
35855
|
this[offset] = value & 0xFF
|
35719
35856
|
while (++i < byteLength && (mul *= 0x100)) {
|
35720
35857
|
this[offset + i] = (value / mul) & 0xFF
|
@@ -35723,17 +35860,18 @@ Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength,
|
|
35723
35860
|
return offset + byteLength
|
35724
35861
|
}
|
35725
35862
|
|
35863
|
+
Buffer.prototype.writeUintBE =
|
35726
35864
|
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
35727
35865
|
value = +value
|
35728
|
-
offset = offset
|
35729
|
-
byteLength = byteLength
|
35866
|
+
offset = offset >>> 0
|
35867
|
+
byteLength = byteLength >>> 0
|
35730
35868
|
if (!noAssert) {
|
35731
|
-
|
35869
|
+
const maxBytes = Math.pow(2, 8 * byteLength) - 1
|
35732
35870
|
checkInt(this, value, offset, byteLength, maxBytes, 0)
|
35733
35871
|
}
|
35734
35872
|
|
35735
|
-
|
35736
|
-
|
35873
|
+
let i = byteLength - 1
|
35874
|
+
let mul = 1
|
35737
35875
|
this[offset + i] = value & 0xFF
|
35738
35876
|
while (--i >= 0 && (mul *= 0x100)) {
|
35739
35877
|
this[offset + i] = (value / mul) & 0xFF
|
@@ -35742,98 +35880,123 @@ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength,
|
|
35742
35880
|
return offset + byteLength
|
35743
35881
|
}
|
35744
35882
|
|
35883
|
+
Buffer.prototype.writeUint8 =
|
35745
35884
|
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
35746
35885
|
value = +value
|
35747
|
-
offset = offset
|
35886
|
+
offset = offset >>> 0
|
35748
35887
|
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
|
35749
|
-
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
35750
35888
|
this[offset] = (value & 0xff)
|
35751
35889
|
return offset + 1
|
35752
35890
|
}
|
35753
35891
|
|
35754
|
-
|
35755
|
-
if (value < 0) value = 0xffff + value + 1
|
35756
|
-
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
|
35757
|
-
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
35758
|
-
(littleEndian ? i : 1 - i) * 8
|
35759
|
-
}
|
35760
|
-
}
|
35761
|
-
|
35892
|
+
Buffer.prototype.writeUint16LE =
|
35762
35893
|
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
35763
35894
|
value = +value
|
35764
|
-
offset = offset
|
35895
|
+
offset = offset >>> 0
|
35765
35896
|
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
35766
|
-
|
35767
|
-
|
35768
|
-
this[offset + 1] = (value >>> 8)
|
35769
|
-
} else {
|
35770
|
-
objectWriteUInt16(this, value, offset, true)
|
35771
|
-
}
|
35897
|
+
this[offset] = (value & 0xff)
|
35898
|
+
this[offset + 1] = (value >>> 8)
|
35772
35899
|
return offset + 2
|
35773
35900
|
}
|
35774
35901
|
|
35902
|
+
Buffer.prototype.writeUint16BE =
|
35775
35903
|
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
35776
35904
|
value = +value
|
35777
|
-
offset = offset
|
35905
|
+
offset = offset >>> 0
|
35778
35906
|
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
35779
|
-
|
35780
|
-
|
35781
|
-
this[offset + 1] = (value & 0xff)
|
35782
|
-
} else {
|
35783
|
-
objectWriteUInt16(this, value, offset, false)
|
35784
|
-
}
|
35907
|
+
this[offset] = (value >>> 8)
|
35908
|
+
this[offset + 1] = (value & 0xff)
|
35785
35909
|
return offset + 2
|
35786
35910
|
}
|
35787
35911
|
|
35788
|
-
|
35789
|
-
if (value < 0) value = 0xffffffff + value + 1
|
35790
|
-
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
|
35791
|
-
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
35792
|
-
}
|
35793
|
-
}
|
35794
|
-
|
35912
|
+
Buffer.prototype.writeUint32LE =
|
35795
35913
|
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
35796
35914
|
value = +value
|
35797
|
-
offset = offset
|
35915
|
+
offset = offset >>> 0
|
35798
35916
|
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
35799
|
-
|
35800
|
-
|
35801
|
-
|
35802
|
-
|
35803
|
-
this[offset] = (value & 0xff)
|
35804
|
-
} else {
|
35805
|
-
objectWriteUInt32(this, value, offset, true)
|
35806
|
-
}
|
35917
|
+
this[offset + 3] = (value >>> 24)
|
35918
|
+
this[offset + 2] = (value >>> 16)
|
35919
|
+
this[offset + 1] = (value >>> 8)
|
35920
|
+
this[offset] = (value & 0xff)
|
35807
35921
|
return offset + 4
|
35808
35922
|
}
|
35809
35923
|
|
35924
|
+
Buffer.prototype.writeUint32BE =
|
35810
35925
|
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
35811
35926
|
value = +value
|
35812
|
-
offset = offset
|
35927
|
+
offset = offset >>> 0
|
35813
35928
|
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
35814
|
-
|
35815
|
-
|
35816
|
-
|
35817
|
-
|
35818
|
-
this[offset + 3] = (value & 0xff)
|
35819
|
-
} else {
|
35820
|
-
objectWriteUInt32(this, value, offset, false)
|
35821
|
-
}
|
35929
|
+
this[offset] = (value >>> 24)
|
35930
|
+
this[offset + 1] = (value >>> 16)
|
35931
|
+
this[offset + 2] = (value >>> 8)
|
35932
|
+
this[offset + 3] = (value & 0xff)
|
35822
35933
|
return offset + 4
|
35823
35934
|
}
|
35824
35935
|
|
35936
|
+
function wrtBigUInt64LE (buf, value, offset, min, max) {
|
35937
|
+
checkIntBI(value, min, max, buf, offset, 7)
|
35938
|
+
|
35939
|
+
let lo = Number(value & BigInt(0xffffffff))
|
35940
|
+
buf[offset++] = lo
|
35941
|
+
lo = lo >> 8
|
35942
|
+
buf[offset++] = lo
|
35943
|
+
lo = lo >> 8
|
35944
|
+
buf[offset++] = lo
|
35945
|
+
lo = lo >> 8
|
35946
|
+
buf[offset++] = lo
|
35947
|
+
let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))
|
35948
|
+
buf[offset++] = hi
|
35949
|
+
hi = hi >> 8
|
35950
|
+
buf[offset++] = hi
|
35951
|
+
hi = hi >> 8
|
35952
|
+
buf[offset++] = hi
|
35953
|
+
hi = hi >> 8
|
35954
|
+
buf[offset++] = hi
|
35955
|
+
return offset
|
35956
|
+
}
|
35957
|
+
|
35958
|
+
function wrtBigUInt64BE (buf, value, offset, min, max) {
|
35959
|
+
checkIntBI(value, min, max, buf, offset, 7)
|
35960
|
+
|
35961
|
+
let lo = Number(value & BigInt(0xffffffff))
|
35962
|
+
buf[offset + 7] = lo
|
35963
|
+
lo = lo >> 8
|
35964
|
+
buf[offset + 6] = lo
|
35965
|
+
lo = lo >> 8
|
35966
|
+
buf[offset + 5] = lo
|
35967
|
+
lo = lo >> 8
|
35968
|
+
buf[offset + 4] = lo
|
35969
|
+
let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))
|
35970
|
+
buf[offset + 3] = hi
|
35971
|
+
hi = hi >> 8
|
35972
|
+
buf[offset + 2] = hi
|
35973
|
+
hi = hi >> 8
|
35974
|
+
buf[offset + 1] = hi
|
35975
|
+
hi = hi >> 8
|
35976
|
+
buf[offset] = hi
|
35977
|
+
return offset + 8
|
35978
|
+
}
|
35979
|
+
|
35980
|
+
Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
|
35981
|
+
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
35982
|
+
})
|
35983
|
+
|
35984
|
+
Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
|
35985
|
+
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
35986
|
+
})
|
35987
|
+
|
35825
35988
|
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
35826
35989
|
value = +value
|
35827
|
-
offset = offset
|
35990
|
+
offset = offset >>> 0
|
35828
35991
|
if (!noAssert) {
|
35829
|
-
|
35992
|
+
const limit = Math.pow(2, (8 * byteLength) - 1)
|
35830
35993
|
|
35831
35994
|
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
35832
35995
|
}
|
35833
35996
|
|
35834
|
-
|
35835
|
-
|
35836
|
-
|
35997
|
+
let i = 0
|
35998
|
+
let mul = 1
|
35999
|
+
let sub = 0
|
35837
36000
|
this[offset] = value & 0xFF
|
35838
36001
|
while (++i < byteLength && (mul *= 0x100)) {
|
35839
36002
|
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
@@ -35847,16 +36010,16 @@ Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, no
|
|
35847
36010
|
|
35848
36011
|
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
35849
36012
|
value = +value
|
35850
|
-
offset = offset
|
36013
|
+
offset = offset >>> 0
|
35851
36014
|
if (!noAssert) {
|
35852
|
-
|
36015
|
+
const limit = Math.pow(2, (8 * byteLength) - 1)
|
35853
36016
|
|
35854
36017
|
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
35855
36018
|
}
|
35856
36019
|
|
35857
|
-
|
35858
|
-
|
35859
|
-
|
36020
|
+
let i = byteLength - 1
|
36021
|
+
let mul = 1
|
36022
|
+
let sub = 0
|
35860
36023
|
this[offset + i] = value & 0xFF
|
35861
36024
|
while (--i >= 0 && (mul *= 0x100)) {
|
35862
36025
|
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
@@ -35870,9 +36033,8 @@ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, no
|
|
35870
36033
|
|
35871
36034
|
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
35872
36035
|
value = +value
|
35873
|
-
offset = offset
|
36036
|
+
offset = offset >>> 0
|
35874
36037
|
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
|
35875
|
-
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
35876
36038
|
if (value < 0) value = 0xff + value + 1
|
35877
36039
|
this[offset] = (value & 0xff)
|
35878
36040
|
return offset + 1
|
@@ -35880,67 +36042,61 @@ Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
|
35880
36042
|
|
35881
36043
|
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
35882
36044
|
value = +value
|
35883
|
-
offset = offset
|
36045
|
+
offset = offset >>> 0
|
35884
36046
|
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
35885
|
-
|
35886
|
-
|
35887
|
-
this[offset + 1] = (value >>> 8)
|
35888
|
-
} else {
|
35889
|
-
objectWriteUInt16(this, value, offset, true)
|
35890
|
-
}
|
36047
|
+
this[offset] = (value & 0xff)
|
36048
|
+
this[offset + 1] = (value >>> 8)
|
35891
36049
|
return offset + 2
|
35892
36050
|
}
|
35893
36051
|
|
35894
36052
|
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
35895
36053
|
value = +value
|
35896
|
-
offset = offset
|
36054
|
+
offset = offset >>> 0
|
35897
36055
|
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
35898
|
-
|
35899
|
-
|
35900
|
-
this[offset + 1] = (value & 0xff)
|
35901
|
-
} else {
|
35902
|
-
objectWriteUInt16(this, value, offset, false)
|
35903
|
-
}
|
36056
|
+
this[offset] = (value >>> 8)
|
36057
|
+
this[offset + 1] = (value & 0xff)
|
35904
36058
|
return offset + 2
|
35905
36059
|
}
|
35906
36060
|
|
35907
36061
|
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
35908
36062
|
value = +value
|
35909
|
-
offset = offset
|
36063
|
+
offset = offset >>> 0
|
35910
36064
|
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
35911
|
-
|
35912
|
-
|
35913
|
-
|
35914
|
-
|
35915
|
-
this[offset + 3] = (value >>> 24)
|
35916
|
-
} else {
|
35917
|
-
objectWriteUInt32(this, value, offset, true)
|
35918
|
-
}
|
36065
|
+
this[offset] = (value & 0xff)
|
36066
|
+
this[offset + 1] = (value >>> 8)
|
36067
|
+
this[offset + 2] = (value >>> 16)
|
36068
|
+
this[offset + 3] = (value >>> 24)
|
35919
36069
|
return offset + 4
|
35920
36070
|
}
|
35921
36071
|
|
35922
36072
|
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
35923
36073
|
value = +value
|
35924
|
-
offset = offset
|
36074
|
+
offset = offset >>> 0
|
35925
36075
|
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
35926
36076
|
if (value < 0) value = 0xffffffff + value + 1
|
35927
|
-
|
35928
|
-
|
35929
|
-
|
35930
|
-
|
35931
|
-
this[offset + 3] = (value & 0xff)
|
35932
|
-
} else {
|
35933
|
-
objectWriteUInt32(this, value, offset, false)
|
35934
|
-
}
|
36077
|
+
this[offset] = (value >>> 24)
|
36078
|
+
this[offset + 1] = (value >>> 16)
|
36079
|
+
this[offset + 2] = (value >>> 8)
|
36080
|
+
this[offset + 3] = (value & 0xff)
|
35935
36081
|
return offset + 4
|
35936
36082
|
}
|
35937
36083
|
|
36084
|
+
Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
|
36085
|
+
return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
36086
|
+
})
|
36087
|
+
|
36088
|
+
Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
|
36089
|
+
return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
36090
|
+
})
|
36091
|
+
|
35938
36092
|
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
35939
36093
|
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
35940
36094
|
if (offset < 0) throw new RangeError('Index out of range')
|
35941
36095
|
}
|
35942
36096
|
|
35943
36097
|
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
36098
|
+
value = +value
|
36099
|
+
offset = offset >>> 0
|
35944
36100
|
if (!noAssert) {
|
35945
36101
|
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
35946
36102
|
}
|
@@ -35957,6 +36113,8 @@ Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert)
|
|
35957
36113
|
}
|
35958
36114
|
|
35959
36115
|
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
36116
|
+
value = +value
|
36117
|
+
offset = offset >>> 0
|
35960
36118
|
if (!noAssert) {
|
35961
36119
|
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
35962
36120
|
}
|
@@ -35974,6 +36132,7 @@ Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert
|
|
35974
36132
|
|
35975
36133
|
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
35976
36134
|
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
36135
|
+
if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
|
35977
36136
|
if (!start) start = 0
|
35978
36137
|
if (!end && end !== 0) end = this.length
|
35979
36138
|
if (targetStart >= target.length) targetStart = target.length
|
@@ -35988,7 +36147,7 @@ Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
|
35988
36147
|
if (targetStart < 0) {
|
35989
36148
|
throw new RangeError('targetStart out of bounds')
|
35990
36149
|
}
|
35991
|
-
if (start < 0 || start >= this.length) throw new RangeError('
|
36150
|
+
if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
|
35992
36151
|
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
35993
36152
|
|
35994
36153
|
// Are we oob?
|
@@ -35997,23 +36156,15 @@ Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
|
35997
36156
|
end = target.length - targetStart + start
|
35998
36157
|
}
|
35999
36158
|
|
36000
|
-
|
36001
|
-
var i
|
36159
|
+
const len = end - start
|
36002
36160
|
|
36003
|
-
if (this === target &&
|
36004
|
-
//
|
36005
|
-
|
36006
|
-
target[i + targetStart] = this[i + start]
|
36007
|
-
}
|
36008
|
-
} else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
36009
|
-
// ascending copy from start
|
36010
|
-
for (i = 0; i < len; ++i) {
|
36011
|
-
target[i + targetStart] = this[i + start]
|
36012
|
-
}
|
36161
|
+
if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
|
36162
|
+
// Use built-in when available, missing from IE11
|
36163
|
+
this.copyWithin(targetStart, start, end)
|
36013
36164
|
} else {
|
36014
36165
|
Uint8Array.prototype.set.call(
|
36015
36166
|
target,
|
36016
|
-
this.subarray(start,
|
36167
|
+
this.subarray(start, end),
|
36017
36168
|
targetStart
|
36018
36169
|
)
|
36019
36170
|
}
|
@@ -36036,20 +36187,24 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
36036
36187
|
encoding = end
|
36037
36188
|
end = this.length
|
36038
36189
|
}
|
36039
|
-
if (val.length === 1) {
|
36040
|
-
var code = val.charCodeAt(0)
|
36041
|
-
if (code < 256) {
|
36042
|
-
val = code
|
36043
|
-
}
|
36044
|
-
}
|
36045
36190
|
if (encoding !== undefined && typeof encoding !== 'string') {
|
36046
36191
|
throw new TypeError('encoding must be a string')
|
36047
36192
|
}
|
36048
36193
|
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
36049
36194
|
throw new TypeError('Unknown encoding: ' + encoding)
|
36050
36195
|
}
|
36196
|
+
if (val.length === 1) {
|
36197
|
+
const code = val.charCodeAt(0)
|
36198
|
+
if ((encoding === 'utf8' && code < 128) ||
|
36199
|
+
encoding === 'latin1') {
|
36200
|
+
// Fast path: If `val` fits into a single byte, use that numeric value.
|
36201
|
+
val = code
|
36202
|
+
}
|
36203
|
+
}
|
36051
36204
|
} else if (typeof val === 'number') {
|
36052
36205
|
val = val & 255
|
36206
|
+
} else if (typeof val === 'boolean') {
|
36207
|
+
val = Number(val)
|
36053
36208
|
}
|
36054
36209
|
|
36055
36210
|
// Invalid ranges are not set to a default, so can range check early.
|
@@ -36066,16 +36221,20 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
36066
36221
|
|
36067
36222
|
if (!val) val = 0
|
36068
36223
|
|
36069
|
-
|
36224
|
+
let i
|
36070
36225
|
if (typeof val === 'number') {
|
36071
36226
|
for (i = start; i < end; ++i) {
|
36072
36227
|
this[i] = val
|
36073
36228
|
}
|
36074
36229
|
} else {
|
36075
|
-
|
36230
|
+
const bytes = Buffer.isBuffer(val)
|
36076
36231
|
? val
|
36077
|
-
:
|
36078
|
-
|
36232
|
+
: Buffer.from(val, encoding)
|
36233
|
+
const len = bytes.length
|
36234
|
+
if (len === 0) {
|
36235
|
+
throw new TypeError('The value "' + val +
|
36236
|
+
'" is invalid for argument "value"')
|
36237
|
+
}
|
36079
36238
|
for (i = 0; i < end - start; ++i) {
|
36080
36239
|
this[i + start] = bytes[i % len]
|
36081
36240
|
}
|
@@ -36084,14 +36243,149 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
36084
36243
|
return this
|
36085
36244
|
}
|
36086
36245
|
|
36246
|
+
// CUSTOM ERRORS
|
36247
|
+
// =============
|
36248
|
+
|
36249
|
+
// Simplified versions from Node, changed for Buffer-only usage
|
36250
|
+
const errors = {}
|
36251
|
+
function E (sym, getMessage, Base) {
|
36252
|
+
errors[sym] = class NodeError extends Base {
|
36253
|
+
constructor () {
|
36254
|
+
super()
|
36255
|
+
|
36256
|
+
Object.defineProperty(this, 'message', {
|
36257
|
+
value: getMessage.apply(this, arguments),
|
36258
|
+
writable: true,
|
36259
|
+
configurable: true
|
36260
|
+
})
|
36261
|
+
|
36262
|
+
// Add the error code to the name to include it in the stack trace.
|
36263
|
+
this.name = `${this.name} [${sym}]`
|
36264
|
+
// Access the stack to generate the error message including the error code
|
36265
|
+
// from the name.
|
36266
|
+
this.stack // eslint-disable-line no-unused-expressions
|
36267
|
+
// Reset the name to the actual name.
|
36268
|
+
delete this.name
|
36269
|
+
}
|
36270
|
+
|
36271
|
+
get code () {
|
36272
|
+
return sym
|
36273
|
+
}
|
36274
|
+
|
36275
|
+
set code (value) {
|
36276
|
+
Object.defineProperty(this, 'code', {
|
36277
|
+
configurable: true,
|
36278
|
+
enumerable: true,
|
36279
|
+
value,
|
36280
|
+
writable: true
|
36281
|
+
})
|
36282
|
+
}
|
36283
|
+
|
36284
|
+
toString () {
|
36285
|
+
return `${this.name} [${sym}]: ${this.message}`
|
36286
|
+
}
|
36287
|
+
}
|
36288
|
+
}
|
36289
|
+
|
36290
|
+
E('ERR_BUFFER_OUT_OF_BOUNDS',
|
36291
|
+
function (name) {
|
36292
|
+
if (name) {
|
36293
|
+
return `${name} is outside of buffer bounds`
|
36294
|
+
}
|
36295
|
+
|
36296
|
+
return 'Attempt to access memory outside buffer bounds'
|
36297
|
+
}, RangeError)
|
36298
|
+
E('ERR_INVALID_ARG_TYPE',
|
36299
|
+
function (name, actual) {
|
36300
|
+
return `The "${name}" argument must be of type number. Received type ${typeof actual}`
|
36301
|
+
}, TypeError)
|
36302
|
+
E('ERR_OUT_OF_RANGE',
|
36303
|
+
function (str, range, input) {
|
36304
|
+
let msg = `The value of "${str}" is out of range.`
|
36305
|
+
let received = input
|
36306
|
+
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
36307
|
+
received = addNumericalSeparator(String(input))
|
36308
|
+
} else if (typeof input === 'bigint') {
|
36309
|
+
received = String(input)
|
36310
|
+
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
36311
|
+
received = addNumericalSeparator(received)
|
36312
|
+
}
|
36313
|
+
received += 'n'
|
36314
|
+
}
|
36315
|
+
msg += ` It must be ${range}. Received ${received}`
|
36316
|
+
return msg
|
36317
|
+
}, RangeError)
|
36318
|
+
|
36319
|
+
function addNumericalSeparator (val) {
|
36320
|
+
let res = ''
|
36321
|
+
let i = val.length
|
36322
|
+
const start = val[0] === '-' ? 1 : 0
|
36323
|
+
for (; i >= start + 4; i -= 3) {
|
36324
|
+
res = `_${val.slice(i - 3, i)}${res}`
|
36325
|
+
}
|
36326
|
+
return `${val.slice(0, i)}${res}`
|
36327
|
+
}
|
36328
|
+
|
36329
|
+
// CHECK FUNCTIONS
|
36330
|
+
// ===============
|
36331
|
+
|
36332
|
+
function checkBounds (buf, offset, byteLength) {
|
36333
|
+
validateNumber(offset, 'offset')
|
36334
|
+
if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
|
36335
|
+
boundsError(offset, buf.length - (byteLength + 1))
|
36336
|
+
}
|
36337
|
+
}
|
36338
|
+
|
36339
|
+
function checkIntBI (value, min, max, buf, offset, byteLength) {
|
36340
|
+
if (value > max || value < min) {
|
36341
|
+
const n = typeof min === 'bigint' ? 'n' : ''
|
36342
|
+
let range
|
36343
|
+
if (byteLength > 3) {
|
36344
|
+
if (min === 0 || min === BigInt(0)) {
|
36345
|
+
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`
|
36346
|
+
} else {
|
36347
|
+
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
|
36348
|
+
`${(byteLength + 1) * 8 - 1}${n}`
|
36349
|
+
}
|
36350
|
+
} else {
|
36351
|
+
range = `>= ${min}${n} and <= ${max}${n}`
|
36352
|
+
}
|
36353
|
+
throw new errors.ERR_OUT_OF_RANGE('value', range, value)
|
36354
|
+
}
|
36355
|
+
checkBounds(buf, offset, byteLength)
|
36356
|
+
}
|
36357
|
+
|
36358
|
+
function validateNumber (value, name) {
|
36359
|
+
if (typeof value !== 'number') {
|
36360
|
+
throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
|
36361
|
+
}
|
36362
|
+
}
|
36363
|
+
|
36364
|
+
function boundsError (value, length, type) {
|
36365
|
+
if (Math.floor(value) !== value) {
|
36366
|
+
validateNumber(value, type)
|
36367
|
+
throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value)
|
36368
|
+
}
|
36369
|
+
|
36370
|
+
if (length < 0) {
|
36371
|
+
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
|
36372
|
+
}
|
36373
|
+
|
36374
|
+
throw new errors.ERR_OUT_OF_RANGE(type || 'offset',
|
36375
|
+
`>= ${type ? 1 : 0} and <= ${length}`,
|
36376
|
+
value)
|
36377
|
+
}
|
36378
|
+
|
36087
36379
|
// HELPER FUNCTIONS
|
36088
36380
|
// ================
|
36089
36381
|
|
36090
|
-
|
36382
|
+
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
|
36091
36383
|
|
36092
36384
|
function base64clean (str) {
|
36385
|
+
// Node takes equal signs as end of the Base64 encoding
|
36386
|
+
str = str.split('=')[0]
|
36093
36387
|
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
36094
|
-
str =
|
36388
|
+
str = str.trim().replace(INVALID_BASE64_RE, '')
|
36095
36389
|
// Node converts strings with length < 2 to ''
|
36096
36390
|
if (str.length < 2) return ''
|
36097
36391
|
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
@@ -36101,24 +36395,14 @@ function base64clean (str) {
|
|
36101
36395
|
return str
|
36102
36396
|
}
|
36103
36397
|
|
36104
|
-
function stringtrim (str) {
|
36105
|
-
if (str.trim) return str.trim()
|
36106
|
-
return str.replace(/^\s+|\s+$/g, '')
|
36107
|
-
}
|
36108
|
-
|
36109
|
-
function toHex (n) {
|
36110
|
-
if (n < 16) return '0' + n.toString(16)
|
36111
|
-
return n.toString(16)
|
36112
|
-
}
|
36113
|
-
|
36114
36398
|
function utf8ToBytes (string, units) {
|
36115
36399
|
units = units || Infinity
|
36116
|
-
|
36117
|
-
|
36118
|
-
|
36119
|
-
|
36400
|
+
let codePoint
|
36401
|
+
const length = string.length
|
36402
|
+
let leadSurrogate = null
|
36403
|
+
const bytes = []
|
36120
36404
|
|
36121
|
-
for (
|
36405
|
+
for (let i = 0; i < length; ++i) {
|
36122
36406
|
codePoint = string.charCodeAt(i)
|
36123
36407
|
|
36124
36408
|
// is surrogate component
|
@@ -36192,8 +36476,8 @@ function utf8ToBytes (string, units) {
|
|
36192
36476
|
}
|
36193
36477
|
|
36194
36478
|
function asciiToBytes (str) {
|
36195
|
-
|
36196
|
-
for (
|
36479
|
+
const byteArray = []
|
36480
|
+
for (let i = 0; i < str.length; ++i) {
|
36197
36481
|
// Node's code seems to be doing this and not & 0x7F..
|
36198
36482
|
byteArray.push(str.charCodeAt(i) & 0xFF)
|
36199
36483
|
}
|
@@ -36201,9 +36485,9 @@ function asciiToBytes (str) {
|
|
36201
36485
|
}
|
36202
36486
|
|
36203
36487
|
function utf16leToBytes (str, units) {
|
36204
|
-
|
36205
|
-
|
36206
|
-
for (
|
36488
|
+
let c, hi, lo
|
36489
|
+
const byteArray = []
|
36490
|
+
for (let i = 0; i < str.length; ++i) {
|
36207
36491
|
if ((units -= 2) < 0) break
|
36208
36492
|
|
36209
36493
|
c = str.charCodeAt(i)
|
@@ -36221,15 +36505,48 @@ function base64ToBytes (str) {
|
|
36221
36505
|
}
|
36222
36506
|
|
36223
36507
|
function blitBuffer (src, dst, offset, length) {
|
36224
|
-
|
36508
|
+
let i
|
36509
|
+
for (i = 0; i < length; ++i) {
|
36225
36510
|
if ((i + offset >= dst.length) || (i >= src.length)) break
|
36226
36511
|
dst[i + offset] = src[i]
|
36227
36512
|
}
|
36228
36513
|
return i
|
36229
36514
|
}
|
36230
36515
|
|
36231
|
-
|
36232
|
-
|
36516
|
+
// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
|
36517
|
+
// the `instanceof` check but they should be treated as of that type.
|
36518
|
+
// See: https://github.com/feross/buffer/issues/166
|
36519
|
+
function isInstance (obj, type) {
|
36520
|
+
return obj instanceof type ||
|
36521
|
+
(obj != null && obj.constructor != null && obj.constructor.name != null &&
|
36522
|
+
obj.constructor.name === type.name)
|
36523
|
+
}
|
36524
|
+
function numberIsNaN (obj) {
|
36525
|
+
// For IE11 support
|
36526
|
+
return obj !== obj // eslint-disable-line no-self-compare
|
36527
|
+
}
|
36528
|
+
|
36529
|
+
// Create lookup table for `toString('hex')`
|
36530
|
+
// See: https://github.com/feross/buffer/issues/219
|
36531
|
+
const hexSliceLookupTable = (function () {
|
36532
|
+
const alphabet = '0123456789abcdef'
|
36533
|
+
const table = new Array(256)
|
36534
|
+
for (let i = 0; i < 16; ++i) {
|
36535
|
+
const i16 = i * 16
|
36536
|
+
for (let j = 0; j < 16; ++j) {
|
36537
|
+
table[i16 + j] = alphabet[i] + alphabet[j]
|
36538
|
+
}
|
36539
|
+
}
|
36540
|
+
return table
|
36541
|
+
})()
|
36542
|
+
|
36543
|
+
// Return not function with Error if BigInt not supported
|
36544
|
+
function defineBigIntMethod (fn) {
|
36545
|
+
return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
|
36546
|
+
}
|
36547
|
+
|
36548
|
+
function BufferBigIntNotDefined () {
|
36549
|
+
throw new Error('BigInt not supported')
|
36233
36550
|
}
|
36234
36551
|
|
36235
36552
|
|
@@ -36394,21 +36711,6 @@ function fromByteArray (uint8) {
|
|
36394
36711
|
}
|
36395
36712
|
|
36396
36713
|
|
36397
|
-
/***/ }),
|
36398
|
-
|
36399
|
-
/***/ "./node_modules/buffer/node_modules/isarray/index.js":
|
36400
|
-
/*!***********************************************************!*\
|
36401
|
-
!*** ./node_modules/buffer/node_modules/isarray/index.js ***!
|
36402
|
-
\***********************************************************/
|
36403
|
-
/***/ ((module) => {
|
36404
|
-
|
36405
|
-
var toString = {}.toString;
|
36406
|
-
|
36407
|
-
module.exports = Array.isArray || function (arr) {
|
36408
|
-
return toString.call(arr) == '[object Array]';
|
36409
|
-
};
|
36410
|
-
|
36411
|
-
|
36412
36714
|
/***/ }),
|
36413
36715
|
|
36414
36716
|
/***/ "./node_modules/canvas-toBlob/canvas-toBlob.js":
|
@@ -80349,7 +80651,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"menuMap":{"cs":[{"code":"am","name":
|
|
80349
80651
|
/***/ ((module) => {
|
80350
80652
|
|
80351
80653
|
"use strict";
|
80352
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"scratch-vm","version":"5.0.
|
80654
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"scratch-vm","version":"5.0.91","description":"Virtual Machine for Scratch 3.0","author":"Massachusetts Institute of Technology","license":"AGPL-3.0-only","homepage":"https://github.com/scratchfoundation/scratch-vm#readme","repository":{"type":"git","url":"https://github.com/scratchfoundation/scratch-vm.git","sha":"5e72055c0a480a838915d82e8591b92ce9caae7e"},"main":"./dist/node/scratch-vm.js","browser":"./dist/web/scratch-vm.js","exports":{"webpack":"./src/index.js","browser":"./dist/web/scratch-vm.js","node":"./dist/node/scratch-vm.js","default":"./src/index.js"},"scripts":{"build":"npm run docs && webpack --progress","coverage":"tap ./test/{unit,integration}/*.js --coverage --coverage-report=lcov","docs":"jsdoc -c .jsdoc.json","i18n:src":"mkdirp translations/core && format-message extract --out-file translations/core/en.json src/extensions/**/index.js","i18n:push":"tx-push-src scratch-editor extensions translations/core/en.json","lint":"eslint . && format-message lint src/**/*.js","prepare":"husky install","prepublish":"in-publish && npm run build || not-in-publish","start":"webpack serve","tap":"tap ./test/{unit,integration}/*.js","tap:unit":"tap ./test/unit/*.js","tap:integration":"tap ./test/integration/*.js","test":"npm run lint && npm run tap","watch":"webpack --progress --watch","version":"json -f package.json -I -e \\"this.repository.sha = \'$(git log -n1 --pretty=format:%H)\'\\""},"config":{"commitizen":{"path":"cz-conventional-changelog"}},"browserslist":["Chrome >= 63","Edge >= 15","Firefox >= 57","Safari >= 11"],"tap":{"branches":60,"functions":70,"lines":70,"statements":70},"dependencies":{"@vernier/godirect":"^1.5.0","arraybuffer-loader":"^1.0.6","atob":"^2.1.2","btoa":"^1.2.1","buffer":"^6.0.3","canvas-toBlob":"^1.0.0","decode-html":"^2.0.0","diff-match-patch":"^1.0.4","format-message":"^6.2.1","htmlparser2":"^3.10.0","immutable":"^3.8.1","jszip":"^3.1.5","minilog":"^3.1.0","scratch-audio":"^2.0.0","scratch-parser":"^6.0.0","scratch-render":"^2.0.0","scratch-sb1-converter":"^2.0.0","scratch-storage":"^4.0.0","scratch-svg-renderer":"3.0.36","scratch-translate-extension-languages":"^1.0.0","text-encoding":"^0.7.0","uuid":"^8.3.2","web-worker":"^1.3.0"},"devDependencies":{"@babel/core":"7.26.0","@babel/eslint-parser":"7.25.9","@babel/preset-env":"7.26.0","@commitlint/cli":"17.8.1","@commitlint/config-conventional":"17.8.1","adm-zip":"0.4.11","babel-loader":"9.2.1","callsite":"1.0.0","copy-webpack-plugin":"4.6.0","docdash":"1.2.0","eslint":"8.57.1","eslint-config-scratch":"9.0.9","expose-loader":"1.0.3","file-loader":"6.2.0","format-message-cli":"6.2.4","husky":"8.0.3","in-publish":"2.0.1","js-md5":"0.7.3","jsdoc":"3.6.11","json":"^9.0.4","pngjs":"3.4.0","scratch-blocks":"1.1.206","scratch-l10n":"5.0.68","scratch-render-fonts":"1.0.149","scratch-semantic-release-config":"3.0.0","scratch-webpack-configuration":"3.0.0","script-loader":"0.7.2","semantic-release":"19.0.5","stats.js":"0.17.0","tap":"16.3.10","webpack":"5.97.1","webpack-cli":"4.10.0","webpack-dev-server":"3.11.3"}}');
|
80353
80655
|
|
80354
80656
|
/***/ })
|
80355
80657
|
|