plist 1.1.0 → 1.2.0
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/.travis.yml +2 -0
- package/History.md +10 -0
- package/dist/plist-build.js +3082 -11696
- package/dist/plist-parse.js +1144 -717
- package/dist/plist.js +4298 -11231
- package/lib/build.js +4 -2
- package/package.json +9 -8
- package/test/build.js +0 -133
- package/test/parse.js +0 -448
package/dist/plist-parse.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.plist = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
2
2
|
(function (Buffer){
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -202,7 +202,7 @@ function parsePlistXML (node) {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
}).call(this,require("buffer").Buffer)
|
|
205
|
-
},{"buffer":3,"util-deprecate":
|
|
205
|
+
},{"buffer":3,"util-deprecate":6,"xmldom":7}],2:[function(require,module,exports){
|
|
206
206
|
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
207
207
|
|
|
208
208
|
;(function (exports) {
|
|
@@ -212,18 +212,21 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
|
212
212
|
? Uint8Array
|
|
213
213
|
: Array
|
|
214
214
|
|
|
215
|
-
var ZERO = '0'.charCodeAt(0)
|
|
216
215
|
var PLUS = '+'.charCodeAt(0)
|
|
217
216
|
var SLASH = '/'.charCodeAt(0)
|
|
218
217
|
var NUMBER = '0'.charCodeAt(0)
|
|
219
218
|
var LOWER = 'a'.charCodeAt(0)
|
|
220
219
|
var UPPER = 'A'.charCodeAt(0)
|
|
220
|
+
var PLUS_URL_SAFE = '-'.charCodeAt(0)
|
|
221
|
+
var SLASH_URL_SAFE = '_'.charCodeAt(0)
|
|
221
222
|
|
|
222
223
|
function decode (elt) {
|
|
223
224
|
var code = elt.charCodeAt(0)
|
|
224
|
-
if (code === PLUS
|
|
225
|
+
if (code === PLUS ||
|
|
226
|
+
code === PLUS_URL_SAFE)
|
|
225
227
|
return 62 // '+'
|
|
226
|
-
if (code === SLASH
|
|
228
|
+
if (code === SLASH ||
|
|
229
|
+
code === SLASH_URL_SAFE)
|
|
227
230
|
return 63 // '/'
|
|
228
231
|
if (code < NUMBER)
|
|
229
232
|
return -1 //no match
|
|
@@ -321,60 +324,82 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
|
321
324
|
return output
|
|
322
325
|
}
|
|
323
326
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}())
|
|
327
|
+
exports.toByteArray = b64ToByteArray
|
|
328
|
+
exports.fromByteArray = uint8ToBase64
|
|
329
|
+
}(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
|
|
327
330
|
|
|
328
331
|
},{}],3:[function(require,module,exports){
|
|
332
|
+
(function (global){
|
|
329
333
|
/*!
|
|
330
334
|
* The buffer module from node.js, for the browser.
|
|
331
335
|
*
|
|
332
336
|
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
333
337
|
* @license MIT
|
|
334
338
|
*/
|
|
339
|
+
/* eslint-disable no-proto */
|
|
335
340
|
|
|
336
341
|
var base64 = require('base64-js')
|
|
337
342
|
var ieee754 = require('ieee754')
|
|
343
|
+
var isArray = require('is-array')
|
|
338
344
|
|
|
339
345
|
exports.Buffer = Buffer
|
|
340
|
-
exports.SlowBuffer =
|
|
346
|
+
exports.SlowBuffer = SlowBuffer
|
|
341
347
|
exports.INSPECT_MAX_BYTES = 50
|
|
342
|
-
Buffer.poolSize = 8192
|
|
348
|
+
Buffer.poolSize = 8192 // not used by this implementation
|
|
349
|
+
|
|
350
|
+
var rootParent = {}
|
|
343
351
|
|
|
344
352
|
/**
|
|
345
|
-
* If `TYPED_ARRAY_SUPPORT`:
|
|
353
|
+
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
346
354
|
* === true Use Uint8Array implementation (fastest)
|
|
347
355
|
* === false Use Object implementation (most compatible, even IE6)
|
|
348
356
|
*
|
|
349
357
|
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
|
350
358
|
* Opera 11.6+, iOS 4.2+.
|
|
351
359
|
*
|
|
360
|
+
* Due to various browser bugs, sometimes the Object implementation will be used even
|
|
361
|
+
* when the browser supports typed arrays.
|
|
362
|
+
*
|
|
352
363
|
* Note:
|
|
353
364
|
*
|
|
354
|
-
* -
|
|
355
|
-
*
|
|
356
|
-
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
|
|
365
|
+
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
|
|
366
|
+
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
|
|
357
367
|
*
|
|
358
|
-
*
|
|
368
|
+
* - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property
|
|
369
|
+
* on objects.
|
|
359
370
|
*
|
|
360
|
-
*
|
|
361
|
-
* incorrect length in some situations.
|
|
371
|
+
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
|
|
362
372
|
*
|
|
363
|
-
*
|
|
364
|
-
*
|
|
373
|
+
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
|
|
374
|
+
* incorrect length in some situations.
|
|
375
|
+
|
|
376
|
+
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
|
|
377
|
+
* get the Object implementation, which is slower but behaves correctly.
|
|
365
378
|
*/
|
|
366
|
-
|
|
379
|
+
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
|
|
380
|
+
? global.TYPED_ARRAY_SUPPORT
|
|
381
|
+
: typedArraySupport()
|
|
382
|
+
|
|
383
|
+
function typedArraySupport () {
|
|
384
|
+
function Bar () {}
|
|
367
385
|
try {
|
|
368
|
-
var
|
|
369
|
-
var arr = new Uint8Array(buf)
|
|
386
|
+
var arr = new Uint8Array(1)
|
|
370
387
|
arr.foo = function () { return 42 }
|
|
371
|
-
|
|
388
|
+
arr.constructor = Bar
|
|
389
|
+
return arr.foo() === 42 && // typed array instances can be augmented
|
|
390
|
+
arr.constructor === Bar && // constructor can be set
|
|
372
391
|
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
|
|
373
|
-
|
|
392
|
+
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
|
|
374
393
|
} catch (e) {
|
|
375
394
|
return false
|
|
376
395
|
}
|
|
377
|
-
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function kMaxLength () {
|
|
399
|
+
return Buffer.TYPED_ARRAY_SUPPORT
|
|
400
|
+
? 0x7fffffff
|
|
401
|
+
: 0x3fffffff
|
|
402
|
+
}
|
|
378
403
|
|
|
379
404
|
/**
|
|
380
405
|
* Class: Buffer
|
|
@@ -388,137 +413,249 @@ var TYPED_ARRAY_SUPPORT = (function () {
|
|
|
388
413
|
* By augmenting the instances, we can avoid modifying the `Uint8Array`
|
|
389
414
|
* prototype.
|
|
390
415
|
*/
|
|
391
|
-
function Buffer (
|
|
392
|
-
if (!(this instanceof Buffer))
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
// Find the length
|
|
398
|
-
var length
|
|
399
|
-
if (type === 'number')
|
|
400
|
-
length = subject > 0 ? subject >>> 0 : 0
|
|
401
|
-
else if (type === 'string') {
|
|
402
|
-
if (encoding === 'base64')
|
|
403
|
-
subject = base64clean(subject)
|
|
404
|
-
length = Buffer.byteLength(subject, encoding)
|
|
405
|
-
} else if (type === 'object' && subject !== null) { // assume object is array-like
|
|
406
|
-
if (subject.type === 'Buffer' && isArray(subject.data))
|
|
407
|
-
subject = subject.data
|
|
408
|
-
length = +subject.length > 0 ? Math.floor(+subject.length) : 0
|
|
409
|
-
} else
|
|
410
|
-
throw new Error('First argument needs to be a number, array or string.')
|
|
411
|
-
|
|
412
|
-
var buf
|
|
413
|
-
if (TYPED_ARRAY_SUPPORT) {
|
|
414
|
-
// Preferred: Return an augmented `Uint8Array` instance for best performance
|
|
415
|
-
buf = Buffer._augment(new Uint8Array(length))
|
|
416
|
-
} else {
|
|
417
|
-
// Fallback: Return THIS instance of Buffer (created by `new`)
|
|
418
|
-
buf = this
|
|
419
|
-
buf.length = length
|
|
420
|
-
buf._isBuffer = true
|
|
416
|
+
function Buffer (arg) {
|
|
417
|
+
if (!(this instanceof Buffer)) {
|
|
418
|
+
// Avoid going through an ArgumentsAdaptorTrampoline in the common case.
|
|
419
|
+
if (arguments.length > 1) return new Buffer(arg, arguments[1])
|
|
420
|
+
return new Buffer(arg)
|
|
421
421
|
}
|
|
422
422
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
423
|
+
this.length = 0
|
|
424
|
+
this.parent = undefined
|
|
425
|
+
|
|
426
|
+
// Common case.
|
|
427
|
+
if (typeof arg === 'number') {
|
|
428
|
+
return fromNumber(this, arg)
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Slightly less common case.
|
|
432
|
+
if (typeof arg === 'string') {
|
|
433
|
+
return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8')
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// Unusual.
|
|
437
|
+
return fromObject(this, arg)
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function fromNumber (that, length) {
|
|
441
|
+
that = allocate(that, length < 0 ? 0 : checked(length) | 0)
|
|
442
|
+
if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
|
443
|
+
for (var i = 0; i < length; i++) {
|
|
444
|
+
that[i] = 0
|
|
435
445
|
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
446
|
+
}
|
|
447
|
+
return that
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function fromString (that, string, encoding) {
|
|
451
|
+
if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8'
|
|
452
|
+
|
|
453
|
+
// Assumption: byteLength() return value is always < kMaxLength.
|
|
454
|
+
var length = byteLength(string, encoding) | 0
|
|
455
|
+
that = allocate(that, length)
|
|
456
|
+
|
|
457
|
+
that.write(string, encoding)
|
|
458
|
+
return that
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function fromObject (that, object) {
|
|
462
|
+
if (Buffer.isBuffer(object)) return fromBuffer(that, object)
|
|
463
|
+
|
|
464
|
+
if (isArray(object)) return fromArray(that, object)
|
|
465
|
+
|
|
466
|
+
if (object == null) {
|
|
467
|
+
throw new TypeError('must start with number, buffer, array or string')
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if (typeof ArrayBuffer !== 'undefined') {
|
|
471
|
+
if (object.buffer instanceof ArrayBuffer) {
|
|
472
|
+
return fromTypedArray(that, object)
|
|
473
|
+
}
|
|
474
|
+
if (object instanceof ArrayBuffer) {
|
|
475
|
+
return fromArrayBuffer(that, object)
|
|
441
476
|
}
|
|
442
477
|
}
|
|
443
478
|
|
|
444
|
-
return
|
|
479
|
+
if (object.length) return fromArrayLike(that, object)
|
|
480
|
+
|
|
481
|
+
return fromJsonObject(that, object)
|
|
445
482
|
}
|
|
446
483
|
|
|
447
|
-
|
|
448
|
-
|
|
484
|
+
function fromBuffer (that, buffer) {
|
|
485
|
+
var length = checked(buffer.length) | 0
|
|
486
|
+
that = allocate(that, length)
|
|
487
|
+
buffer.copy(that, 0, 0, length)
|
|
488
|
+
return that
|
|
489
|
+
}
|
|
449
490
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
491
|
+
function fromArray (that, array) {
|
|
492
|
+
var length = checked(array.length) | 0
|
|
493
|
+
that = allocate(that, length)
|
|
494
|
+
for (var i = 0; i < length; i += 1) {
|
|
495
|
+
that[i] = array[i] & 255
|
|
496
|
+
}
|
|
497
|
+
return that
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// Duplicate of fromArray() to keep fromArray() monomorphic.
|
|
501
|
+
function fromTypedArray (that, array) {
|
|
502
|
+
var length = checked(array.length) | 0
|
|
503
|
+
that = allocate(that, length)
|
|
504
|
+
// Truncating the elements is probably not what people expect from typed
|
|
505
|
+
// arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior
|
|
506
|
+
// of the old Buffer constructor.
|
|
507
|
+
for (var i = 0; i < length; i += 1) {
|
|
508
|
+
that[i] = array[i] & 255
|
|
509
|
+
}
|
|
510
|
+
return that
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
function fromArrayBuffer (that, array) {
|
|
514
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
515
|
+
// Return an augmented `Uint8Array` instance, for best performance
|
|
516
|
+
array.byteLength
|
|
517
|
+
that = Buffer._augment(new Uint8Array(array))
|
|
518
|
+
} else {
|
|
519
|
+
// Fallback: Return an object instance of the Buffer class
|
|
520
|
+
that = fromTypedArray(that, new Uint8Array(array))
|
|
466
521
|
}
|
|
522
|
+
return that
|
|
467
523
|
}
|
|
468
524
|
|
|
469
|
-
|
|
525
|
+
function fromArrayLike (that, array) {
|
|
526
|
+
var length = checked(array.length) | 0
|
|
527
|
+
that = allocate(that, length)
|
|
528
|
+
for (var i = 0; i < length; i += 1) {
|
|
529
|
+
that[i] = array[i] & 255
|
|
530
|
+
}
|
|
531
|
+
return that
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object.
|
|
535
|
+
// Returns a zero-length buffer for inputs that don't conform to the spec.
|
|
536
|
+
function fromJsonObject (that, object) {
|
|
537
|
+
var array
|
|
538
|
+
var length = 0
|
|
539
|
+
|
|
540
|
+
if (object.type === 'Buffer' && isArray(object.data)) {
|
|
541
|
+
array = object.data
|
|
542
|
+
length = checked(array.length) | 0
|
|
543
|
+
}
|
|
544
|
+
that = allocate(that, length)
|
|
545
|
+
|
|
546
|
+
for (var i = 0; i < length; i += 1) {
|
|
547
|
+
that[i] = array[i] & 255
|
|
548
|
+
}
|
|
549
|
+
return that
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
553
|
+
Buffer.prototype.__proto__ = Uint8Array.prototype
|
|
554
|
+
Buffer.__proto__ = Uint8Array
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
function allocate (that, length) {
|
|
558
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
559
|
+
// Return an augmented `Uint8Array` instance, for best performance
|
|
560
|
+
that = Buffer._augment(new Uint8Array(length))
|
|
561
|
+
that.__proto__ = Buffer.prototype
|
|
562
|
+
} else {
|
|
563
|
+
// Fallback: Return an object instance of the Buffer class
|
|
564
|
+
that.length = length
|
|
565
|
+
that._isBuffer = true
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1
|
|
569
|
+
if (fromPool) that.parent = rootParent
|
|
570
|
+
|
|
571
|
+
return that
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function checked (length) {
|
|
575
|
+
// Note: cannot use `length < kMaxLength` here because that fails when
|
|
576
|
+
// length is NaN (which is otherwise coerced to zero.)
|
|
577
|
+
if (length >= kMaxLength()) {
|
|
578
|
+
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
|
579
|
+
'size: 0x' + kMaxLength().toString(16) + ' bytes')
|
|
580
|
+
}
|
|
581
|
+
return length | 0
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
function SlowBuffer (subject, encoding) {
|
|
585
|
+
if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
|
|
586
|
+
|
|
587
|
+
var buf = new Buffer(subject, encoding)
|
|
588
|
+
delete buf.parent
|
|
589
|
+
return buf
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
Buffer.isBuffer = function isBuffer (b) {
|
|
470
593
|
return !!(b != null && b._isBuffer)
|
|
471
594
|
}
|
|
472
595
|
|
|
473
|
-
Buffer.
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
596
|
+
Buffer.compare = function compare (a, b) {
|
|
597
|
+
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
598
|
+
throw new TypeError('Arguments must be Buffers')
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if (a === b) return 0
|
|
602
|
+
|
|
603
|
+
var x = a.length
|
|
604
|
+
var y = b.length
|
|
605
|
+
|
|
606
|
+
var i = 0
|
|
607
|
+
var len = Math.min(x, y)
|
|
608
|
+
while (i < len) {
|
|
609
|
+
if (a[i] !== b[i]) break
|
|
610
|
+
|
|
611
|
+
++i
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
if (i !== len) {
|
|
615
|
+
x = a[i]
|
|
616
|
+
y = b[i]
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
if (x < y) return -1
|
|
620
|
+
if (y < x) return 1
|
|
621
|
+
return 0
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
Buffer.isEncoding = function isEncoding (encoding) {
|
|
625
|
+
switch (String(encoding).toLowerCase()) {
|
|
477
626
|
case 'hex':
|
|
478
|
-
ret = str.length / 2
|
|
479
|
-
break
|
|
480
627
|
case 'utf8':
|
|
481
628
|
case 'utf-8':
|
|
482
|
-
ret = utf8ToBytes(str).length
|
|
483
|
-
break
|
|
484
629
|
case 'ascii':
|
|
485
630
|
case 'binary':
|
|
486
|
-
case 'raw':
|
|
487
|
-
ret = str.length
|
|
488
|
-
break
|
|
489
631
|
case 'base64':
|
|
490
|
-
|
|
491
|
-
break
|
|
632
|
+
case 'raw':
|
|
492
633
|
case 'ucs2':
|
|
493
634
|
case 'ucs-2':
|
|
494
635
|
case 'utf16le':
|
|
495
636
|
case 'utf-16le':
|
|
496
|
-
|
|
497
|
-
break
|
|
637
|
+
return true
|
|
498
638
|
default:
|
|
499
|
-
|
|
639
|
+
return false
|
|
500
640
|
}
|
|
501
|
-
return ret
|
|
502
641
|
}
|
|
503
642
|
|
|
504
|
-
Buffer.concat = function (list,
|
|
505
|
-
|
|
643
|
+
Buffer.concat = function concat (list, length) {
|
|
644
|
+
if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
|
|
506
645
|
|
|
507
646
|
if (list.length === 0) {
|
|
508
647
|
return new Buffer(0)
|
|
509
|
-
} else if (list.length === 1) {
|
|
510
|
-
return list[0]
|
|
511
648
|
}
|
|
512
649
|
|
|
513
650
|
var i
|
|
514
|
-
if (
|
|
515
|
-
|
|
651
|
+
if (length === undefined) {
|
|
652
|
+
length = 0
|
|
516
653
|
for (i = 0; i < list.length; i++) {
|
|
517
|
-
|
|
654
|
+
length += list[i].length
|
|
518
655
|
}
|
|
519
656
|
}
|
|
520
657
|
|
|
521
|
-
var buf = new Buffer(
|
|
658
|
+
var buf = new Buffer(length)
|
|
522
659
|
var pos = 0
|
|
523
660
|
for (i = 0; i < list.length; i++) {
|
|
524
661
|
var item = list[i]
|
|
@@ -528,26 +665,171 @@ Buffer.concat = function (list, totalLength) {
|
|
|
528
665
|
return buf
|
|
529
666
|
}
|
|
530
667
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
var
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
668
|
+
function byteLength (string, encoding) {
|
|
669
|
+
if (typeof string !== 'string') string = '' + string
|
|
670
|
+
|
|
671
|
+
var len = string.length
|
|
672
|
+
if (len === 0) return 0
|
|
673
|
+
|
|
674
|
+
// Use a for loop to avoid recursion
|
|
675
|
+
var loweredCase = false
|
|
676
|
+
for (;;) {
|
|
677
|
+
switch (encoding) {
|
|
678
|
+
case 'ascii':
|
|
679
|
+
case 'binary':
|
|
680
|
+
// Deprecated
|
|
681
|
+
case 'raw':
|
|
682
|
+
case 'raws':
|
|
683
|
+
return len
|
|
684
|
+
case 'utf8':
|
|
685
|
+
case 'utf-8':
|
|
686
|
+
return utf8ToBytes(string).length
|
|
687
|
+
case 'ucs2':
|
|
688
|
+
case 'ucs-2':
|
|
689
|
+
case 'utf16le':
|
|
690
|
+
case 'utf-16le':
|
|
691
|
+
return len * 2
|
|
692
|
+
case 'hex':
|
|
693
|
+
return len >>> 1
|
|
694
|
+
case 'base64':
|
|
695
|
+
return base64ToBytes(string).length
|
|
696
|
+
default:
|
|
697
|
+
if (loweredCase) return utf8ToBytes(string).length // assume utf8
|
|
698
|
+
encoding = ('' + encoding).toLowerCase()
|
|
699
|
+
loweredCase = true
|
|
700
|
+
}
|
|
539
701
|
}
|
|
540
|
-
|
|
541
|
-
|
|
702
|
+
}
|
|
703
|
+
Buffer.byteLength = byteLength
|
|
704
|
+
|
|
705
|
+
// pre-set for values that may exist in the future
|
|
706
|
+
Buffer.prototype.length = undefined
|
|
707
|
+
Buffer.prototype.parent = undefined
|
|
708
|
+
|
|
709
|
+
function slowToString (encoding, start, end) {
|
|
710
|
+
var loweredCase = false
|
|
711
|
+
|
|
712
|
+
start = start | 0
|
|
713
|
+
end = end === undefined || end === Infinity ? this.length : end | 0
|
|
714
|
+
|
|
715
|
+
if (!encoding) encoding = 'utf8'
|
|
716
|
+
if (start < 0) start = 0
|
|
717
|
+
if (end > this.length) end = this.length
|
|
718
|
+
if (end <= start) return ''
|
|
719
|
+
|
|
720
|
+
while (true) {
|
|
721
|
+
switch (encoding) {
|
|
722
|
+
case 'hex':
|
|
723
|
+
return hexSlice(this, start, end)
|
|
724
|
+
|
|
725
|
+
case 'utf8':
|
|
726
|
+
case 'utf-8':
|
|
727
|
+
return utf8Slice(this, start, end)
|
|
728
|
+
|
|
729
|
+
case 'ascii':
|
|
730
|
+
return asciiSlice(this, start, end)
|
|
731
|
+
|
|
732
|
+
case 'binary':
|
|
733
|
+
return binarySlice(this, start, end)
|
|
734
|
+
|
|
735
|
+
case 'base64':
|
|
736
|
+
return base64Slice(this, start, end)
|
|
737
|
+
|
|
738
|
+
case 'ucs2':
|
|
739
|
+
case 'ucs-2':
|
|
740
|
+
case 'utf16le':
|
|
741
|
+
case 'utf-16le':
|
|
742
|
+
return utf16leSlice(this, start, end)
|
|
743
|
+
|
|
744
|
+
default:
|
|
745
|
+
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
746
|
+
encoding = (encoding + '').toLowerCase()
|
|
747
|
+
loweredCase = true
|
|
748
|
+
}
|
|
542
749
|
}
|
|
543
|
-
|
|
544
|
-
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
Buffer.prototype.toString = function toString () {
|
|
753
|
+
var length = this.length | 0
|
|
754
|
+
if (length === 0) return ''
|
|
755
|
+
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
|
756
|
+
return slowToString.apply(this, arguments)
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
Buffer.prototype.equals = function equals (b) {
|
|
760
|
+
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
|
761
|
+
if (this === b) return true
|
|
762
|
+
return Buffer.compare(this, b) === 0
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
Buffer.prototype.inspect = function inspect () {
|
|
766
|
+
var str = ''
|
|
767
|
+
var max = exports.INSPECT_MAX_BYTES
|
|
768
|
+
if (this.length > 0) {
|
|
769
|
+
str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
|
|
770
|
+
if (this.length > max) str += ' ... '
|
|
545
771
|
}
|
|
546
|
-
return
|
|
772
|
+
return '<Buffer ' + str + '>'
|
|
547
773
|
}
|
|
548
774
|
|
|
549
|
-
|
|
550
|
-
|
|
775
|
+
Buffer.prototype.compare = function compare (b) {
|
|
776
|
+
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
|
777
|
+
if (this === b) return 0
|
|
778
|
+
return Buffer.compare(this, b)
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
|
|
782
|
+
if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
|
|
783
|
+
else if (byteOffset < -0x80000000) byteOffset = -0x80000000
|
|
784
|
+
byteOffset >>= 0
|
|
785
|
+
|
|
786
|
+
if (this.length === 0) return -1
|
|
787
|
+
if (byteOffset >= this.length) return -1
|
|
788
|
+
|
|
789
|
+
// Negative offsets start from the end of the buffer
|
|
790
|
+
if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
|
|
791
|
+
|
|
792
|
+
if (typeof val === 'string') {
|
|
793
|
+
if (val.length === 0) return -1 // special case: looking for empty string always fails
|
|
794
|
+
return String.prototype.indexOf.call(this, val, byteOffset)
|
|
795
|
+
}
|
|
796
|
+
if (Buffer.isBuffer(val)) {
|
|
797
|
+
return arrayIndexOf(this, val, byteOffset)
|
|
798
|
+
}
|
|
799
|
+
if (typeof val === 'number') {
|
|
800
|
+
if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
|
|
801
|
+
return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
|
|
802
|
+
}
|
|
803
|
+
return arrayIndexOf(this, [ val ], byteOffset)
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
function arrayIndexOf (arr, val, byteOffset) {
|
|
807
|
+
var foundIndex = -1
|
|
808
|
+
for (var i = 0; byteOffset + i < arr.length; i++) {
|
|
809
|
+
if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
|
|
810
|
+
if (foundIndex === -1) foundIndex = i
|
|
811
|
+
if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
|
|
812
|
+
} else {
|
|
813
|
+
foundIndex = -1
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return -1
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
throw new TypeError('val must be string, number or Buffer')
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// `get` is deprecated
|
|
823
|
+
Buffer.prototype.get = function get (offset) {
|
|
824
|
+
console.log('.get() is deprecated. Access using array indexes instead.')
|
|
825
|
+
return this.readUInt8(offset)
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
// `set` is deprecated
|
|
829
|
+
Buffer.prototype.set = function set (v, offset) {
|
|
830
|
+
console.log('.set() is deprecated. Access using array indexes instead.')
|
|
831
|
+
return this.writeUInt8(v, offset)
|
|
832
|
+
}
|
|
551
833
|
|
|
552
834
|
function hexWrite (buf, string, offset, length) {
|
|
553
835
|
offset = Number(offset) || 0
|
|
@@ -563,27 +845,25 @@ function hexWrite (buf, string, offset, length) {
|
|
|
563
845
|
|
|
564
846
|
// must be an even number of digits
|
|
565
847
|
var strLen = string.length
|
|
566
|
-
|
|
848
|
+
if (strLen % 2 !== 0) throw new Error('Invalid hex string')
|
|
567
849
|
|
|
568
850
|
if (length > strLen / 2) {
|
|
569
851
|
length = strLen / 2
|
|
570
852
|
}
|
|
571
853
|
for (var i = 0; i < length; i++) {
|
|
572
|
-
var
|
|
573
|
-
|
|
574
|
-
buf[offset + i] =
|
|
854
|
+
var parsed = parseInt(string.substr(i * 2, 2), 16)
|
|
855
|
+
if (isNaN(parsed)) throw new Error('Invalid hex string')
|
|
856
|
+
buf[offset + i] = parsed
|
|
575
857
|
}
|
|
576
858
|
return i
|
|
577
859
|
}
|
|
578
860
|
|
|
579
861
|
function utf8Write (buf, string, offset, length) {
|
|
580
|
-
|
|
581
|
-
return charsWritten
|
|
862
|
+
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
|
582
863
|
}
|
|
583
864
|
|
|
584
865
|
function asciiWrite (buf, string, offset, length) {
|
|
585
|
-
|
|
586
|
-
return charsWritten
|
|
866
|
+
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
587
867
|
}
|
|
588
868
|
|
|
589
869
|
function binaryWrite (buf, string, offset, length) {
|
|
@@ -591,166 +871,92 @@ function binaryWrite (buf, string, offset, length) {
|
|
|
591
871
|
}
|
|
592
872
|
|
|
593
873
|
function base64Write (buf, string, offset, length) {
|
|
594
|
-
|
|
595
|
-
return charsWritten
|
|
874
|
+
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
596
875
|
}
|
|
597
876
|
|
|
598
|
-
function
|
|
599
|
-
|
|
600
|
-
return charsWritten
|
|
877
|
+
function ucs2Write (buf, string, offset, length) {
|
|
878
|
+
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
|
601
879
|
}
|
|
602
880
|
|
|
603
|
-
Buffer.prototype.write = function (string, offset, length, encoding) {
|
|
604
|
-
//
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
881
|
+
Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
882
|
+
// Buffer#write(string)
|
|
883
|
+
if (offset === undefined) {
|
|
884
|
+
encoding = 'utf8'
|
|
885
|
+
length = this.length
|
|
886
|
+
offset = 0
|
|
887
|
+
// Buffer#write(string, encoding)
|
|
888
|
+
} else if (length === undefined && typeof offset === 'string') {
|
|
889
|
+
encoding = offset
|
|
890
|
+
length = this.length
|
|
891
|
+
offset = 0
|
|
892
|
+
// Buffer#write(string, offset[, length][, encoding])
|
|
893
|
+
} else if (isFinite(offset)) {
|
|
894
|
+
offset = offset | 0
|
|
895
|
+
if (isFinite(length)) {
|
|
896
|
+
length = length | 0
|
|
897
|
+
if (encoding === undefined) encoding = 'utf8'
|
|
898
|
+
} else {
|
|
608
899
|
encoding = length
|
|
609
900
|
length = undefined
|
|
610
901
|
}
|
|
611
|
-
|
|
902
|
+
// legacy write(string, encoding, offset, length) - remove in v0.13
|
|
903
|
+
} else {
|
|
612
904
|
var swap = encoding
|
|
613
905
|
encoding = offset
|
|
614
|
-
offset = length
|
|
906
|
+
offset = length | 0
|
|
615
907
|
length = swap
|
|
616
908
|
}
|
|
617
909
|
|
|
618
|
-
offset = Number(offset) || 0
|
|
619
910
|
var remaining = this.length - offset
|
|
620
|
-
if (
|
|
621
|
-
length = remaining
|
|
622
|
-
} else {
|
|
623
|
-
length = Number(length)
|
|
624
|
-
if (length > remaining) {
|
|
625
|
-
length = remaining
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
encoding = String(encoding || 'utf8').toLowerCase()
|
|
911
|
+
if (length === undefined || length > remaining) length = remaining
|
|
629
912
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
case 'hex':
|
|
633
|
-
ret = hexWrite(this, string, offset, length)
|
|
634
|
-
break
|
|
635
|
-
case 'utf8':
|
|
636
|
-
case 'utf-8':
|
|
637
|
-
ret = utf8Write(this, string, offset, length)
|
|
638
|
-
break
|
|
639
|
-
case 'ascii':
|
|
640
|
-
ret = asciiWrite(this, string, offset, length)
|
|
641
|
-
break
|
|
642
|
-
case 'binary':
|
|
643
|
-
ret = binaryWrite(this, string, offset, length)
|
|
644
|
-
break
|
|
645
|
-
case 'base64':
|
|
646
|
-
ret = base64Write(this, string, offset, length)
|
|
647
|
-
break
|
|
648
|
-
case 'ucs2':
|
|
649
|
-
case 'ucs-2':
|
|
650
|
-
case 'utf16le':
|
|
651
|
-
case 'utf-16le':
|
|
652
|
-
ret = utf16leWrite(this, string, offset, length)
|
|
653
|
-
break
|
|
654
|
-
default:
|
|
655
|
-
throw new Error('Unknown encoding')
|
|
913
|
+
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
|
914
|
+
throw new RangeError('attempt to write outside buffer bounds')
|
|
656
915
|
}
|
|
657
|
-
return ret
|
|
658
|
-
}
|
|
659
916
|
|
|
660
|
-
|
|
661
|
-
var self = this
|
|
917
|
+
if (!encoding) encoding = 'utf8'
|
|
662
918
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
919
|
+
var loweredCase = false
|
|
920
|
+
for (;;) {
|
|
921
|
+
switch (encoding) {
|
|
922
|
+
case 'hex':
|
|
923
|
+
return hexWrite(this, string, offset, length)
|
|
666
924
|
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
925
|
+
case 'utf8':
|
|
926
|
+
case 'utf-8':
|
|
927
|
+
return utf8Write(this, string, offset, length)
|
|
670
928
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
case 'utf-16le':
|
|
693
|
-
ret = utf16leSlice(self, start, end)
|
|
694
|
-
break
|
|
695
|
-
default:
|
|
696
|
-
throw new Error('Unknown encoding')
|
|
929
|
+
case 'ascii':
|
|
930
|
+
return asciiWrite(this, string, offset, length)
|
|
931
|
+
|
|
932
|
+
case 'binary':
|
|
933
|
+
return binaryWrite(this, string, offset, length)
|
|
934
|
+
|
|
935
|
+
case 'base64':
|
|
936
|
+
// Warning: maxLength not taken into account in base64Write
|
|
937
|
+
return base64Write(this, string, offset, length)
|
|
938
|
+
|
|
939
|
+
case 'ucs2':
|
|
940
|
+
case 'ucs-2':
|
|
941
|
+
case 'utf16le':
|
|
942
|
+
case 'utf-16le':
|
|
943
|
+
return ucs2Write(this, string, offset, length)
|
|
944
|
+
|
|
945
|
+
default:
|
|
946
|
+
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
947
|
+
encoding = ('' + encoding).toLowerCase()
|
|
948
|
+
loweredCase = true
|
|
949
|
+
}
|
|
697
950
|
}
|
|
698
|
-
return ret
|
|
699
951
|
}
|
|
700
952
|
|
|
701
|
-
Buffer.prototype.toJSON = function () {
|
|
953
|
+
Buffer.prototype.toJSON = function toJSON () {
|
|
702
954
|
return {
|
|
703
955
|
type: 'Buffer',
|
|
704
956
|
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
705
957
|
}
|
|
706
958
|
}
|
|
707
959
|
|
|
708
|
-
Buffer.prototype.equals = function (b) {
|
|
709
|
-
assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
|
|
710
|
-
return Buffer.compare(this, b) === 0
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
Buffer.prototype.compare = function (b) {
|
|
714
|
-
assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
|
|
715
|
-
return Buffer.compare(this, b)
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
719
|
-
Buffer.prototype.copy = function (target, target_start, start, end) {
|
|
720
|
-
var source = this
|
|
721
|
-
|
|
722
|
-
if (!start) start = 0
|
|
723
|
-
if (!end && end !== 0) end = this.length
|
|
724
|
-
if (!target_start) target_start = 0
|
|
725
|
-
|
|
726
|
-
// Copy 0 bytes; we're done
|
|
727
|
-
if (end === start) return
|
|
728
|
-
if (target.length === 0 || source.length === 0) return
|
|
729
|
-
|
|
730
|
-
// Fatal error conditions
|
|
731
|
-
assert(end >= start, 'sourceEnd < sourceStart')
|
|
732
|
-
assert(target_start >= 0 && target_start < target.length,
|
|
733
|
-
'targetStart out of bounds')
|
|
734
|
-
assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
|
|
735
|
-
assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
|
|
736
|
-
|
|
737
|
-
// Are we oob?
|
|
738
|
-
if (end > this.length)
|
|
739
|
-
end = this.length
|
|
740
|
-
if (target.length - target_start < end - start)
|
|
741
|
-
end = target.length - target_start + start
|
|
742
|
-
|
|
743
|
-
var len = end - start
|
|
744
|
-
|
|
745
|
-
if (len < 100 || !TYPED_ARRAY_SUPPORT) {
|
|
746
|
-
for (var i = 0; i < len; i++) {
|
|
747
|
-
target[i + target_start] = this[i + start]
|
|
748
|
-
}
|
|
749
|
-
} else {
|
|
750
|
-
target._set(this.subarray(start, start + len), target_start)
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
|
|
754
960
|
function base64Slice (buf, start, end) {
|
|
755
961
|
if (start === 0 && end === buf.length) {
|
|
756
962
|
return base64.fromByteArray(buf)
|
|
@@ -760,20 +966,99 @@ function base64Slice (buf, start, end) {
|
|
|
760
966
|
}
|
|
761
967
|
|
|
762
968
|
function utf8Slice (buf, start, end) {
|
|
763
|
-
var res = ''
|
|
764
|
-
var tmp = ''
|
|
765
969
|
end = Math.min(buf.length, end)
|
|
970
|
+
var res = []
|
|
971
|
+
|
|
972
|
+
var i = start
|
|
973
|
+
while (i < end) {
|
|
974
|
+
var firstByte = buf[i]
|
|
975
|
+
var codePoint = null
|
|
976
|
+
var bytesPerSequence = (firstByte > 0xEF) ? 4
|
|
977
|
+
: (firstByte > 0xDF) ? 3
|
|
978
|
+
: (firstByte > 0xBF) ? 2
|
|
979
|
+
: 1
|
|
980
|
+
|
|
981
|
+
if (i + bytesPerSequence <= end) {
|
|
982
|
+
var secondByte, thirdByte, fourthByte, tempCodePoint
|
|
983
|
+
|
|
984
|
+
switch (bytesPerSequence) {
|
|
985
|
+
case 1:
|
|
986
|
+
if (firstByte < 0x80) {
|
|
987
|
+
codePoint = firstByte
|
|
988
|
+
}
|
|
989
|
+
break
|
|
990
|
+
case 2:
|
|
991
|
+
secondByte = buf[i + 1]
|
|
992
|
+
if ((secondByte & 0xC0) === 0x80) {
|
|
993
|
+
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
|
|
994
|
+
if (tempCodePoint > 0x7F) {
|
|
995
|
+
codePoint = tempCodePoint
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
break
|
|
999
|
+
case 3:
|
|
1000
|
+
secondByte = buf[i + 1]
|
|
1001
|
+
thirdByte = buf[i + 2]
|
|
1002
|
+
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
1003
|
+
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
|
|
1004
|
+
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
1005
|
+
codePoint = tempCodePoint
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
break
|
|
1009
|
+
case 4:
|
|
1010
|
+
secondByte = buf[i + 1]
|
|
1011
|
+
thirdByte = buf[i + 2]
|
|
1012
|
+
fourthByte = buf[i + 3]
|
|
1013
|
+
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
1014
|
+
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
|
|
1015
|
+
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
1016
|
+
codePoint = tempCodePoint
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
766
1021
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
1022
|
+
if (codePoint === null) {
|
|
1023
|
+
// we did not generate a valid codePoint so insert a
|
|
1024
|
+
// replacement char (U+FFFD) and advance only 1 byte
|
|
1025
|
+
codePoint = 0xFFFD
|
|
1026
|
+
bytesPerSequence = 1
|
|
1027
|
+
} else if (codePoint > 0xFFFF) {
|
|
1028
|
+
// encode to utf16 (surrogate pair dance)
|
|
1029
|
+
codePoint -= 0x10000
|
|
1030
|
+
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
|
|
1031
|
+
codePoint = 0xDC00 | codePoint & 0x3FF
|
|
773
1032
|
}
|
|
1033
|
+
|
|
1034
|
+
res.push(codePoint)
|
|
1035
|
+
i += bytesPerSequence
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
return decodeCodePointsArray(res)
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
|
1042
|
+
// the lowest limit is Chrome, with 0x10000 args.
|
|
1043
|
+
// We go 1 magnitude less, for safety
|
|
1044
|
+
var MAX_ARGUMENTS_LENGTH = 0x1000
|
|
1045
|
+
|
|
1046
|
+
function decodeCodePointsArray (codePoints) {
|
|
1047
|
+
var len = codePoints.length
|
|
1048
|
+
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
1049
|
+
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
|
774
1050
|
}
|
|
775
1051
|
|
|
776
|
-
|
|
1052
|
+
// Decode in chunks to avoid "call stack size exceeded".
|
|
1053
|
+
var res = ''
|
|
1054
|
+
var i = 0
|
|
1055
|
+
while (i < len) {
|
|
1056
|
+
res += String.fromCharCode.apply(
|
|
1057
|
+
String,
|
|
1058
|
+
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
1059
|
+
)
|
|
1060
|
+
}
|
|
1061
|
+
return res
|
|
777
1062
|
}
|
|
778
1063
|
|
|
779
1064
|
function asciiSlice (buf, start, end) {
|
|
@@ -781,13 +1066,19 @@ function asciiSlice (buf, start, end) {
|
|
|
781
1066
|
end = Math.min(buf.length, end)
|
|
782
1067
|
|
|
783
1068
|
for (var i = start; i < end; i++) {
|
|
784
|
-
ret += String.fromCharCode(buf[i])
|
|
1069
|
+
ret += String.fromCharCode(buf[i] & 0x7F)
|
|
785
1070
|
}
|
|
786
1071
|
return ret
|
|
787
1072
|
}
|
|
788
1073
|
|
|
789
1074
|
function binarySlice (buf, start, end) {
|
|
790
|
-
|
|
1075
|
+
var ret = ''
|
|
1076
|
+
end = Math.min(buf.length, end)
|
|
1077
|
+
|
|
1078
|
+
for (var i = start; i < end; i++) {
|
|
1079
|
+
ret += String.fromCharCode(buf[i])
|
|
1080
|
+
}
|
|
1081
|
+
return ret
|
|
791
1082
|
}
|
|
792
1083
|
|
|
793
1084
|
function hexSlice (buf, start, end) {
|
|
@@ -812,453 +1103,529 @@ function utf16leSlice (buf, start, end) {
|
|
|
812
1103
|
return res
|
|
813
1104
|
}
|
|
814
1105
|
|
|
815
|
-
Buffer.prototype.slice = function (start, end) {
|
|
1106
|
+
Buffer.prototype.slice = function slice (start, end) {
|
|
816
1107
|
var len = this.length
|
|
817
1108
|
start = ~~start
|
|
818
1109
|
end = end === undefined ? len : ~~end
|
|
819
1110
|
|
|
820
1111
|
if (start < 0) {
|
|
821
|
-
start += len
|
|
822
|
-
if (start < 0)
|
|
823
|
-
start = 0
|
|
1112
|
+
start += len
|
|
1113
|
+
if (start < 0) start = 0
|
|
824
1114
|
} else if (start > len) {
|
|
825
1115
|
start = len
|
|
826
1116
|
}
|
|
827
1117
|
|
|
828
1118
|
if (end < 0) {
|
|
829
1119
|
end += len
|
|
830
|
-
if (end < 0)
|
|
831
|
-
end = 0
|
|
1120
|
+
if (end < 0) end = 0
|
|
832
1121
|
} else if (end > len) {
|
|
833
1122
|
end = len
|
|
834
1123
|
}
|
|
835
1124
|
|
|
836
|
-
if (end < start)
|
|
837
|
-
end = start
|
|
1125
|
+
if (end < start) end = start
|
|
838
1126
|
|
|
839
|
-
|
|
840
|
-
|
|
1127
|
+
var newBuf
|
|
1128
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
1129
|
+
newBuf = Buffer._augment(this.subarray(start, end))
|
|
841
1130
|
} else {
|
|
842
1131
|
var sliceLen = end - start
|
|
843
|
-
|
|
1132
|
+
newBuf = new Buffer(sliceLen, undefined)
|
|
844
1133
|
for (var i = 0; i < sliceLen; i++) {
|
|
845
1134
|
newBuf[i] = this[i + start]
|
|
846
1135
|
}
|
|
847
|
-
return newBuf
|
|
848
1136
|
}
|
|
849
|
-
}
|
|
850
1137
|
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
return this.readUInt8(offset)
|
|
1138
|
+
if (newBuf.length) newBuf.parent = this.parent || this
|
|
1139
|
+
|
|
1140
|
+
return newBuf
|
|
855
1141
|
}
|
|
856
1142
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
1143
|
+
/*
|
|
1144
|
+
* Need to make sure that buffer isn't trying to write out of bounds.
|
|
1145
|
+
*/
|
|
1146
|
+
function checkOffset (offset, ext, length) {
|
|
1147
|
+
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
|
1148
|
+
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
|
861
1149
|
}
|
|
862
1150
|
|
|
863
|
-
Buffer.prototype.
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
}
|
|
1151
|
+
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
|
1152
|
+
offset = offset | 0
|
|
1153
|
+
byteLength = byteLength | 0
|
|
1154
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
868
1155
|
|
|
869
|
-
|
|
870
|
-
|
|
1156
|
+
var val = this[offset]
|
|
1157
|
+
var mul = 1
|
|
1158
|
+
var i = 0
|
|
1159
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
1160
|
+
val += this[offset + i] * mul
|
|
1161
|
+
}
|
|
871
1162
|
|
|
872
|
-
return
|
|
1163
|
+
return val
|
|
873
1164
|
}
|
|
874
1165
|
|
|
875
|
-
function
|
|
1166
|
+
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
|
1167
|
+
offset = offset | 0
|
|
1168
|
+
byteLength = byteLength | 0
|
|
876
1169
|
if (!noAssert) {
|
|
877
|
-
|
|
878
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
879
|
-
assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
|
|
1170
|
+
checkOffset(offset, byteLength, this.length)
|
|
880
1171
|
}
|
|
881
1172
|
|
|
882
|
-
var
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
var val
|
|
887
|
-
if (littleEndian) {
|
|
888
|
-
val = buf[offset]
|
|
889
|
-
if (offset + 1 < len)
|
|
890
|
-
val |= buf[offset + 1] << 8
|
|
891
|
-
} else {
|
|
892
|
-
val = buf[offset] << 8
|
|
893
|
-
if (offset + 1 < len)
|
|
894
|
-
val |= buf[offset + 1]
|
|
1173
|
+
var val = this[offset + --byteLength]
|
|
1174
|
+
var mul = 1
|
|
1175
|
+
while (byteLength > 0 && (mul *= 0x100)) {
|
|
1176
|
+
val += this[offset + --byteLength] * mul
|
|
895
1177
|
}
|
|
1178
|
+
|
|
896
1179
|
return val
|
|
897
1180
|
}
|
|
898
1181
|
|
|
899
|
-
Buffer.prototype.
|
|
900
|
-
|
|
1182
|
+
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
|
1183
|
+
if (!noAssert) checkOffset(offset, 1, this.length)
|
|
1184
|
+
return this[offset]
|
|
901
1185
|
}
|
|
902
1186
|
|
|
903
|
-
Buffer.prototype.
|
|
904
|
-
|
|
1187
|
+
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
|
1188
|
+
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
1189
|
+
return this[offset] | (this[offset + 1] << 8)
|
|
905
1190
|
}
|
|
906
1191
|
|
|
907
|
-
function
|
|
908
|
-
if (!noAssert)
|
|
909
|
-
|
|
910
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
911
|
-
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
var len = buf.length
|
|
915
|
-
if (offset >= len)
|
|
916
|
-
return
|
|
917
|
-
|
|
918
|
-
var val
|
|
919
|
-
if (littleEndian) {
|
|
920
|
-
if (offset + 2 < len)
|
|
921
|
-
val = buf[offset + 2] << 16
|
|
922
|
-
if (offset + 1 < len)
|
|
923
|
-
val |= buf[offset + 1] << 8
|
|
924
|
-
val |= buf[offset]
|
|
925
|
-
if (offset + 3 < len)
|
|
926
|
-
val = val + (buf[offset + 3] << 24 >>> 0)
|
|
927
|
-
} else {
|
|
928
|
-
if (offset + 1 < len)
|
|
929
|
-
val = buf[offset + 1] << 16
|
|
930
|
-
if (offset + 2 < len)
|
|
931
|
-
val |= buf[offset + 2] << 8
|
|
932
|
-
if (offset + 3 < len)
|
|
933
|
-
val |= buf[offset + 3]
|
|
934
|
-
val = val + (buf[offset] << 24 >>> 0)
|
|
935
|
-
}
|
|
936
|
-
return val
|
|
1192
|
+
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
|
1193
|
+
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
1194
|
+
return (this[offset] << 8) | this[offset + 1]
|
|
937
1195
|
}
|
|
938
1196
|
|
|
939
|
-
Buffer.prototype.readUInt32LE = function (offset, noAssert) {
|
|
940
|
-
|
|
1197
|
+
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
|
1198
|
+
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
1199
|
+
|
|
1200
|
+
return ((this[offset]) |
|
|
1201
|
+
(this[offset + 1] << 8) |
|
|
1202
|
+
(this[offset + 2] << 16)) +
|
|
1203
|
+
(this[offset + 3] * 0x1000000)
|
|
941
1204
|
}
|
|
942
1205
|
|
|
943
|
-
Buffer.prototype.readUInt32BE = function (offset, noAssert) {
|
|
944
|
-
|
|
1206
|
+
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
|
1207
|
+
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
1208
|
+
|
|
1209
|
+
return (this[offset] * 0x1000000) +
|
|
1210
|
+
((this[offset + 1] << 16) |
|
|
1211
|
+
(this[offset + 2] << 8) |
|
|
1212
|
+
this[offset + 3])
|
|
945
1213
|
}
|
|
946
1214
|
|
|
947
|
-
Buffer.prototype.
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1215
|
+
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
|
1216
|
+
offset = offset | 0
|
|
1217
|
+
byteLength = byteLength | 0
|
|
1218
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
1219
|
+
|
|
1220
|
+
var val = this[offset]
|
|
1221
|
+
var mul = 1
|
|
1222
|
+
var i = 0
|
|
1223
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
1224
|
+
val += this[offset + i] * mul
|
|
952
1225
|
}
|
|
1226
|
+
mul *= 0x80
|
|
953
1227
|
|
|
954
|
-
if (
|
|
955
|
-
return
|
|
1228
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
|
956
1229
|
|
|
957
|
-
|
|
958
|
-
if (neg)
|
|
959
|
-
return (0xff - this[offset] + 1) * -1
|
|
960
|
-
else
|
|
961
|
-
return this[offset]
|
|
1230
|
+
return val
|
|
962
1231
|
}
|
|
963
1232
|
|
|
964
|
-
function
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1233
|
+
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
|
1234
|
+
offset = offset | 0
|
|
1235
|
+
byteLength = byteLength | 0
|
|
1236
|
+
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
1237
|
+
|
|
1238
|
+
var i = byteLength
|
|
1239
|
+
var mul = 1
|
|
1240
|
+
var val = this[offset + --i]
|
|
1241
|
+
while (i > 0 && (mul *= 0x100)) {
|
|
1242
|
+
val += this[offset + --i] * mul
|
|
969
1243
|
}
|
|
1244
|
+
mul *= 0x80
|
|
970
1245
|
|
|
971
|
-
|
|
972
|
-
if (offset >= len)
|
|
973
|
-
return
|
|
1246
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
|
974
1247
|
|
|
975
|
-
|
|
976
|
-
var neg = val & 0x8000
|
|
977
|
-
if (neg)
|
|
978
|
-
return (0xffff - val + 1) * -1
|
|
979
|
-
else
|
|
980
|
-
return val
|
|
1248
|
+
return val
|
|
981
1249
|
}
|
|
982
1250
|
|
|
983
|
-
Buffer.prototype.
|
|
984
|
-
|
|
1251
|
+
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
|
1252
|
+
if (!noAssert) checkOffset(offset, 1, this.length)
|
|
1253
|
+
if (!(this[offset] & 0x80)) return (this[offset])
|
|
1254
|
+
return ((0xff - this[offset] + 1) * -1)
|
|
985
1255
|
}
|
|
986
1256
|
|
|
987
|
-
Buffer.prototype.
|
|
988
|
-
|
|
1257
|
+
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
|
1258
|
+
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
1259
|
+
var val = this[offset] | (this[offset + 1] << 8)
|
|
1260
|
+
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
989
1261
|
}
|
|
990
1262
|
|
|
991
|
-
function
|
|
992
|
-
if (!noAssert)
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
}
|
|
1263
|
+
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
|
1264
|
+
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
1265
|
+
var val = this[offset + 1] | (this[offset] << 8)
|
|
1266
|
+
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
1267
|
+
}
|
|
997
1268
|
|
|
998
|
-
|
|
999
|
-
if (offset
|
|
1000
|
-
return
|
|
1269
|
+
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
|
1270
|
+
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
1001
1271
|
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
else
|
|
1007
|
-
return val
|
|
1272
|
+
return (this[offset]) |
|
|
1273
|
+
(this[offset + 1] << 8) |
|
|
1274
|
+
(this[offset + 2] << 16) |
|
|
1275
|
+
(this[offset + 3] << 24)
|
|
1008
1276
|
}
|
|
1009
1277
|
|
|
1010
|
-
Buffer.prototype.
|
|
1011
|
-
|
|
1278
|
+
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
|
1279
|
+
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
1280
|
+
|
|
1281
|
+
return (this[offset] << 24) |
|
|
1282
|
+
(this[offset + 1] << 16) |
|
|
1283
|
+
(this[offset + 2] << 8) |
|
|
1284
|
+
(this[offset + 3])
|
|
1012
1285
|
}
|
|
1013
1286
|
|
|
1014
|
-
Buffer.prototype.
|
|
1015
|
-
|
|
1287
|
+
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
|
1288
|
+
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
1289
|
+
return ieee754.read(this, offset, true, 23, 4)
|
|
1016
1290
|
}
|
|
1017
1291
|
|
|
1018
|
-
function
|
|
1019
|
-
if (!noAssert)
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
}
|
|
1292
|
+
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
|
1293
|
+
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
1294
|
+
return ieee754.read(this, offset, false, 23, 4)
|
|
1295
|
+
}
|
|
1023
1296
|
|
|
1024
|
-
|
|
1297
|
+
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
|
1298
|
+
if (!noAssert) checkOffset(offset, 8, this.length)
|
|
1299
|
+
return ieee754.read(this, offset, true, 52, 8)
|
|
1025
1300
|
}
|
|
1026
1301
|
|
|
1027
|
-
Buffer.prototype.
|
|
1028
|
-
|
|
1302
|
+
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
|
1303
|
+
if (!noAssert) checkOffset(offset, 8, this.length)
|
|
1304
|
+
return ieee754.read(this, offset, false, 52, 8)
|
|
1029
1305
|
}
|
|
1030
1306
|
|
|
1031
|
-
|
|
1032
|
-
|
|
1307
|
+
function checkInt (buf, value, offset, ext, max, min) {
|
|
1308
|
+
if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
|
|
1309
|
+
if (value > max || value < min) throw new RangeError('value is out of bounds')
|
|
1310
|
+
if (offset + ext > buf.length) throw new RangeError('index out of range')
|
|
1033
1311
|
}
|
|
1034
1312
|
|
|
1035
|
-
function
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1313
|
+
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
|
1314
|
+
value = +value
|
|
1315
|
+
offset = offset | 0
|
|
1316
|
+
byteLength = byteLength | 0
|
|
1317
|
+
if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
|
|
1040
1318
|
|
|
1041
|
-
|
|
1042
|
-
|
|
1319
|
+
var mul = 1
|
|
1320
|
+
var i = 0
|
|
1321
|
+
this[offset] = value & 0xFF
|
|
1322
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
1323
|
+
this[offset + i] = (value / mul) & 0xFF
|
|
1324
|
+
}
|
|
1043
1325
|
|
|
1044
|
-
|
|
1045
|
-
return readDouble(this, offset, true, noAssert)
|
|
1326
|
+
return offset + byteLength
|
|
1046
1327
|
}
|
|
1047
1328
|
|
|
1048
|
-
Buffer.prototype.
|
|
1049
|
-
|
|
1050
|
-
|
|
1329
|
+
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
|
1330
|
+
value = +value
|
|
1331
|
+
offset = offset | 0
|
|
1332
|
+
byteLength = byteLength | 0
|
|
1333
|
+
if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
|
|
1051
1334
|
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
verifuint(value, 0xff)
|
|
1335
|
+
var i = byteLength - 1
|
|
1336
|
+
var mul = 1
|
|
1337
|
+
this[offset + i] = value & 0xFF
|
|
1338
|
+
while (--i >= 0 && (mul *= 0x100)) {
|
|
1339
|
+
this[offset + i] = (value / mul) & 0xFF
|
|
1058
1340
|
}
|
|
1059
1341
|
|
|
1060
|
-
|
|
1342
|
+
return offset + byteLength
|
|
1343
|
+
}
|
|
1061
1344
|
|
|
1062
|
-
|
|
1345
|
+
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
|
1346
|
+
value = +value
|
|
1347
|
+
offset = offset | 0
|
|
1348
|
+
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
|
|
1349
|
+
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
|
1350
|
+
this[offset] = (value & 0xff)
|
|
1063
1351
|
return offset + 1
|
|
1064
1352
|
}
|
|
1065
1353
|
|
|
1066
|
-
function
|
|
1067
|
-
if (
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
|
|
1072
|
-
verifuint(value, 0xffff)
|
|
1354
|
+
function objectWriteUInt16 (buf, value, offset, littleEndian) {
|
|
1355
|
+
if (value < 0) value = 0xffff + value + 1
|
|
1356
|
+
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
|
|
1357
|
+
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
|
1358
|
+
(littleEndian ? i : 1 - i) * 8
|
|
1073
1359
|
}
|
|
1360
|
+
}
|
|
1074
1361
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1362
|
+
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
|
1363
|
+
value = +value
|
|
1364
|
+
offset = offset | 0
|
|
1365
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
|
1366
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
1367
|
+
this[offset] = (value & 0xff)
|
|
1368
|
+
this[offset + 1] = (value >>> 8)
|
|
1369
|
+
} else {
|
|
1370
|
+
objectWriteUInt16(this, value, offset, true)
|
|
1083
1371
|
}
|
|
1084
1372
|
return offset + 2
|
|
1085
1373
|
}
|
|
1086
1374
|
|
|
1087
|
-
Buffer.prototype.
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
Buffer.
|
|
1092
|
-
|
|
1375
|
+
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
|
1376
|
+
value = +value
|
|
1377
|
+
offset = offset | 0
|
|
1378
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
|
1379
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
1380
|
+
this[offset] = (value >>> 8)
|
|
1381
|
+
this[offset + 1] = (value & 0xff)
|
|
1382
|
+
} else {
|
|
1383
|
+
objectWriteUInt16(this, value, offset, false)
|
|
1384
|
+
}
|
|
1385
|
+
return offset + 2
|
|
1093
1386
|
}
|
|
1094
1387
|
|
|
1095
|
-
function
|
|
1096
|
-
if (
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
1100
|
-
assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
|
|
1101
|
-
verifuint(value, 0xffffffff)
|
|
1388
|
+
function objectWriteUInt32 (buf, value, offset, littleEndian) {
|
|
1389
|
+
if (value < 0) value = 0xffffffff + value + 1
|
|
1390
|
+
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
|
|
1391
|
+
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
|
1102
1392
|
}
|
|
1393
|
+
}
|
|
1103
1394
|
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1395
|
+
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
|
1396
|
+
value = +value
|
|
1397
|
+
offset = offset | 0
|
|
1398
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
|
1399
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
1400
|
+
this[offset + 3] = (value >>> 24)
|
|
1401
|
+
this[offset + 2] = (value >>> 16)
|
|
1402
|
+
this[offset + 1] = (value >>> 8)
|
|
1403
|
+
this[offset] = (value & 0xff)
|
|
1404
|
+
} else {
|
|
1405
|
+
objectWriteUInt32(this, value, offset, true)
|
|
1111
1406
|
}
|
|
1112
1407
|
return offset + 4
|
|
1113
1408
|
}
|
|
1114
1409
|
|
|
1115
|
-
Buffer.prototype.
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
Buffer.
|
|
1120
|
-
|
|
1410
|
+
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
|
1411
|
+
value = +value
|
|
1412
|
+
offset = offset | 0
|
|
1413
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
|
1414
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
1415
|
+
this[offset] = (value >>> 24)
|
|
1416
|
+
this[offset + 1] = (value >>> 16)
|
|
1417
|
+
this[offset + 2] = (value >>> 8)
|
|
1418
|
+
this[offset + 3] = (value & 0xff)
|
|
1419
|
+
} else {
|
|
1420
|
+
objectWriteUInt32(this, value, offset, false)
|
|
1421
|
+
}
|
|
1422
|
+
return offset + 4
|
|
1121
1423
|
}
|
|
1122
1424
|
|
|
1123
|
-
Buffer.prototype.
|
|
1425
|
+
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
|
1426
|
+
value = +value
|
|
1427
|
+
offset = offset | 0
|
|
1124
1428
|
if (!noAssert) {
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
verifsint(value, 0x7f, -0x80)
|
|
1429
|
+
var limit = Math.pow(2, 8 * byteLength - 1)
|
|
1430
|
+
|
|
1431
|
+
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
|
1129
1432
|
}
|
|
1130
1433
|
|
|
1131
|
-
|
|
1132
|
-
|
|
1434
|
+
var i = 0
|
|
1435
|
+
var mul = 1
|
|
1436
|
+
var sub = value < 0 ? 1 : 0
|
|
1437
|
+
this[offset] = value & 0xFF
|
|
1438
|
+
while (++i < byteLength && (mul *= 0x100)) {
|
|
1439
|
+
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
|
1440
|
+
}
|
|
1133
1441
|
|
|
1134
|
-
|
|
1135
|
-
this.writeUInt8(value, offset, noAssert)
|
|
1136
|
-
else
|
|
1137
|
-
this.writeUInt8(0xff + value + 1, offset, noAssert)
|
|
1138
|
-
return offset + 1
|
|
1442
|
+
return offset + byteLength
|
|
1139
1443
|
}
|
|
1140
1444
|
|
|
1141
|
-
function
|
|
1445
|
+
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
|
1446
|
+
value = +value
|
|
1447
|
+
offset = offset | 0
|
|
1142
1448
|
if (!noAssert) {
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
|
|
1147
|
-
verifsint(value, 0x7fff, -0x8000)
|
|
1449
|
+
var limit = Math.pow(2, 8 * byteLength - 1)
|
|
1450
|
+
|
|
1451
|
+
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
|
1148
1452
|
}
|
|
1149
1453
|
|
|
1150
|
-
var
|
|
1151
|
-
|
|
1152
|
-
|
|
1454
|
+
var i = byteLength - 1
|
|
1455
|
+
var mul = 1
|
|
1456
|
+
var sub = value < 0 ? 1 : 0
|
|
1457
|
+
this[offset + i] = value & 0xFF
|
|
1458
|
+
while (--i >= 0 && (mul *= 0x100)) {
|
|
1459
|
+
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
|
1460
|
+
}
|
|
1153
1461
|
|
|
1154
|
-
|
|
1155
|
-
writeUInt16(buf, value, offset, littleEndian, noAssert)
|
|
1156
|
-
else
|
|
1157
|
-
writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
|
|
1158
|
-
return offset + 2
|
|
1462
|
+
return offset + byteLength
|
|
1159
1463
|
}
|
|
1160
1464
|
|
|
1161
|
-
Buffer.prototype.
|
|
1162
|
-
|
|
1465
|
+
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
|
1466
|
+
value = +value
|
|
1467
|
+
offset = offset | 0
|
|
1468
|
+
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
|
|
1469
|
+
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
|
1470
|
+
if (value < 0) value = 0xff + value + 1
|
|
1471
|
+
this[offset] = (value & 0xff)
|
|
1472
|
+
return offset + 1
|
|
1163
1473
|
}
|
|
1164
1474
|
|
|
1165
|
-
Buffer.prototype.
|
|
1166
|
-
|
|
1475
|
+
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
|
1476
|
+
value = +value
|
|
1477
|
+
offset = offset | 0
|
|
1478
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
|
1479
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
1480
|
+
this[offset] = (value & 0xff)
|
|
1481
|
+
this[offset + 1] = (value >>> 8)
|
|
1482
|
+
} else {
|
|
1483
|
+
objectWriteUInt16(this, value, offset, true)
|
|
1484
|
+
}
|
|
1485
|
+
return offset + 2
|
|
1167
1486
|
}
|
|
1168
1487
|
|
|
1169
|
-
function
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1488
|
+
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
|
1489
|
+
value = +value
|
|
1490
|
+
offset = offset | 0
|
|
1491
|
+
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
|
1492
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
1493
|
+
this[offset] = (value >>> 8)
|
|
1494
|
+
this[offset + 1] = (value & 0xff)
|
|
1495
|
+
} else {
|
|
1496
|
+
objectWriteUInt16(this, value, offset, false)
|
|
1176
1497
|
}
|
|
1498
|
+
return offset + 2
|
|
1499
|
+
}
|
|
1177
1500
|
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
if (
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1501
|
+
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
|
1502
|
+
value = +value
|
|
1503
|
+
offset = offset | 0
|
|
1504
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
|
1505
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
1506
|
+
this[offset] = (value & 0xff)
|
|
1507
|
+
this[offset + 1] = (value >>> 8)
|
|
1508
|
+
this[offset + 2] = (value >>> 16)
|
|
1509
|
+
this[offset + 3] = (value >>> 24)
|
|
1510
|
+
} else {
|
|
1511
|
+
objectWriteUInt32(this, value, offset, true)
|
|
1512
|
+
}
|
|
1186
1513
|
return offset + 4
|
|
1187
1514
|
}
|
|
1188
1515
|
|
|
1189
|
-
Buffer.prototype.
|
|
1190
|
-
|
|
1516
|
+
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
|
1517
|
+
value = +value
|
|
1518
|
+
offset = offset | 0
|
|
1519
|
+
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
|
1520
|
+
if (value < 0) value = 0xffffffff + value + 1
|
|
1521
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
1522
|
+
this[offset] = (value >>> 24)
|
|
1523
|
+
this[offset + 1] = (value >>> 16)
|
|
1524
|
+
this[offset + 2] = (value >>> 8)
|
|
1525
|
+
this[offset + 3] = (value & 0xff)
|
|
1526
|
+
} else {
|
|
1527
|
+
objectWriteUInt32(this, value, offset, false)
|
|
1528
|
+
}
|
|
1529
|
+
return offset + 4
|
|
1191
1530
|
}
|
|
1192
1531
|
|
|
1193
|
-
|
|
1194
|
-
|
|
1532
|
+
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
|
1533
|
+
if (value > max || value < min) throw new RangeError('value is out of bounds')
|
|
1534
|
+
if (offset + ext > buf.length) throw new RangeError('index out of range')
|
|
1535
|
+
if (offset < 0) throw new RangeError('index out of range')
|
|
1195
1536
|
}
|
|
1196
1537
|
|
|
1197
1538
|
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
1198
1539
|
if (!noAssert) {
|
|
1199
|
-
|
|
1200
|
-
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
1201
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
1202
|
-
assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
|
|
1203
|
-
verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
|
1540
|
+
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
|
1204
1541
|
}
|
|
1205
|
-
|
|
1206
|
-
var len = buf.length
|
|
1207
|
-
if (offset >= len)
|
|
1208
|
-
return
|
|
1209
|
-
|
|
1210
1542
|
ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
|
1211
1543
|
return offset + 4
|
|
1212
1544
|
}
|
|
1213
1545
|
|
|
1214
|
-
Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
|
|
1546
|
+
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
|
1215
1547
|
return writeFloat(this, value, offset, true, noAssert)
|
|
1216
1548
|
}
|
|
1217
1549
|
|
|
1218
|
-
Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
|
|
1550
|
+
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
|
1219
1551
|
return writeFloat(this, value, offset, false, noAssert)
|
|
1220
1552
|
}
|
|
1221
1553
|
|
|
1222
1554
|
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
1223
1555
|
if (!noAssert) {
|
|
1224
|
-
|
|
1225
|
-
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
1226
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
1227
|
-
assert(offset + 7 < buf.length,
|
|
1228
|
-
'Trying to write beyond buffer length')
|
|
1229
|
-
verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
|
1556
|
+
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
|
1230
1557
|
}
|
|
1231
|
-
|
|
1232
|
-
var len = buf.length
|
|
1233
|
-
if (offset >= len)
|
|
1234
|
-
return
|
|
1235
|
-
|
|
1236
1558
|
ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
|
1237
1559
|
return offset + 8
|
|
1238
1560
|
}
|
|
1239
1561
|
|
|
1240
|
-
Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
|
|
1562
|
+
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
|
1241
1563
|
return writeDouble(this, value, offset, true, noAssert)
|
|
1242
1564
|
}
|
|
1243
1565
|
|
|
1244
|
-
Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
|
|
1566
|
+
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
|
1245
1567
|
return writeDouble(this, value, offset, false, noAssert)
|
|
1246
1568
|
}
|
|
1247
1569
|
|
|
1570
|
+
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
1571
|
+
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
|
1572
|
+
if (!start) start = 0
|
|
1573
|
+
if (!end && end !== 0) end = this.length
|
|
1574
|
+
if (targetStart >= target.length) targetStart = target.length
|
|
1575
|
+
if (!targetStart) targetStart = 0
|
|
1576
|
+
if (end > 0 && end < start) end = start
|
|
1577
|
+
|
|
1578
|
+
// Copy 0 bytes; we're done
|
|
1579
|
+
if (end === start) return 0
|
|
1580
|
+
if (target.length === 0 || this.length === 0) return 0
|
|
1581
|
+
|
|
1582
|
+
// Fatal error conditions
|
|
1583
|
+
if (targetStart < 0) {
|
|
1584
|
+
throw new RangeError('targetStart out of bounds')
|
|
1585
|
+
}
|
|
1586
|
+
if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
|
|
1587
|
+
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
|
1588
|
+
|
|
1589
|
+
// Are we oob?
|
|
1590
|
+
if (end > this.length) end = this.length
|
|
1591
|
+
if (target.length - targetStart < end - start) {
|
|
1592
|
+
end = target.length - targetStart + start
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
var len = end - start
|
|
1596
|
+
var i
|
|
1597
|
+
|
|
1598
|
+
if (this === target && start < targetStart && targetStart < end) {
|
|
1599
|
+
// descending copy from end
|
|
1600
|
+
for (i = len - 1; i >= 0; i--) {
|
|
1601
|
+
target[i + targetStart] = this[i + start]
|
|
1602
|
+
}
|
|
1603
|
+
} else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
|
1604
|
+
// ascending copy from start
|
|
1605
|
+
for (i = 0; i < len; i++) {
|
|
1606
|
+
target[i + targetStart] = this[i + start]
|
|
1607
|
+
}
|
|
1608
|
+
} else {
|
|
1609
|
+
target._set(this.subarray(start, start + len), targetStart)
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
return len
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1248
1615
|
// fill(value, start=0, end=buffer.length)
|
|
1249
|
-
Buffer.prototype.fill = function (value, start, end) {
|
|
1616
|
+
Buffer.prototype.fill = function fill (value, start, end) {
|
|
1250
1617
|
if (!value) value = 0
|
|
1251
1618
|
if (!start) start = 0
|
|
1252
1619
|
if (!end) end = this.length
|
|
1253
1620
|
|
|
1254
|
-
|
|
1621
|
+
if (end < start) throw new RangeError('end < start')
|
|
1255
1622
|
|
|
1256
1623
|
// Fill 0 bytes; we're done
|
|
1257
1624
|
if (end === start) return
|
|
1258
1625
|
if (this.length === 0) return
|
|
1259
1626
|
|
|
1260
|
-
|
|
1261
|
-
|
|
1627
|
+
if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
|
|
1628
|
+
if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
|
|
1262
1629
|
|
|
1263
1630
|
var i
|
|
1264
1631
|
if (typeof value === 'number') {
|
|
@@ -1276,26 +1643,13 @@ Buffer.prototype.fill = function (value, start, end) {
|
|
|
1276
1643
|
return this
|
|
1277
1644
|
}
|
|
1278
1645
|
|
|
1279
|
-
Buffer.prototype.inspect = function () {
|
|
1280
|
-
var out = []
|
|
1281
|
-
var len = this.length
|
|
1282
|
-
for (var i = 0; i < len; i++) {
|
|
1283
|
-
out[i] = toHex(this[i])
|
|
1284
|
-
if (i === exports.INSPECT_MAX_BYTES) {
|
|
1285
|
-
out[i + 1] = '...'
|
|
1286
|
-
break
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
return '<Buffer ' + out.join(' ') + '>'
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
1646
|
/**
|
|
1293
1647
|
* Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
|
|
1294
1648
|
* Added in Node 0.12. Only available in browsers that support ArrayBuffer.
|
|
1295
1649
|
*/
|
|
1296
|
-
Buffer.prototype.toArrayBuffer = function () {
|
|
1650
|
+
Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
|
|
1297
1651
|
if (typeof Uint8Array !== 'undefined') {
|
|
1298
|
-
if (TYPED_ARRAY_SUPPORT) {
|
|
1652
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
1299
1653
|
return (new Buffer(this)).buffer
|
|
1300
1654
|
} else {
|
|
1301
1655
|
var buf = new Uint8Array(this.length)
|
|
@@ -1305,7 +1659,7 @@ Buffer.prototype.toArrayBuffer = function () {
|
|
|
1305
1659
|
return buf.buffer
|
|
1306
1660
|
}
|
|
1307
1661
|
} else {
|
|
1308
|
-
throw new
|
|
1662
|
+
throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
|
|
1309
1663
|
}
|
|
1310
1664
|
}
|
|
1311
1665
|
|
|
@@ -1317,14 +1671,14 @@ var BP = Buffer.prototype
|
|
|
1317
1671
|
/**
|
|
1318
1672
|
* Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
|
|
1319
1673
|
*/
|
|
1320
|
-
Buffer._augment = function (arr) {
|
|
1674
|
+
Buffer._augment = function _augment (arr) {
|
|
1675
|
+
arr.constructor = Buffer
|
|
1321
1676
|
arr._isBuffer = true
|
|
1322
1677
|
|
|
1323
|
-
// save reference to original Uint8Array
|
|
1324
|
-
arr._get = arr.get
|
|
1678
|
+
// save reference to original Uint8Array set method before overwriting
|
|
1325
1679
|
arr._set = arr.set
|
|
1326
1680
|
|
|
1327
|
-
// deprecated
|
|
1681
|
+
// deprecated
|
|
1328
1682
|
arr.get = BP.get
|
|
1329
1683
|
arr.set = BP.set
|
|
1330
1684
|
|
|
@@ -1334,13 +1688,18 @@ Buffer._augment = function (arr) {
|
|
|
1334
1688
|
arr.toJSON = BP.toJSON
|
|
1335
1689
|
arr.equals = BP.equals
|
|
1336
1690
|
arr.compare = BP.compare
|
|
1691
|
+
arr.indexOf = BP.indexOf
|
|
1337
1692
|
arr.copy = BP.copy
|
|
1338
1693
|
arr.slice = BP.slice
|
|
1694
|
+
arr.readUIntLE = BP.readUIntLE
|
|
1695
|
+
arr.readUIntBE = BP.readUIntBE
|
|
1339
1696
|
arr.readUInt8 = BP.readUInt8
|
|
1340
1697
|
arr.readUInt16LE = BP.readUInt16LE
|
|
1341
1698
|
arr.readUInt16BE = BP.readUInt16BE
|
|
1342
1699
|
arr.readUInt32LE = BP.readUInt32LE
|
|
1343
1700
|
arr.readUInt32BE = BP.readUInt32BE
|
|
1701
|
+
arr.readIntLE = BP.readIntLE
|
|
1702
|
+
arr.readIntBE = BP.readIntBE
|
|
1344
1703
|
arr.readInt8 = BP.readInt8
|
|
1345
1704
|
arr.readInt16LE = BP.readInt16LE
|
|
1346
1705
|
arr.readInt16BE = BP.readInt16BE
|
|
@@ -1351,10 +1710,14 @@ Buffer._augment = function (arr) {
|
|
|
1351
1710
|
arr.readDoubleLE = BP.readDoubleLE
|
|
1352
1711
|
arr.readDoubleBE = BP.readDoubleBE
|
|
1353
1712
|
arr.writeUInt8 = BP.writeUInt8
|
|
1713
|
+
arr.writeUIntLE = BP.writeUIntLE
|
|
1714
|
+
arr.writeUIntBE = BP.writeUIntBE
|
|
1354
1715
|
arr.writeUInt16LE = BP.writeUInt16LE
|
|
1355
1716
|
arr.writeUInt16BE = BP.writeUInt16BE
|
|
1356
1717
|
arr.writeUInt32LE = BP.writeUInt32LE
|
|
1357
1718
|
arr.writeUInt32BE = BP.writeUInt32BE
|
|
1719
|
+
arr.writeIntLE = BP.writeIntLE
|
|
1720
|
+
arr.writeIntBE = BP.writeIntBE
|
|
1358
1721
|
arr.writeInt8 = BP.writeInt8
|
|
1359
1722
|
arr.writeInt16LE = BP.writeInt16LE
|
|
1360
1723
|
arr.writeInt16BE = BP.writeInt16BE
|
|
@@ -1371,11 +1734,13 @@ Buffer._augment = function (arr) {
|
|
|
1371
1734
|
return arr
|
|
1372
1735
|
}
|
|
1373
1736
|
|
|
1374
|
-
var INVALID_BASE64_RE = /[^+\/0-9A-z]/g
|
|
1737
|
+
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
|
|
1375
1738
|
|
|
1376
1739
|
function base64clean (str) {
|
|
1377
1740
|
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
|
1378
1741
|
str = stringtrim(str).replace(INVALID_BASE64_RE, '')
|
|
1742
|
+
// Node converts strings with length < 2 to ''
|
|
1743
|
+
if (str.length < 2) return ''
|
|
1379
1744
|
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
|
1380
1745
|
while (str.length % 4 !== 0) {
|
|
1381
1746
|
str = str + '='
|
|
@@ -1388,39 +1753,89 @@ function stringtrim (str) {
|
|
|
1388
1753
|
return str.replace(/^\s+|\s+$/g, '')
|
|
1389
1754
|
}
|
|
1390
1755
|
|
|
1391
|
-
function isArray (subject) {
|
|
1392
|
-
return (Array.isArray || function (subject) {
|
|
1393
|
-
return Object.prototype.toString.call(subject) === '[object Array]'
|
|
1394
|
-
})(subject)
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
function isArrayish (subject) {
|
|
1398
|
-
return isArray(subject) || Buffer.isBuffer(subject) ||
|
|
1399
|
-
subject && typeof subject === 'object' &&
|
|
1400
|
-
typeof subject.length === 'number'
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
1756
|
function toHex (n) {
|
|
1404
1757
|
if (n < 16) return '0' + n.toString(16)
|
|
1405
1758
|
return n.toString(16)
|
|
1406
1759
|
}
|
|
1407
1760
|
|
|
1408
|
-
function utf8ToBytes (
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1761
|
+
function utf8ToBytes (string, units) {
|
|
1762
|
+
units = units || Infinity
|
|
1763
|
+
var codePoint
|
|
1764
|
+
var length = string.length
|
|
1765
|
+
var leadSurrogate = null
|
|
1766
|
+
var bytes = []
|
|
1767
|
+
|
|
1768
|
+
for (var i = 0; i < length; i++) {
|
|
1769
|
+
codePoint = string.charCodeAt(i)
|
|
1770
|
+
|
|
1771
|
+
// is surrogate component
|
|
1772
|
+
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
|
1773
|
+
// last char was a lead
|
|
1774
|
+
if (!leadSurrogate) {
|
|
1775
|
+
// no lead yet
|
|
1776
|
+
if (codePoint > 0xDBFF) {
|
|
1777
|
+
// unexpected trail
|
|
1778
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
1779
|
+
continue
|
|
1780
|
+
} else if (i + 1 === length) {
|
|
1781
|
+
// unpaired lead
|
|
1782
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
1783
|
+
continue
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
// valid lead
|
|
1787
|
+
leadSurrogate = codePoint
|
|
1788
|
+
|
|
1789
|
+
continue
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
// 2 leads in a row
|
|
1793
|
+
if (codePoint < 0xDC00) {
|
|
1794
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
1795
|
+
leadSurrogate = codePoint
|
|
1796
|
+
continue
|
|
1420
1797
|
}
|
|
1798
|
+
|
|
1799
|
+
// valid surrogate pair
|
|
1800
|
+
codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000
|
|
1801
|
+
} else if (leadSurrogate) {
|
|
1802
|
+
// valid bmp char, but last char was a lead
|
|
1803
|
+
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
leadSurrogate = null
|
|
1807
|
+
|
|
1808
|
+
// encode utf8
|
|
1809
|
+
if (codePoint < 0x80) {
|
|
1810
|
+
if ((units -= 1) < 0) break
|
|
1811
|
+
bytes.push(codePoint)
|
|
1812
|
+
} else if (codePoint < 0x800) {
|
|
1813
|
+
if ((units -= 2) < 0) break
|
|
1814
|
+
bytes.push(
|
|
1815
|
+
codePoint >> 0x6 | 0xC0,
|
|
1816
|
+
codePoint & 0x3F | 0x80
|
|
1817
|
+
)
|
|
1818
|
+
} else if (codePoint < 0x10000) {
|
|
1819
|
+
if ((units -= 3) < 0) break
|
|
1820
|
+
bytes.push(
|
|
1821
|
+
codePoint >> 0xC | 0xE0,
|
|
1822
|
+
codePoint >> 0x6 & 0x3F | 0x80,
|
|
1823
|
+
codePoint & 0x3F | 0x80
|
|
1824
|
+
)
|
|
1825
|
+
} else if (codePoint < 0x110000) {
|
|
1826
|
+
if ((units -= 4) < 0) break
|
|
1827
|
+
bytes.push(
|
|
1828
|
+
codePoint >> 0x12 | 0xF0,
|
|
1829
|
+
codePoint >> 0xC & 0x3F | 0x80,
|
|
1830
|
+
codePoint >> 0x6 & 0x3F | 0x80,
|
|
1831
|
+
codePoint & 0x3F | 0x80
|
|
1832
|
+
)
|
|
1833
|
+
} else {
|
|
1834
|
+
throw new Error('Invalid code point')
|
|
1421
1835
|
}
|
|
1422
1836
|
}
|
|
1423
|
-
|
|
1837
|
+
|
|
1838
|
+
return bytes
|
|
1424
1839
|
}
|
|
1425
1840
|
|
|
1426
1841
|
function asciiToBytes (str) {
|
|
@@ -1432,10 +1847,12 @@ function asciiToBytes (str) {
|
|
|
1432
1847
|
return byteArray
|
|
1433
1848
|
}
|
|
1434
1849
|
|
|
1435
|
-
function utf16leToBytes (str) {
|
|
1850
|
+
function utf16leToBytes (str, units) {
|
|
1436
1851
|
var c, hi, lo
|
|
1437
1852
|
var byteArray = []
|
|
1438
1853
|
for (var i = 0; i < str.length; i++) {
|
|
1854
|
+
if ((units -= 2) < 0) break
|
|
1855
|
+
|
|
1439
1856
|
c = str.charCodeAt(i)
|
|
1440
1857
|
hi = c >> 8
|
|
1441
1858
|
lo = c % 256
|
|
@@ -1447,142 +1864,140 @@ function utf16leToBytes (str) {
|
|
|
1447
1864
|
}
|
|
1448
1865
|
|
|
1449
1866
|
function base64ToBytes (str) {
|
|
1450
|
-
return base64.toByteArray(str)
|
|
1867
|
+
return base64.toByteArray(base64clean(str))
|
|
1451
1868
|
}
|
|
1452
1869
|
|
|
1453
1870
|
function blitBuffer (src, dst, offset, length) {
|
|
1454
1871
|
for (var i = 0; i < length; i++) {
|
|
1455
|
-
if ((i + offset >= dst.length) || (i >= src.length))
|
|
1456
|
-
break
|
|
1872
|
+
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
1457
1873
|
dst[i + offset] = src[i]
|
|
1458
1874
|
}
|
|
1459
1875
|
return i
|
|
1460
1876
|
}
|
|
1461
1877
|
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
assert(value >= min, 'value smaller than minimum allowed value')
|
|
1486
|
-
assert(Math.floor(value) === value, 'value has a fractional component')
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
function verifIEEE754 (value, max, min) {
|
|
1490
|
-
assert(typeof value === 'number', 'cannot write a non-number as a number')
|
|
1491
|
-
assert(value <= max, 'value larger than maximum allowed value')
|
|
1492
|
-
assert(value >= min, 'value smaller than minimum allowed value')
|
|
1493
|
-
}
|
|
1494
|
-
|
|
1495
|
-
function assert (test, message) {
|
|
1496
|
-
if (!test) throw new Error(message || 'Failed assertion')
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
},{"base64-js":2,"ieee754":4}],4:[function(require,module,exports){
|
|
1500
|
-
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
|
|
1501
|
-
var e, m,
|
|
1502
|
-
eLen = nBytes * 8 - mLen - 1,
|
|
1503
|
-
eMax = (1 << eLen) - 1,
|
|
1504
|
-
eBias = eMax >> 1,
|
|
1505
|
-
nBits = -7,
|
|
1506
|
-
i = isLE ? (nBytes - 1) : 0,
|
|
1507
|
-
d = isLE ? -1 : 1,
|
|
1508
|
-
s = buffer[offset + i];
|
|
1509
|
-
|
|
1510
|
-
i += d;
|
|
1511
|
-
|
|
1512
|
-
e = s & ((1 << (-nBits)) - 1);
|
|
1513
|
-
s >>= (-nBits);
|
|
1514
|
-
nBits += eLen;
|
|
1515
|
-
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
|
|
1516
|
-
|
|
1517
|
-
m = e & ((1 << (-nBits)) - 1);
|
|
1518
|
-
e >>= (-nBits);
|
|
1519
|
-
nBits += mLen;
|
|
1520
|
-
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
|
|
1878
|
+
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
1879
|
+
},{"base64-js":2,"ieee754":4,"is-array":5}],4:[function(require,module,exports){
|
|
1880
|
+
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
1881
|
+
var e, m
|
|
1882
|
+
var eLen = nBytes * 8 - mLen - 1
|
|
1883
|
+
var eMax = (1 << eLen) - 1
|
|
1884
|
+
var eBias = eMax >> 1
|
|
1885
|
+
var nBits = -7
|
|
1886
|
+
var i = isLE ? (nBytes - 1) : 0
|
|
1887
|
+
var d = isLE ? -1 : 1
|
|
1888
|
+
var s = buffer[offset + i]
|
|
1889
|
+
|
|
1890
|
+
i += d
|
|
1891
|
+
|
|
1892
|
+
e = s & ((1 << (-nBits)) - 1)
|
|
1893
|
+
s >>= (-nBits)
|
|
1894
|
+
nBits += eLen
|
|
1895
|
+
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
|
1896
|
+
|
|
1897
|
+
m = e & ((1 << (-nBits)) - 1)
|
|
1898
|
+
e >>= (-nBits)
|
|
1899
|
+
nBits += mLen
|
|
1900
|
+
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
|
1521
1901
|
|
|
1522
1902
|
if (e === 0) {
|
|
1523
|
-
e = 1 - eBias
|
|
1903
|
+
e = 1 - eBias
|
|
1524
1904
|
} else if (e === eMax) {
|
|
1525
|
-
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
|
1905
|
+
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
|
1526
1906
|
} else {
|
|
1527
|
-
m = m + Math.pow(2, mLen)
|
|
1528
|
-
e = e - eBias
|
|
1907
|
+
m = m + Math.pow(2, mLen)
|
|
1908
|
+
e = e - eBias
|
|
1529
1909
|
}
|
|
1530
|
-
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
1531
|
-
}
|
|
1910
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
1911
|
+
}
|
|
1532
1912
|
|
|
1533
|
-
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
|
|
1534
|
-
var e, m, c
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1913
|
+
exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
1914
|
+
var e, m, c
|
|
1915
|
+
var eLen = nBytes * 8 - mLen - 1
|
|
1916
|
+
var eMax = (1 << eLen) - 1
|
|
1917
|
+
var eBias = eMax >> 1
|
|
1918
|
+
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
|
|
1919
|
+
var i = isLE ? 0 : (nBytes - 1)
|
|
1920
|
+
var d = isLE ? 1 : -1
|
|
1921
|
+
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
|
|
1542
1922
|
|
|
1543
|
-
value = Math.abs(value)
|
|
1923
|
+
value = Math.abs(value)
|
|
1544
1924
|
|
|
1545
1925
|
if (isNaN(value) || value === Infinity) {
|
|
1546
|
-
m = isNaN(value) ? 1 : 0
|
|
1547
|
-
e = eMax
|
|
1926
|
+
m = isNaN(value) ? 1 : 0
|
|
1927
|
+
e = eMax
|
|
1548
1928
|
} else {
|
|
1549
|
-
e = Math.floor(Math.log(value) / Math.LN2)
|
|
1929
|
+
e = Math.floor(Math.log(value) / Math.LN2)
|
|
1550
1930
|
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
1551
|
-
e
|
|
1552
|
-
c *= 2
|
|
1931
|
+
e--
|
|
1932
|
+
c *= 2
|
|
1553
1933
|
}
|
|
1554
1934
|
if (e + eBias >= 1) {
|
|
1555
|
-
value += rt / c
|
|
1935
|
+
value += rt / c
|
|
1556
1936
|
} else {
|
|
1557
|
-
value += rt * Math.pow(2, 1 - eBias)
|
|
1937
|
+
value += rt * Math.pow(2, 1 - eBias)
|
|
1558
1938
|
}
|
|
1559
1939
|
if (value * c >= 2) {
|
|
1560
|
-
e
|
|
1561
|
-
c /= 2
|
|
1940
|
+
e++
|
|
1941
|
+
c /= 2
|
|
1562
1942
|
}
|
|
1563
1943
|
|
|
1564
1944
|
if (e + eBias >= eMax) {
|
|
1565
|
-
m = 0
|
|
1566
|
-
e = eMax
|
|
1945
|
+
m = 0
|
|
1946
|
+
e = eMax
|
|
1567
1947
|
} else if (e + eBias >= 1) {
|
|
1568
|
-
m = (value * c - 1) * Math.pow(2, mLen)
|
|
1569
|
-
e = e + eBias
|
|
1948
|
+
m = (value * c - 1) * Math.pow(2, mLen)
|
|
1949
|
+
e = e + eBias
|
|
1570
1950
|
} else {
|
|
1571
|
-
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
|
1572
|
-
e = 0
|
|
1951
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
|
1952
|
+
e = 0
|
|
1573
1953
|
}
|
|
1574
1954
|
}
|
|
1575
1955
|
|
|
1576
|
-
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8)
|
|
1956
|
+
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
|
1577
1957
|
|
|
1578
|
-
e = (e << mLen) | m
|
|
1579
|
-
eLen += mLen
|
|
1580
|
-
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8)
|
|
1958
|
+
e = (e << mLen) | m
|
|
1959
|
+
eLen += mLen
|
|
1960
|
+
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
|
1581
1961
|
|
|
1582
|
-
buffer[offset + i - d] |= s * 128
|
|
1583
|
-
}
|
|
1962
|
+
buffer[offset + i - d] |= s * 128
|
|
1963
|
+
}
|
|
1584
1964
|
|
|
1585
1965
|
},{}],5:[function(require,module,exports){
|
|
1966
|
+
|
|
1967
|
+
/**
|
|
1968
|
+
* isArray
|
|
1969
|
+
*/
|
|
1970
|
+
|
|
1971
|
+
var isArray = Array.isArray;
|
|
1972
|
+
|
|
1973
|
+
/**
|
|
1974
|
+
* toString
|
|
1975
|
+
*/
|
|
1976
|
+
|
|
1977
|
+
var str = Object.prototype.toString;
|
|
1978
|
+
|
|
1979
|
+
/**
|
|
1980
|
+
* Whether or not the given `val`
|
|
1981
|
+
* is an array.
|
|
1982
|
+
*
|
|
1983
|
+
* example:
|
|
1984
|
+
*
|
|
1985
|
+
* isArray([]);
|
|
1986
|
+
* // > true
|
|
1987
|
+
* isArray(arguments);
|
|
1988
|
+
* // > false
|
|
1989
|
+
* isArray('');
|
|
1990
|
+
* // > false
|
|
1991
|
+
*
|
|
1992
|
+
* @param {mixed} val
|
|
1993
|
+
* @return {bool}
|
|
1994
|
+
*/
|
|
1995
|
+
|
|
1996
|
+
module.exports = isArray || function (val) {
|
|
1997
|
+
return !! val && '[object Array]' == str.call(val);
|
|
1998
|
+
};
|
|
1999
|
+
|
|
2000
|
+
},{}],6:[function(require,module,exports){
|
|
1586
2001
|
(function (global){
|
|
1587
2002
|
|
|
1588
2003
|
/**
|
|
@@ -1594,7 +2009,14 @@ module.exports = deprecate;
|
|
|
1594
2009
|
/**
|
|
1595
2010
|
* Mark that a method should not be used.
|
|
1596
2011
|
* Returns a modified function which warns once by default.
|
|
1597
|
-
*
|
|
2012
|
+
*
|
|
2013
|
+
* If `localStorage.noDeprecation = true` is set, then it is a no-op.
|
|
2014
|
+
*
|
|
2015
|
+
* If `localStorage.throwDeprecation = true` is set, then deprecated functions
|
|
2016
|
+
* will throw an Error when invoked.
|
|
2017
|
+
*
|
|
2018
|
+
* If `localStorage.traceDeprecation = true` is set, then deprecated functions
|
|
2019
|
+
* will invoke `console.trace()` instead of `console.error()`.
|
|
1598
2020
|
*
|
|
1599
2021
|
* @param {Function} fn - the function to deprecate
|
|
1600
2022
|
* @param {String} msg - the string to print to the console when `fn` is invoked
|
|
@@ -1615,7 +2037,7 @@ function deprecate (fn, msg) {
|
|
|
1615
2037
|
} else if (config('traceDeprecation')) {
|
|
1616
2038
|
console.trace(msg);
|
|
1617
2039
|
} else {
|
|
1618
|
-
console.
|
|
2040
|
+
console.warn(msg);
|
|
1619
2041
|
}
|
|
1620
2042
|
warned = true;
|
|
1621
2043
|
}
|
|
@@ -1634,14 +2056,19 @@ function deprecate (fn, msg) {
|
|
|
1634
2056
|
*/
|
|
1635
2057
|
|
|
1636
2058
|
function config (name) {
|
|
1637
|
-
|
|
2059
|
+
// accessing global.localStorage can trigger a DOMException in sandboxed iframes
|
|
2060
|
+
try {
|
|
2061
|
+
if (!global.localStorage) return false;
|
|
2062
|
+
} catch (_) {
|
|
2063
|
+
return false;
|
|
2064
|
+
}
|
|
1638
2065
|
var val = global.localStorage[name];
|
|
1639
2066
|
if (null == val) return false;
|
|
1640
2067
|
return String(val).toLowerCase() === 'true';
|
|
1641
2068
|
}
|
|
1642
2069
|
|
|
1643
2070
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
1644
|
-
},{}],
|
|
2071
|
+
},{}],7:[function(require,module,exports){
|
|
1645
2072
|
function DOMParser(options){
|
|
1646
2073
|
this.options = options ||{locator:{}};
|
|
1647
2074
|
|
|
@@ -1898,7 +2325,7 @@ if(typeof require == 'function'){
|
|
|
1898
2325
|
exports.DOMParser = DOMParser;
|
|
1899
2326
|
}
|
|
1900
2327
|
|
|
1901
|
-
},{"./dom":
|
|
2328
|
+
},{"./dom":8,"./sax":9}],8:[function(require,module,exports){
|
|
1902
2329
|
/*
|
|
1903
2330
|
* DOM Level 2
|
|
1904
2331
|
* Object DOMException
|
|
@@ -3038,7 +3465,7 @@ if(typeof require == 'function'){
|
|
|
3038
3465
|
exports.XMLSerializer = XMLSerializer;
|
|
3039
3466
|
}
|
|
3040
3467
|
|
|
3041
|
-
},{}],
|
|
3468
|
+
},{}],9:[function(require,module,exports){
|
|
3042
3469
|
//[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
|
|
3043
3470
|
//[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
|
|
3044
3471
|
//[5] Name ::= NameStartChar (NameChar)*
|