plist 1.0.1 → 2.0.1
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 +41 -2
- package/History.md +38 -0
- package/Makefile +33 -1
- package/README.md +58 -5
- package/dist/plist-build.js +3128 -11684
- package/dist/plist-parse.js +1238 -752
- package/dist/plist.js +4435 -11259
- package/index.js +13 -0
- package/lib/build.js +4 -3
- package/lib/parse.js +24 -54
- package/package.json +11 -10
- package/.zuul.yml +0 -18
- package/lib/node.js +0 -49
- package/lib/plist.js +0 -23
- package/test/build.js +0 -133
- package/test/parse.js +0 -448
package/dist/plist-parse.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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
|
/**
|
|
5
5
|
* Module dependencies.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
var deprecate =
|
|
9
|
-
var DOMParser =
|
|
8
|
+
var deprecate = require('util-deprecate');
|
|
9
|
+
var DOMParser = require('xmldom').DOMParser;
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Module exports.
|
|
@@ -201,8 +201,8 @@ function parsePlistXML (node) {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
}).call(this,
|
|
205
|
-
},{"buffer":3,"util-deprecate":
|
|
204
|
+
}).call(this,require("buffer").Buffer)
|
|
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,47 +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
|
-
},{}],3:[function(
|
|
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
|
-
var base64 =
|
|
337
|
-
var ieee754 =
|
|
341
|
+
var base64 = require('base64-js')
|
|
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 `Buffer.
|
|
353
|
+
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
346
354
|
* === true Use Uint8Array implementation (fastest)
|
|
347
|
-
* === false Use Object implementation (compatible
|
|
355
|
+
* === false Use Object implementation (most compatible, even IE6)
|
|
356
|
+
*
|
|
357
|
+
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
|
358
|
+
* Opera 11.6+, iOS 4.2+.
|
|
359
|
+
*
|
|
360
|
+
* Due to various browser bugs, sometimes the Object implementation will be used even
|
|
361
|
+
* when the browser supports typed arrays.
|
|
362
|
+
*
|
|
363
|
+
* Note:
|
|
364
|
+
*
|
|
365
|
+
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
|
|
366
|
+
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
|
|
367
|
+
*
|
|
368
|
+
* - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property
|
|
369
|
+
* on objects.
|
|
370
|
+
*
|
|
371
|
+
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
|
|
372
|
+
*
|
|
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.
|
|
348
378
|
*/
|
|
349
|
-
Buffer.
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
379
|
+
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
|
|
380
|
+
? global.TYPED_ARRAY_SUPPORT
|
|
381
|
+
: typedArraySupport()
|
|
382
|
+
|
|
383
|
+
function typedArraySupport () {
|
|
384
|
+
function Bar () {}
|
|
355
385
|
try {
|
|
356
|
-
var
|
|
357
|
-
var arr = new Uint8Array(buf)
|
|
386
|
+
var arr = new Uint8Array(1)
|
|
358
387
|
arr.foo = function () { return 42 }
|
|
359
|
-
|
|
360
|
-
|
|
388
|
+
arr.constructor = Bar
|
|
389
|
+
return arr.foo() === 42 && // typed array instances can be augmented
|
|
390
|
+
arr.constructor === Bar && // constructor can be set
|
|
391
|
+
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
|
|
392
|
+
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
|
|
361
393
|
} catch (e) {
|
|
362
394
|
return false
|
|
363
395
|
}
|
|
364
|
-
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function kMaxLength () {
|
|
399
|
+
return Buffer.TYPED_ARRAY_SUPPORT
|
|
400
|
+
? 0x7fffffff
|
|
401
|
+
: 0x3fffffff
|
|
402
|
+
}
|
|
365
403
|
|
|
366
404
|
/**
|
|
367
405
|
* Class: Buffer
|
|
@@ -375,142 +413,249 @@ Buffer._useTypedArrays = (function () {
|
|
|
375
413
|
* By augmenting the instances, we can avoid modifying the `Uint8Array`
|
|
376
414
|
* prototype.
|
|
377
415
|
*/
|
|
378
|
-
function Buffer (
|
|
379
|
-
if (!(this instanceof Buffer))
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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
|
+
}
|
|
422
|
+
|
|
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
|
|
390
445
|
}
|
|
391
446
|
}
|
|
447
|
+
return that
|
|
448
|
+
}
|
|
392
449
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if (Buffer.
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
buf.length = length
|
|
412
|
-
buf._isBuffer = true
|
|
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')
|
|
413
468
|
}
|
|
414
469
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
buf._set(subject)
|
|
419
|
-
} else if (isArrayish(subject)) {
|
|
420
|
-
// Treat array-ish objects as a byte array
|
|
421
|
-
for (i = 0; i < length; i++) {
|
|
422
|
-
if (Buffer.isBuffer(subject))
|
|
423
|
-
buf[i] = subject.readUInt8(i)
|
|
424
|
-
else
|
|
425
|
-
buf[i] = subject[i]
|
|
470
|
+
if (typeof ArrayBuffer !== 'undefined') {
|
|
471
|
+
if (object.buffer instanceof ArrayBuffer) {
|
|
472
|
+
return fromTypedArray(that, object)
|
|
426
473
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
} else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
|
|
430
|
-
for (i = 0; i < length; i++) {
|
|
431
|
-
buf[i] = 0
|
|
474
|
+
if (object instanceof ArrayBuffer) {
|
|
475
|
+
return fromArrayBuffer(that, object)
|
|
432
476
|
}
|
|
433
477
|
}
|
|
434
478
|
|
|
435
|
-
return
|
|
479
|
+
if (object.length) return fromArrayLike(that, object)
|
|
480
|
+
|
|
481
|
+
return fromJsonObject(that, object)
|
|
436
482
|
}
|
|
437
483
|
|
|
438
|
-
|
|
439
|
-
|
|
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
|
+
}
|
|
440
490
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
case 'ascii':
|
|
447
|
-
case 'binary':
|
|
448
|
-
case 'base64':
|
|
449
|
-
case 'raw':
|
|
450
|
-
case 'ucs2':
|
|
451
|
-
case 'ucs-2':
|
|
452
|
-
case 'utf16le':
|
|
453
|
-
case 'utf-16le':
|
|
454
|
-
return true
|
|
455
|
-
default:
|
|
456
|
-
return false
|
|
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
|
|
457
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
|
|
458
511
|
}
|
|
459
512
|
|
|
460
|
-
|
|
461
|
-
|
|
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))
|
|
521
|
+
}
|
|
522
|
+
return that
|
|
462
523
|
}
|
|
463
524
|
|
|
464
|
-
|
|
465
|
-
var
|
|
466
|
-
|
|
467
|
-
|
|
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) {
|
|
593
|
+
return !!(b != null && b._isBuffer)
|
|
594
|
+
}
|
|
595
|
+
|
|
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()) {
|
|
468
626
|
case 'hex':
|
|
469
|
-
ret = str.length / 2
|
|
470
|
-
break
|
|
471
627
|
case 'utf8':
|
|
472
628
|
case 'utf-8':
|
|
473
|
-
ret = utf8ToBytes(str).length
|
|
474
|
-
break
|
|
475
629
|
case 'ascii':
|
|
476
630
|
case 'binary':
|
|
477
|
-
case 'raw':
|
|
478
|
-
ret = str.length
|
|
479
|
-
break
|
|
480
631
|
case 'base64':
|
|
481
|
-
|
|
482
|
-
break
|
|
632
|
+
case 'raw':
|
|
483
633
|
case 'ucs2':
|
|
484
634
|
case 'ucs-2':
|
|
485
635
|
case 'utf16le':
|
|
486
636
|
case 'utf-16le':
|
|
487
|
-
|
|
488
|
-
break
|
|
637
|
+
return true
|
|
489
638
|
default:
|
|
490
|
-
|
|
639
|
+
return false
|
|
491
640
|
}
|
|
492
|
-
return ret
|
|
493
641
|
}
|
|
494
642
|
|
|
495
|
-
Buffer.concat = function (list,
|
|
496
|
-
|
|
497
|
-
'list should be an Array.')
|
|
643
|
+
Buffer.concat = function concat (list, length) {
|
|
644
|
+
if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
|
|
498
645
|
|
|
499
646
|
if (list.length === 0) {
|
|
500
647
|
return new Buffer(0)
|
|
501
|
-
} else if (list.length === 1) {
|
|
502
|
-
return list[0]
|
|
503
648
|
}
|
|
504
649
|
|
|
505
650
|
var i
|
|
506
|
-
if (
|
|
507
|
-
|
|
651
|
+
if (length === undefined) {
|
|
652
|
+
length = 0
|
|
508
653
|
for (i = 0; i < list.length; i++) {
|
|
509
|
-
|
|
654
|
+
length += list[i].length
|
|
510
655
|
}
|
|
511
656
|
}
|
|
512
657
|
|
|
513
|
-
var buf = new Buffer(
|
|
658
|
+
var buf = new Buffer(length)
|
|
514
659
|
var pos = 0
|
|
515
660
|
for (i = 0; i < list.length; i++) {
|
|
516
661
|
var item = list[i]
|
|
@@ -520,10 +665,173 @@ Buffer.concat = function (list, totalLength) {
|
|
|
520
665
|
return buf
|
|
521
666
|
}
|
|
522
667
|
|
|
523
|
-
|
|
524
|
-
|
|
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
|
+
}
|
|
701
|
+
}
|
|
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
|
+
}
|
|
749
|
+
}
|
|
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
|
+
}
|
|
525
758
|
|
|
526
|
-
function
|
|
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 += ' ... '
|
|
771
|
+
}
|
|
772
|
+
return '<Buffer ' + str + '>'
|
|
773
|
+
}
|
|
774
|
+
|
|
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
|
+
}
|
|
833
|
+
|
|
834
|
+
function hexWrite (buf, string, offset, length) {
|
|
527
835
|
offset = Number(offset) || 0
|
|
528
836
|
var remaining = buf.length - offset
|
|
529
837
|
if (!length) {
|
|
@@ -537,229 +845,243 @@ function _hexWrite (buf, string, offset, length) {
|
|
|
537
845
|
|
|
538
846
|
// must be an even number of digits
|
|
539
847
|
var strLen = string.length
|
|
540
|
-
|
|
848
|
+
if (strLen % 2 !== 0) throw new Error('Invalid hex string')
|
|
541
849
|
|
|
542
850
|
if (length > strLen / 2) {
|
|
543
851
|
length = strLen / 2
|
|
544
852
|
}
|
|
545
853
|
for (var i = 0; i < length; i++) {
|
|
546
|
-
var
|
|
547
|
-
|
|
548
|
-
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
|
|
549
857
|
}
|
|
550
|
-
Buffer._charsWritten = i * 2
|
|
551
858
|
return i
|
|
552
859
|
}
|
|
553
860
|
|
|
554
|
-
function
|
|
555
|
-
|
|
556
|
-
blitBuffer(utf8ToBytes(string), buf, offset, length)
|
|
557
|
-
return charsWritten
|
|
861
|
+
function utf8Write (buf, string, offset, length) {
|
|
862
|
+
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
|
558
863
|
}
|
|
559
864
|
|
|
560
|
-
function
|
|
561
|
-
|
|
562
|
-
blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
563
|
-
return charsWritten
|
|
865
|
+
function asciiWrite (buf, string, offset, length) {
|
|
866
|
+
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
564
867
|
}
|
|
565
868
|
|
|
566
|
-
function
|
|
567
|
-
return
|
|
869
|
+
function binaryWrite (buf, string, offset, length) {
|
|
870
|
+
return asciiWrite(buf, string, offset, length)
|
|
568
871
|
}
|
|
569
872
|
|
|
570
|
-
function
|
|
571
|
-
|
|
572
|
-
blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
573
|
-
return charsWritten
|
|
873
|
+
function base64Write (buf, string, offset, length) {
|
|
874
|
+
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
574
875
|
}
|
|
575
876
|
|
|
576
|
-
function
|
|
577
|
-
|
|
578
|
-
blitBuffer(utf16leToBytes(string), buf, offset, length)
|
|
579
|
-
return charsWritten
|
|
877
|
+
function ucs2Write (buf, string, offset, length) {
|
|
878
|
+
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
|
580
879
|
}
|
|
581
880
|
|
|
582
|
-
Buffer.prototype.write = function (string, offset, length, encoding) {
|
|
583
|
-
//
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
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 {
|
|
587
899
|
encoding = length
|
|
588
900
|
length = undefined
|
|
589
901
|
}
|
|
590
|
-
|
|
902
|
+
// legacy write(string, encoding, offset, length) - remove in v0.13
|
|
903
|
+
} else {
|
|
591
904
|
var swap = encoding
|
|
592
905
|
encoding = offset
|
|
593
|
-
offset = length
|
|
906
|
+
offset = length | 0
|
|
594
907
|
length = swap
|
|
595
908
|
}
|
|
596
909
|
|
|
597
|
-
offset = Number(offset) || 0
|
|
598
910
|
var remaining = this.length - offset
|
|
599
|
-
if (
|
|
600
|
-
length = remaining
|
|
601
|
-
} else {
|
|
602
|
-
length = Number(length)
|
|
603
|
-
if (length > remaining) {
|
|
604
|
-
length = remaining
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
encoding = String(encoding || 'utf8').toLowerCase()
|
|
911
|
+
if (length === undefined || length > remaining) length = remaining
|
|
608
912
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
case 'hex':
|
|
612
|
-
ret = _hexWrite(this, string, offset, length)
|
|
613
|
-
break
|
|
614
|
-
case 'utf8':
|
|
615
|
-
case 'utf-8':
|
|
616
|
-
ret = _utf8Write(this, string, offset, length)
|
|
617
|
-
break
|
|
618
|
-
case 'ascii':
|
|
619
|
-
ret = _asciiWrite(this, string, offset, length)
|
|
620
|
-
break
|
|
621
|
-
case 'binary':
|
|
622
|
-
ret = _binaryWrite(this, string, offset, length)
|
|
623
|
-
break
|
|
624
|
-
case 'base64':
|
|
625
|
-
ret = _base64Write(this, string, offset, length)
|
|
626
|
-
break
|
|
627
|
-
case 'ucs2':
|
|
628
|
-
case 'ucs-2':
|
|
629
|
-
case 'utf16le':
|
|
630
|
-
case 'utf-16le':
|
|
631
|
-
ret = _utf16leWrite(this, string, offset, length)
|
|
632
|
-
break
|
|
633
|
-
default:
|
|
634
|
-
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')
|
|
635
915
|
}
|
|
636
|
-
return ret
|
|
637
|
-
}
|
|
638
916
|
|
|
639
|
-
|
|
640
|
-
var self = this
|
|
917
|
+
if (!encoding) encoding = 'utf8'
|
|
641
918
|
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
919
|
+
var loweredCase = false
|
|
920
|
+
for (;;) {
|
|
921
|
+
switch (encoding) {
|
|
922
|
+
case 'hex':
|
|
923
|
+
return hexWrite(this, string, offset, length)
|
|
647
924
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
925
|
+
case 'utf8':
|
|
926
|
+
case 'utf-8':
|
|
927
|
+
return utf8Write(this, string, offset, length)
|
|
651
928
|
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
case 'utf-16le':
|
|
674
|
-
ret = _utf16leSlice(self, start, end)
|
|
675
|
-
break
|
|
676
|
-
default:
|
|
677
|
-
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
|
+
}
|
|
678
950
|
}
|
|
679
|
-
return ret
|
|
680
951
|
}
|
|
681
952
|
|
|
682
|
-
Buffer.prototype.toJSON = function () {
|
|
953
|
+
Buffer.prototype.toJSON = function toJSON () {
|
|
683
954
|
return {
|
|
684
955
|
type: 'Buffer',
|
|
685
956
|
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
686
957
|
}
|
|
687
958
|
}
|
|
688
959
|
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
960
|
+
function base64Slice (buf, start, end) {
|
|
961
|
+
if (start === 0 && end === buf.length) {
|
|
962
|
+
return base64.fromByteArray(buf)
|
|
963
|
+
} else {
|
|
964
|
+
return base64.fromByteArray(buf.slice(start, end))
|
|
965
|
+
}
|
|
966
|
+
}
|
|
692
967
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
968
|
+
function utf8Slice (buf, start, end) {
|
|
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
|
+
}
|
|
696
1021
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
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
|
|
1032
|
+
}
|
|
700
1033
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
'targetStart out of bounds')
|
|
705
|
-
assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
|
|
706
|
-
assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
|
|
1034
|
+
res.push(codePoint)
|
|
1035
|
+
i += bytesPerSequence
|
|
1036
|
+
}
|
|
707
1037
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
end = this.length
|
|
711
|
-
if (target.length - target_start < end - start)
|
|
712
|
-
end = target.length - target_start + start
|
|
1038
|
+
return decodeCodePointsArray(res)
|
|
1039
|
+
}
|
|
713
1040
|
|
|
714
|
-
|
|
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
|
|
715
1045
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
target._set(this.subarray(start, start + len), target_start)
|
|
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()
|
|
721
1050
|
}
|
|
722
|
-
}
|
|
723
1051
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
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
|
+
)
|
|
729
1060
|
}
|
|
1061
|
+
return res
|
|
730
1062
|
}
|
|
731
1063
|
|
|
732
|
-
function
|
|
733
|
-
var
|
|
734
|
-
var tmp = ''
|
|
1064
|
+
function asciiSlice (buf, start, end) {
|
|
1065
|
+
var ret = ''
|
|
735
1066
|
end = Math.min(buf.length, end)
|
|
736
1067
|
|
|
737
1068
|
for (var i = start; i < end; i++) {
|
|
738
|
-
|
|
739
|
-
res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
|
|
740
|
-
tmp = ''
|
|
741
|
-
} else {
|
|
742
|
-
tmp += '%' + buf[i].toString(16)
|
|
743
|
-
}
|
|
1069
|
+
ret += String.fromCharCode(buf[i] & 0x7F)
|
|
744
1070
|
}
|
|
745
|
-
|
|
746
|
-
return res + decodeUtf8Char(tmp)
|
|
1071
|
+
return ret
|
|
747
1072
|
}
|
|
748
1073
|
|
|
749
|
-
function
|
|
1074
|
+
function binarySlice (buf, start, end) {
|
|
750
1075
|
var ret = ''
|
|
751
1076
|
end = Math.min(buf.length, end)
|
|
752
1077
|
|
|
753
|
-
for (var i = start; i < end; i++)
|
|
1078
|
+
for (var i = start; i < end; i++) {
|
|
754
1079
|
ret += String.fromCharCode(buf[i])
|
|
1080
|
+
}
|
|
755
1081
|
return ret
|
|
756
1082
|
}
|
|
757
1083
|
|
|
758
|
-
function
|
|
759
|
-
return _asciiSlice(buf, start, end)
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
function _hexSlice (buf, start, end) {
|
|
1084
|
+
function hexSlice (buf, start, end) {
|
|
763
1085
|
var len = buf.length
|
|
764
1086
|
|
|
765
1087
|
if (!start || start < 0) start = 0
|
|
@@ -772,499 +1094,591 @@ function _hexSlice (buf, start, end) {
|
|
|
772
1094
|
return out
|
|
773
1095
|
}
|
|
774
1096
|
|
|
775
|
-
function
|
|
1097
|
+
function utf16leSlice (buf, start, end) {
|
|
776
1098
|
var bytes = buf.slice(start, end)
|
|
777
1099
|
var res = ''
|
|
778
1100
|
for (var i = 0; i < bytes.length; i += 2) {
|
|
779
|
-
res += String.fromCharCode(bytes[i] + bytes[i+1] * 256)
|
|
1101
|
+
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
|
|
780
1102
|
}
|
|
781
1103
|
return res
|
|
782
1104
|
}
|
|
783
1105
|
|
|
784
|
-
Buffer.prototype.slice = function (start, end) {
|
|
1106
|
+
Buffer.prototype.slice = function slice (start, end) {
|
|
785
1107
|
var len = this.length
|
|
786
|
-
start =
|
|
787
|
-
end =
|
|
1108
|
+
start = ~~start
|
|
1109
|
+
end = end === undefined ? len : ~~end
|
|
1110
|
+
|
|
1111
|
+
if (start < 0) {
|
|
1112
|
+
start += len
|
|
1113
|
+
if (start < 0) start = 0
|
|
1114
|
+
} else if (start > len) {
|
|
1115
|
+
start = len
|
|
1116
|
+
}
|
|
788
1117
|
|
|
789
|
-
if (
|
|
790
|
-
|
|
1118
|
+
if (end < 0) {
|
|
1119
|
+
end += len
|
|
1120
|
+
if (end < 0) end = 0
|
|
1121
|
+
} else if (end > len) {
|
|
1122
|
+
end = len
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
if (end < start) end = start
|
|
1126
|
+
|
|
1127
|
+
var newBuf
|
|
1128
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
1129
|
+
newBuf = Buffer._augment(this.subarray(start, end))
|
|
791
1130
|
} else {
|
|
792
1131
|
var sliceLen = end - start
|
|
793
|
-
|
|
1132
|
+
newBuf = new Buffer(sliceLen, undefined)
|
|
794
1133
|
for (var i = 0; i < sliceLen; i++) {
|
|
795
1134
|
newBuf[i] = this[i + start]
|
|
796
1135
|
}
|
|
797
|
-
return newBuf
|
|
798
1136
|
}
|
|
799
|
-
}
|
|
800
1137
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
return this.readUInt8(offset)
|
|
1138
|
+
if (newBuf.length) newBuf.parent = this.parent || this
|
|
1139
|
+
|
|
1140
|
+
return newBuf
|
|
805
1141
|
}
|
|
806
1142
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
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')
|
|
811
1149
|
}
|
|
812
1150
|
|
|
813
|
-
Buffer.prototype.
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
}
|
|
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)
|
|
818
1155
|
|
|
819
|
-
|
|
820
|
-
|
|
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
|
+
}
|
|
821
1162
|
|
|
822
|
-
return
|
|
1163
|
+
return val
|
|
823
1164
|
}
|
|
824
1165
|
|
|
825
|
-
function
|
|
1166
|
+
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
|
1167
|
+
offset = offset | 0
|
|
1168
|
+
byteLength = byteLength | 0
|
|
826
1169
|
if (!noAssert) {
|
|
827
|
-
|
|
828
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
829
|
-
assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
|
|
1170
|
+
checkOffset(offset, byteLength, this.length)
|
|
830
1171
|
}
|
|
831
1172
|
|
|
832
|
-
var
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
var val
|
|
837
|
-
if (littleEndian) {
|
|
838
|
-
val = buf[offset]
|
|
839
|
-
if (offset + 1 < len)
|
|
840
|
-
val |= buf[offset + 1] << 8
|
|
841
|
-
} else {
|
|
842
|
-
val = buf[offset] << 8
|
|
843
|
-
if (offset + 1 < len)
|
|
844
|
-
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
|
|
845
1177
|
}
|
|
1178
|
+
|
|
846
1179
|
return val
|
|
847
1180
|
}
|
|
848
1181
|
|
|
849
|
-
Buffer.prototype.
|
|
850
|
-
|
|
1182
|
+
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
|
1183
|
+
if (!noAssert) checkOffset(offset, 1, this.length)
|
|
1184
|
+
return this[offset]
|
|
851
1185
|
}
|
|
852
1186
|
|
|
853
|
-
Buffer.prototype.
|
|
854
|
-
|
|
1187
|
+
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
|
1188
|
+
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
1189
|
+
return this[offset] | (this[offset + 1] << 8)
|
|
855
1190
|
}
|
|
856
1191
|
|
|
857
|
-
function
|
|
858
|
-
if (!noAssert)
|
|
859
|
-
|
|
860
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
861
|
-
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
var len = buf.length
|
|
865
|
-
if (offset >= len)
|
|
866
|
-
return
|
|
867
|
-
|
|
868
|
-
var val
|
|
869
|
-
if (littleEndian) {
|
|
870
|
-
if (offset + 2 < len)
|
|
871
|
-
val = buf[offset + 2] << 16
|
|
872
|
-
if (offset + 1 < len)
|
|
873
|
-
val |= buf[offset + 1] << 8
|
|
874
|
-
val |= buf[offset]
|
|
875
|
-
if (offset + 3 < len)
|
|
876
|
-
val = val + (buf[offset + 3] << 24 >>> 0)
|
|
877
|
-
} else {
|
|
878
|
-
if (offset + 1 < len)
|
|
879
|
-
val = buf[offset + 1] << 16
|
|
880
|
-
if (offset + 2 < len)
|
|
881
|
-
val |= buf[offset + 2] << 8
|
|
882
|
-
if (offset + 3 < len)
|
|
883
|
-
val |= buf[offset + 3]
|
|
884
|
-
val = val + (buf[offset] << 24 >>> 0)
|
|
885
|
-
}
|
|
886
|
-
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]
|
|
887
1195
|
}
|
|
888
1196
|
|
|
889
|
-
Buffer.prototype.readUInt32LE = function (offset, noAssert) {
|
|
890
|
-
|
|
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)
|
|
891
1204
|
}
|
|
892
1205
|
|
|
893
|
-
Buffer.prototype.readUInt32BE = function (offset, noAssert) {
|
|
894
|
-
|
|
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])
|
|
895
1213
|
}
|
|
896
1214
|
|
|
897
|
-
Buffer.prototype.
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
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
|
|
902
1225
|
}
|
|
1226
|
+
mul *= 0x80
|
|
903
1227
|
|
|
904
|
-
if (
|
|
905
|
-
return
|
|
1228
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
|
906
1229
|
|
|
907
|
-
|
|
908
|
-
if (neg)
|
|
909
|
-
return (0xff - this[offset] + 1) * -1
|
|
910
|
-
else
|
|
911
|
-
return this[offset]
|
|
1230
|
+
return val
|
|
912
1231
|
}
|
|
913
1232
|
|
|
914
|
-
function
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
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
|
|
919
1243
|
}
|
|
1244
|
+
mul *= 0x80
|
|
920
1245
|
|
|
921
|
-
|
|
922
|
-
if (offset >= len)
|
|
923
|
-
return
|
|
1246
|
+
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
|
924
1247
|
|
|
925
|
-
|
|
926
|
-
var neg = val & 0x8000
|
|
927
|
-
if (neg)
|
|
928
|
-
return (0xffff - val + 1) * -1
|
|
929
|
-
else
|
|
930
|
-
return val
|
|
1248
|
+
return val
|
|
931
1249
|
}
|
|
932
1250
|
|
|
933
|
-
Buffer.prototype.
|
|
934
|
-
|
|
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)
|
|
935
1255
|
}
|
|
936
1256
|
|
|
937
|
-
Buffer.prototype.
|
|
938
|
-
|
|
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
|
|
939
1261
|
}
|
|
940
1262
|
|
|
941
|
-
function
|
|
942
|
-
if (!noAssert)
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
var len = buf.length
|
|
949
|
-
if (offset >= len)
|
|
950
|
-
return
|
|
951
|
-
|
|
952
|
-
var val = _readUInt32(buf, offset, littleEndian, true)
|
|
953
|
-
var neg = val & 0x80000000
|
|
954
|
-
if (neg)
|
|
955
|
-
return (0xffffffff - val + 1) * -1
|
|
956
|
-
else
|
|
957
|
-
return val
|
|
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
|
|
958
1267
|
}
|
|
959
1268
|
|
|
960
|
-
Buffer.prototype.readInt32LE = function (offset, noAssert) {
|
|
961
|
-
|
|
962
|
-
}
|
|
1269
|
+
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
|
1270
|
+
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
963
1271
|
|
|
964
|
-
|
|
965
|
-
|
|
1272
|
+
return (this[offset]) |
|
|
1273
|
+
(this[offset + 1] << 8) |
|
|
1274
|
+
(this[offset + 2] << 16) |
|
|
1275
|
+
(this[offset + 3] << 24)
|
|
966
1276
|
}
|
|
967
1277
|
|
|
968
|
-
function
|
|
969
|
-
if (!noAssert)
|
|
970
|
-
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
971
|
-
assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
|
972
|
-
}
|
|
1278
|
+
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
|
1279
|
+
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
973
1280
|
|
|
974
|
-
return
|
|
1281
|
+
return (this[offset] << 24) |
|
|
1282
|
+
(this[offset + 1] << 16) |
|
|
1283
|
+
(this[offset + 2] << 8) |
|
|
1284
|
+
(this[offset + 3])
|
|
975
1285
|
}
|
|
976
1286
|
|
|
977
|
-
Buffer.prototype.readFloatLE = function (offset, noAssert) {
|
|
978
|
-
|
|
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)
|
|
979
1290
|
}
|
|
980
1291
|
|
|
981
|
-
Buffer.prototype.readFloatBE = function (offset, noAssert) {
|
|
982
|
-
|
|
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)
|
|
983
1295
|
}
|
|
984
1296
|
|
|
985
|
-
function
|
|
986
|
-
if (!noAssert)
|
|
987
|
-
|
|
988
|
-
assert(offset + 7 < buf.length, 'Trying to read beyond buffer length')
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
return ieee754.read(buf, offset, littleEndian, 52, 8)
|
|
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)
|
|
992
1300
|
}
|
|
993
1301
|
|
|
994
|
-
Buffer.prototype.
|
|
995
|
-
|
|
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)
|
|
996
1305
|
}
|
|
997
1306
|
|
|
998
|
-
|
|
999
|
-
|
|
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')
|
|
1000
1311
|
}
|
|
1001
1312
|
|
|
1002
|
-
Buffer.prototype.
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
verifuint(value, 0xff)
|
|
1008
|
-
}
|
|
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)
|
|
1009
1318
|
|
|
1010
|
-
|
|
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
|
+
}
|
|
1011
1325
|
|
|
1012
|
-
|
|
1326
|
+
return offset + byteLength
|
|
1013
1327
|
}
|
|
1014
1328
|
|
|
1015
|
-
function
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
|
|
1021
|
-
verifuint(value, 0xffff)
|
|
1022
|
-
}
|
|
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)
|
|
1023
1334
|
|
|
1024
|
-
var
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
buf[offset + i] =
|
|
1030
|
-
(value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
|
1031
|
-
(littleEndian ? i : 1 - i) * 8
|
|
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
|
|
1032
1340
|
}
|
|
1033
|
-
}
|
|
1034
1341
|
|
|
1035
|
-
|
|
1036
|
-
_writeUInt16(this, value, offset, true, noAssert)
|
|
1342
|
+
return offset + byteLength
|
|
1037
1343
|
}
|
|
1038
1344
|
|
|
1039
|
-
Buffer.prototype.
|
|
1040
|
-
|
|
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)
|
|
1351
|
+
return offset + 1
|
|
1041
1352
|
}
|
|
1042
1353
|
|
|
1043
|
-
function
|
|
1044
|
-
if (
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
|
|
1049
|
-
verifuint(value, 0xffffffff)
|
|
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
|
|
1050
1359
|
}
|
|
1360
|
+
}
|
|
1051
1361
|
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
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)
|
|
1371
|
+
}
|
|
1372
|
+
return offset + 2
|
|
1373
|
+
}
|
|
1055
1374
|
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
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)
|
|
1059
1384
|
}
|
|
1385
|
+
return offset + 2
|
|
1060
1386
|
}
|
|
1061
1387
|
|
|
1062
|
-
|
|
1063
|
-
|
|
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
|
|
1392
|
+
}
|
|
1064
1393
|
}
|
|
1065
1394
|
|
|
1066
|
-
Buffer.prototype.
|
|
1067
|
-
|
|
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)
|
|
1406
|
+
}
|
|
1407
|
+
return offset + 4
|
|
1408
|
+
}
|
|
1409
|
+
|
|
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
|
|
1068
1423
|
}
|
|
1069
1424
|
|
|
1070
|
-
Buffer.prototype.
|
|
1425
|
+
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
|
1426
|
+
value = +value
|
|
1427
|
+
offset = offset | 0
|
|
1071
1428
|
if (!noAssert) {
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
verifsint(value, 0x7f, -0x80)
|
|
1429
|
+
var limit = Math.pow(2, 8 * byteLength - 1)
|
|
1430
|
+
|
|
1431
|
+
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
|
1076
1432
|
}
|
|
1077
1433
|
|
|
1078
|
-
|
|
1079
|
-
|
|
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
|
+
}
|
|
1080
1441
|
|
|
1081
|
-
|
|
1082
|
-
this.writeUInt8(value, offset, noAssert)
|
|
1083
|
-
else
|
|
1084
|
-
this.writeUInt8(0xff + value + 1, offset, noAssert)
|
|
1442
|
+
return offset + byteLength
|
|
1085
1443
|
}
|
|
1086
1444
|
|
|
1087
|
-
function
|
|
1445
|
+
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
|
1446
|
+
value = +value
|
|
1447
|
+
offset = offset | 0
|
|
1088
1448
|
if (!noAssert) {
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
|
|
1093
|
-
verifsint(value, 0x7fff, -0x8000)
|
|
1449
|
+
var limit = Math.pow(2, 8 * byteLength - 1)
|
|
1450
|
+
|
|
1451
|
+
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
|
1094
1452
|
}
|
|
1095
1453
|
|
|
1096
|
-
var
|
|
1097
|
-
|
|
1098
|
-
|
|
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
|
+
}
|
|
1099
1461
|
|
|
1100
|
-
|
|
1101
|
-
_writeUInt16(buf, value, offset, littleEndian, noAssert)
|
|
1102
|
-
else
|
|
1103
|
-
_writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
|
|
1462
|
+
return offset + byteLength
|
|
1104
1463
|
}
|
|
1105
1464
|
|
|
1106
|
-
Buffer.prototype.
|
|
1107
|
-
|
|
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
|
|
1108
1473
|
}
|
|
1109
1474
|
|
|
1110
|
-
Buffer.prototype.
|
|
1111
|
-
|
|
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
|
|
1112
1486
|
}
|
|
1113
1487
|
|
|
1114
|
-
function
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
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)
|
|
1497
|
+
}
|
|
1498
|
+
return offset + 2
|
|
1499
|
+
}
|
|
1500
|
+
|
|
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)
|
|
1121
1512
|
}
|
|
1513
|
+
return offset + 4
|
|
1514
|
+
}
|
|
1515
|
+
|
|
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
|
|
1530
|
+
}
|
|
1122
1531
|
|
|
1123
|
-
|
|
1124
|
-
if (
|
|
1125
|
-
|
|
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')
|
|
1536
|
+
}
|
|
1126
1537
|
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1538
|
+
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
1539
|
+
if (!noAssert) {
|
|
1540
|
+
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
|
1541
|
+
}
|
|
1542
|
+
ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
|
1543
|
+
return offset + 4
|
|
1131
1544
|
}
|
|
1132
1545
|
|
|
1133
|
-
Buffer.prototype.
|
|
1134
|
-
|
|
1546
|
+
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
|
1547
|
+
return writeFloat(this, value, offset, true, noAssert)
|
|
1135
1548
|
}
|
|
1136
1549
|
|
|
1137
|
-
Buffer.prototype.
|
|
1138
|
-
|
|
1550
|
+
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
|
1551
|
+
return writeFloat(this, value, offset, false, noAssert)
|
|
1139
1552
|
}
|
|
1140
1553
|
|
|
1141
|
-
function
|
|
1554
|
+
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
1142
1555
|
if (!noAssert) {
|
|
1143
|
-
|
|
1144
|
-
assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
|
1145
|
-
assert(offset !== undefined && offset !== null, 'missing offset')
|
|
1146
|
-
assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
|
|
1147
|
-
verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
|
1556
|
+
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
|
1148
1557
|
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
if (offset >= len)
|
|
1152
|
-
return
|
|
1153
|
-
|
|
1154
|
-
ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
|
1558
|
+
ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
|
1559
|
+
return offset + 8
|
|
1155
1560
|
}
|
|
1156
1561
|
|
|
1157
|
-
Buffer.prototype.
|
|
1158
|
-
|
|
1562
|
+
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
|
1563
|
+
return writeDouble(this, value, offset, true, noAssert)
|
|
1159
1564
|
}
|
|
1160
1565
|
|
|
1161
|
-
Buffer.prototype.
|
|
1162
|
-
|
|
1566
|
+
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
|
1567
|
+
return writeDouble(this, value, offset, false, noAssert)
|
|
1163
1568
|
}
|
|
1164
1569
|
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
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')
|
|
1173
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')
|
|
1174
1588
|
|
|
1175
|
-
|
|
1176
|
-
if (
|
|
1177
|
-
|
|
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
|
+
}
|
|
1178
1594
|
|
|
1179
|
-
|
|
1180
|
-
|
|
1595
|
+
var len = end - start
|
|
1596
|
+
var i
|
|
1181
1597
|
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
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
|
+
}
|
|
1185
1611
|
|
|
1186
|
-
|
|
1187
|
-
_writeDouble(this, value, offset, false, noAssert)
|
|
1612
|
+
return len
|
|
1188
1613
|
}
|
|
1189
1614
|
|
|
1190
1615
|
// fill(value, start=0, end=buffer.length)
|
|
1191
|
-
Buffer.prototype.fill = function (value, start, end) {
|
|
1616
|
+
Buffer.prototype.fill = function fill (value, start, end) {
|
|
1192
1617
|
if (!value) value = 0
|
|
1193
1618
|
if (!start) start = 0
|
|
1194
1619
|
if (!end) end = this.length
|
|
1195
1620
|
|
|
1196
|
-
if (
|
|
1197
|
-
value = value.charCodeAt(0)
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
assert(typeof value === 'number' && !isNaN(value), 'value is not a number')
|
|
1201
|
-
assert(end >= start, 'end < start')
|
|
1621
|
+
if (end < start) throw new RangeError('end < start')
|
|
1202
1622
|
|
|
1203
1623
|
// Fill 0 bytes; we're done
|
|
1204
1624
|
if (end === start) return
|
|
1205
1625
|
if (this.length === 0) return
|
|
1206
1626
|
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
for (var i = start; i < end; i++) {
|
|
1211
|
-
this[i] = value
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
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')
|
|
1214
1629
|
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1630
|
+
var i
|
|
1631
|
+
if (typeof value === 'number') {
|
|
1632
|
+
for (i = start; i < end; i++) {
|
|
1633
|
+
this[i] = value
|
|
1634
|
+
}
|
|
1635
|
+
} else {
|
|
1636
|
+
var bytes = utf8ToBytes(value.toString())
|
|
1637
|
+
var len = bytes.length
|
|
1638
|
+
for (i = start; i < end; i++) {
|
|
1639
|
+
this[i] = bytes[i % len]
|
|
1223
1640
|
}
|
|
1224
1641
|
}
|
|
1225
|
-
|
|
1642
|
+
|
|
1643
|
+
return this
|
|
1226
1644
|
}
|
|
1227
1645
|
|
|
1228
1646
|
/**
|
|
1229
1647
|
* Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
|
|
1230
1648
|
* Added in Node 0.12. Only available in browsers that support ArrayBuffer.
|
|
1231
1649
|
*/
|
|
1232
|
-
Buffer.prototype.toArrayBuffer = function () {
|
|
1650
|
+
Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
|
|
1233
1651
|
if (typeof Uint8Array !== 'undefined') {
|
|
1234
|
-
if (Buffer.
|
|
1652
|
+
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
1235
1653
|
return (new Buffer(this)).buffer
|
|
1236
1654
|
} else {
|
|
1237
1655
|
var buf = new Uint8Array(this.length)
|
|
1238
|
-
for (var i = 0, len = buf.length; i < len; i += 1)
|
|
1656
|
+
for (var i = 0, len = buf.length; i < len; i += 1) {
|
|
1239
1657
|
buf[i] = this[i]
|
|
1658
|
+
}
|
|
1240
1659
|
return buf.buffer
|
|
1241
1660
|
}
|
|
1242
1661
|
} else {
|
|
1243
|
-
throw new
|
|
1662
|
+
throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
|
|
1244
1663
|
}
|
|
1245
1664
|
}
|
|
1246
1665
|
|
|
1247
1666
|
// HELPER FUNCTIONS
|
|
1248
1667
|
// ================
|
|
1249
1668
|
|
|
1250
|
-
function stringtrim (str) {
|
|
1251
|
-
if (str.trim) return str.trim()
|
|
1252
|
-
return str.replace(/^\s+|\s+$/g, '')
|
|
1253
|
-
}
|
|
1254
|
-
|
|
1255
1669
|
var BP = Buffer.prototype
|
|
1256
1670
|
|
|
1257
1671
|
/**
|
|
1258
1672
|
* Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
|
|
1259
1673
|
*/
|
|
1260
|
-
Buffer._augment = function (arr) {
|
|
1674
|
+
Buffer._augment = function _augment (arr) {
|
|
1675
|
+
arr.constructor = Buffer
|
|
1261
1676
|
arr._isBuffer = true
|
|
1262
1677
|
|
|
1263
|
-
// save reference to original Uint8Array
|
|
1264
|
-
arr._get = arr.get
|
|
1678
|
+
// save reference to original Uint8Array set method before overwriting
|
|
1265
1679
|
arr._set = arr.set
|
|
1266
1680
|
|
|
1267
|
-
// deprecated
|
|
1681
|
+
// deprecated
|
|
1268
1682
|
arr.get = BP.get
|
|
1269
1683
|
arr.set = BP.set
|
|
1270
1684
|
|
|
@@ -1272,13 +1686,20 @@ Buffer._augment = function (arr) {
|
|
|
1272
1686
|
arr.toString = BP.toString
|
|
1273
1687
|
arr.toLocaleString = BP.toString
|
|
1274
1688
|
arr.toJSON = BP.toJSON
|
|
1689
|
+
arr.equals = BP.equals
|
|
1690
|
+
arr.compare = BP.compare
|
|
1691
|
+
arr.indexOf = BP.indexOf
|
|
1275
1692
|
arr.copy = BP.copy
|
|
1276
1693
|
arr.slice = BP.slice
|
|
1694
|
+
arr.readUIntLE = BP.readUIntLE
|
|
1695
|
+
arr.readUIntBE = BP.readUIntBE
|
|
1277
1696
|
arr.readUInt8 = BP.readUInt8
|
|
1278
1697
|
arr.readUInt16LE = BP.readUInt16LE
|
|
1279
1698
|
arr.readUInt16BE = BP.readUInt16BE
|
|
1280
1699
|
arr.readUInt32LE = BP.readUInt32LE
|
|
1281
1700
|
arr.readUInt32BE = BP.readUInt32BE
|
|
1701
|
+
arr.readIntLE = BP.readIntLE
|
|
1702
|
+
arr.readIntBE = BP.readIntBE
|
|
1282
1703
|
arr.readInt8 = BP.readInt8
|
|
1283
1704
|
arr.readInt16LE = BP.readInt16LE
|
|
1284
1705
|
arr.readInt16BE = BP.readInt16BE
|
|
@@ -1289,10 +1710,14 @@ Buffer._augment = function (arr) {
|
|
|
1289
1710
|
arr.readDoubleLE = BP.readDoubleLE
|
|
1290
1711
|
arr.readDoubleBE = BP.readDoubleBE
|
|
1291
1712
|
arr.writeUInt8 = BP.writeUInt8
|
|
1713
|
+
arr.writeUIntLE = BP.writeUIntLE
|
|
1714
|
+
arr.writeUIntBE = BP.writeUIntBE
|
|
1292
1715
|
arr.writeUInt16LE = BP.writeUInt16LE
|
|
1293
1716
|
arr.writeUInt16BE = BP.writeUInt16BE
|
|
1294
1717
|
arr.writeUInt32LE = BP.writeUInt32LE
|
|
1295
1718
|
arr.writeUInt32BE = BP.writeUInt32BE
|
|
1719
|
+
arr.writeIntLE = BP.writeIntLE
|
|
1720
|
+
arr.writeIntBE = BP.writeIntBE
|
|
1296
1721
|
arr.writeInt8 = BP.writeInt8
|
|
1297
1722
|
arr.writeInt16LE = BP.writeInt16LE
|
|
1298
1723
|
arr.writeInt16BE = BP.writeInt16BE
|
|
@@ -1309,35 +1734,23 @@ Buffer._augment = function (arr) {
|
|
|
1309
1734
|
return arr
|
|
1310
1735
|
}
|
|
1311
1736
|
|
|
1312
|
-
|
|
1313
|
-
function clamp (index, len, defaultValue) {
|
|
1314
|
-
if (typeof index !== 'number') return defaultValue
|
|
1315
|
-
index = ~~index; // Coerce to integer.
|
|
1316
|
-
if (index >= len) return len
|
|
1317
|
-
if (index >= 0) return index
|
|
1318
|
-
index += len
|
|
1319
|
-
if (index >= 0) return index
|
|
1320
|
-
return 0
|
|
1321
|
-
}
|
|
1737
|
+
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
|
|
1322
1738
|
|
|
1323
|
-
function
|
|
1324
|
-
//
|
|
1325
|
-
|
|
1326
|
-
//
|
|
1327
|
-
length
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
return
|
|
1333
|
-
return Object.prototype.toString.call(subject) === '[object Array]'
|
|
1334
|
-
})(subject)
|
|
1739
|
+
function base64clean (str) {
|
|
1740
|
+
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
|
1741
|
+
str = stringtrim(str).replace(INVALID_BASE64_RE, '')
|
|
1742
|
+
// Node converts strings with length < 2 to ''
|
|
1743
|
+
if (str.length < 2) return ''
|
|
1744
|
+
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
|
1745
|
+
while (str.length % 4 !== 0) {
|
|
1746
|
+
str = str + '='
|
|
1747
|
+
}
|
|
1748
|
+
return str
|
|
1335
1749
|
}
|
|
1336
1750
|
|
|
1337
|
-
function
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
typeof subject.length === 'number'
|
|
1751
|
+
function stringtrim (str) {
|
|
1752
|
+
if (str.trim) return str.trim()
|
|
1753
|
+
return str.replace(/^\s+|\s+$/g, '')
|
|
1341
1754
|
}
|
|
1342
1755
|
|
|
1343
1756
|
function toHex (n) {
|
|
@@ -1345,21 +1758,84 @@ function toHex (n) {
|
|
|
1345
1758
|
return n.toString(16)
|
|
1346
1759
|
}
|
|
1347
1760
|
|
|
1348
|
-
function utf8ToBytes (
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
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
|
|
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')
|
|
1360
1835
|
}
|
|
1361
1836
|
}
|
|
1362
|
-
|
|
1837
|
+
|
|
1838
|
+
return bytes
|
|
1363
1839
|
}
|
|
1364
1840
|
|
|
1365
1841
|
function asciiToBytes (str) {
|
|
@@ -1371,10 +1847,12 @@ function asciiToBytes (str) {
|
|
|
1371
1847
|
return byteArray
|
|
1372
1848
|
}
|
|
1373
1849
|
|
|
1374
|
-
function utf16leToBytes (str) {
|
|
1850
|
+
function utf16leToBytes (str, units) {
|
|
1375
1851
|
var c, hi, lo
|
|
1376
1852
|
var byteArray = []
|
|
1377
1853
|
for (var i = 0; i < str.length; i++) {
|
|
1854
|
+
if ((units -= 2) < 0) break
|
|
1855
|
+
|
|
1378
1856
|
c = str.charCodeAt(i)
|
|
1379
1857
|
hi = c >> 8
|
|
1380
1858
|
lo = c % 256
|
|
@@ -1386,143 +1864,140 @@ function utf16leToBytes (str) {
|
|
|
1386
1864
|
}
|
|
1387
1865
|
|
|
1388
1866
|
function base64ToBytes (str) {
|
|
1389
|
-
return base64.toByteArray(str)
|
|
1867
|
+
return base64.toByteArray(base64clean(str))
|
|
1390
1868
|
}
|
|
1391
1869
|
|
|
1392
1870
|
function blitBuffer (src, dst, offset, length) {
|
|
1393
|
-
var pos
|
|
1394
1871
|
for (var i = 0; i < length; i++) {
|
|
1395
|
-
if ((i + offset >= dst.length) || (i >= src.length))
|
|
1396
|
-
break
|
|
1872
|
+
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
1397
1873
|
dst[i + offset] = src[i]
|
|
1398
1874
|
}
|
|
1399
1875
|
return i
|
|
1400
1876
|
}
|
|
1401
1877
|
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
* exceed the maximum allowed value.
|
|
1414
|
-
*/
|
|
1415
|
-
function verifuint (value, max) {
|
|
1416
|
-
assert(typeof value === 'number', 'cannot write a non-number as a number')
|
|
1417
|
-
assert(value >= 0, 'specified a negative value for writing an unsigned value')
|
|
1418
|
-
assert(value <= max, 'value is larger than maximum value for type')
|
|
1419
|
-
assert(Math.floor(value) === value, 'value has a fractional component')
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
function verifsint (value, max, min) {
|
|
1423
|
-
assert(typeof value === 'number', 'cannot write a non-number as a number')
|
|
1424
|
-
assert(value <= max, 'value larger than maximum allowed value')
|
|
1425
|
-
assert(value >= min, 'value smaller than minimum allowed value')
|
|
1426
|
-
assert(Math.floor(value) === value, 'value has a fractional component')
|
|
1427
|
-
}
|
|
1428
|
-
|
|
1429
|
-
function verifIEEE754 (value, max, min) {
|
|
1430
|
-
assert(typeof value === 'number', 'cannot write a non-number as a number')
|
|
1431
|
-
assert(value <= max, 'value larger than maximum allowed value')
|
|
1432
|
-
assert(value >= min, 'value smaller than minimum allowed value')
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
function assert (test, message) {
|
|
1436
|
-
if (!test) throw new Error(message || 'Failed assertion')
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
|
-
},{"base64-js":2,"ieee754":4}],4:[function(_dereq_,module,exports){
|
|
1440
|
-
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
|
|
1441
|
-
var e, m,
|
|
1442
|
-
eLen = nBytes * 8 - mLen - 1,
|
|
1443
|
-
eMax = (1 << eLen) - 1,
|
|
1444
|
-
eBias = eMax >> 1,
|
|
1445
|
-
nBits = -7,
|
|
1446
|
-
i = isLE ? (nBytes - 1) : 0,
|
|
1447
|
-
d = isLE ? -1 : 1,
|
|
1448
|
-
s = buffer[offset + i];
|
|
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]
|
|
1449
1889
|
|
|
1450
|
-
i += d
|
|
1890
|
+
i += d
|
|
1451
1891
|
|
|
1452
|
-
e = s & ((1 << (-nBits)) - 1)
|
|
1453
|
-
s >>= (-nBits)
|
|
1454
|
-
nBits += eLen
|
|
1455
|
-
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8)
|
|
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) {}
|
|
1456
1896
|
|
|
1457
|
-
m = e & ((1 << (-nBits)) - 1)
|
|
1458
|
-
e >>= (-nBits)
|
|
1459
|
-
nBits += mLen
|
|
1460
|
-
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8)
|
|
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) {}
|
|
1461
1901
|
|
|
1462
1902
|
if (e === 0) {
|
|
1463
|
-
e = 1 - eBias
|
|
1903
|
+
e = 1 - eBias
|
|
1464
1904
|
} else if (e === eMax) {
|
|
1465
|
-
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
|
1905
|
+
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
|
1466
1906
|
} else {
|
|
1467
|
-
m = m + Math.pow(2, mLen)
|
|
1468
|
-
e = e - eBias
|
|
1907
|
+
m = m + Math.pow(2, mLen)
|
|
1908
|
+
e = e - eBias
|
|
1469
1909
|
}
|
|
1470
|
-
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
1471
|
-
}
|
|
1910
|
+
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
1911
|
+
}
|
|
1472
1912
|
|
|
1473
|
-
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
|
|
1474
|
-
var e, m, c
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
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
|
|
1482
1922
|
|
|
1483
|
-
value = Math.abs(value)
|
|
1923
|
+
value = Math.abs(value)
|
|
1484
1924
|
|
|
1485
1925
|
if (isNaN(value) || value === Infinity) {
|
|
1486
|
-
m = isNaN(value) ? 1 : 0
|
|
1487
|
-
e = eMax
|
|
1926
|
+
m = isNaN(value) ? 1 : 0
|
|
1927
|
+
e = eMax
|
|
1488
1928
|
} else {
|
|
1489
|
-
e = Math.floor(Math.log(value) / Math.LN2)
|
|
1929
|
+
e = Math.floor(Math.log(value) / Math.LN2)
|
|
1490
1930
|
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
1491
|
-
e
|
|
1492
|
-
c *= 2
|
|
1931
|
+
e--
|
|
1932
|
+
c *= 2
|
|
1493
1933
|
}
|
|
1494
1934
|
if (e + eBias >= 1) {
|
|
1495
|
-
value += rt / c
|
|
1935
|
+
value += rt / c
|
|
1496
1936
|
} else {
|
|
1497
|
-
value += rt * Math.pow(2, 1 - eBias)
|
|
1937
|
+
value += rt * Math.pow(2, 1 - eBias)
|
|
1498
1938
|
}
|
|
1499
1939
|
if (value * c >= 2) {
|
|
1500
|
-
e
|
|
1501
|
-
c /= 2
|
|
1940
|
+
e++
|
|
1941
|
+
c /= 2
|
|
1502
1942
|
}
|
|
1503
1943
|
|
|
1504
1944
|
if (e + eBias >= eMax) {
|
|
1505
|
-
m = 0
|
|
1506
|
-
e = eMax
|
|
1945
|
+
m = 0
|
|
1946
|
+
e = eMax
|
|
1507
1947
|
} else if (e + eBias >= 1) {
|
|
1508
|
-
m = (value * c - 1) * Math.pow(2, mLen)
|
|
1509
|
-
e = e + eBias
|
|
1948
|
+
m = (value * c - 1) * Math.pow(2, mLen)
|
|
1949
|
+
e = e + eBias
|
|
1510
1950
|
} else {
|
|
1511
|
-
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
|
1512
|
-
e = 0
|
|
1951
|
+
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
|
1952
|
+
e = 0
|
|
1513
1953
|
}
|
|
1514
1954
|
}
|
|
1515
1955
|
|
|
1516
|
-
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) {}
|
|
1957
|
+
|
|
1958
|
+
e = (e << mLen) | m
|
|
1959
|
+
eLen += mLen
|
|
1960
|
+
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
|
1961
|
+
|
|
1962
|
+
buffer[offset + i - d] |= s * 128
|
|
1963
|
+
}
|
|
1964
|
+
|
|
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;
|
|
1517
1978
|
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
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
|
+
*/
|
|
1521
1995
|
|
|
1522
|
-
|
|
1996
|
+
module.exports = isArray || function (val) {
|
|
1997
|
+
return !! val && '[object Array]' == str.call(val);
|
|
1523
1998
|
};
|
|
1524
1999
|
|
|
1525
|
-
},{}],
|
|
2000
|
+
},{}],6:[function(require,module,exports){
|
|
1526
2001
|
(function (global){
|
|
1527
2002
|
|
|
1528
2003
|
/**
|
|
@@ -1534,7 +2009,14 @@ module.exports = deprecate;
|
|
|
1534
2009
|
/**
|
|
1535
2010
|
* Mark that a method should not be used.
|
|
1536
2011
|
* Returns a modified function which warns once by default.
|
|
1537
|
-
*
|
|
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()`.
|
|
1538
2020
|
*
|
|
1539
2021
|
* @param {Function} fn - the function to deprecate
|
|
1540
2022
|
* @param {String} msg - the string to print to the console when `fn` is invoked
|
|
@@ -1555,7 +2037,7 @@ function deprecate (fn, msg) {
|
|
|
1555
2037
|
} else if (config('traceDeprecation')) {
|
|
1556
2038
|
console.trace(msg);
|
|
1557
2039
|
} else {
|
|
1558
|
-
console.
|
|
2040
|
+
console.warn(msg);
|
|
1559
2041
|
}
|
|
1560
2042
|
warned = true;
|
|
1561
2043
|
}
|
|
@@ -1574,14 +2056,19 @@ function deprecate (fn, msg) {
|
|
|
1574
2056
|
*/
|
|
1575
2057
|
|
|
1576
2058
|
function config (name) {
|
|
1577
|
-
|
|
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
|
+
}
|
|
1578
2065
|
var val = global.localStorage[name];
|
|
1579
2066
|
if (null == val) return false;
|
|
1580
2067
|
return String(val).toLowerCase() === 'true';
|
|
1581
2068
|
}
|
|
1582
2069
|
|
|
1583
|
-
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
1584
|
-
},{}],
|
|
2070
|
+
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
2071
|
+
},{}],7:[function(require,module,exports){
|
|
1585
2072
|
function DOMParser(options){
|
|
1586
2073
|
this.options = options ||{locator:{}};
|
|
1587
2074
|
|
|
@@ -1831,14 +2318,14 @@ function appendElement (hander,node) {
|
|
|
1831
2318
|
}
|
|
1832
2319
|
}//appendChild and setAttributeNS are preformance key
|
|
1833
2320
|
|
|
1834
|
-
if(typeof
|
|
1835
|
-
var XMLReader =
|
|
1836
|
-
var DOMImplementation = exports.DOMImplementation =
|
|
1837
|
-
exports.XMLSerializer =
|
|
2321
|
+
if(typeof require == 'function'){
|
|
2322
|
+
var XMLReader = require('./sax').XMLReader;
|
|
2323
|
+
var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation;
|
|
2324
|
+
exports.XMLSerializer = require('./dom').XMLSerializer ;
|
|
1838
2325
|
exports.DOMParser = DOMParser;
|
|
1839
2326
|
}
|
|
1840
2327
|
|
|
1841
|
-
},{"./dom":
|
|
2328
|
+
},{"./dom":8,"./sax":9}],8:[function(require,module,exports){
|
|
1842
2329
|
/*
|
|
1843
2330
|
* DOM Level 2
|
|
1844
2331
|
* Object DOMException
|
|
@@ -2973,12 +3460,12 @@ try{
|
|
|
2973
3460
|
}catch(e){//ie8
|
|
2974
3461
|
}
|
|
2975
3462
|
|
|
2976
|
-
if(typeof
|
|
3463
|
+
if(typeof require == 'function'){
|
|
2977
3464
|
exports.DOMImplementation = DOMImplementation;
|
|
2978
3465
|
exports.XMLSerializer = XMLSerializer;
|
|
2979
3466
|
}
|
|
2980
3467
|
|
|
2981
|
-
},{}],
|
|
3468
|
+
},{}],9:[function(require,module,exports){
|
|
2982
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]
|
|
2983
3470
|
//[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
|
|
2984
3471
|
//[5] Name ::= NameStartChar (NameChar)*
|
|
@@ -3559,11 +4046,10 @@ function split(source,start){
|
|
|
3559
4046
|
}
|
|
3560
4047
|
}
|
|
3561
4048
|
|
|
3562
|
-
if(typeof
|
|
4049
|
+
if(typeof require == 'function'){
|
|
3563
4050
|
exports.XMLReader = XMLReader;
|
|
3564
4051
|
}
|
|
3565
4052
|
|
|
3566
4053
|
|
|
3567
|
-
},{}]},{},[1])
|
|
3568
|
-
(1)
|
|
4054
|
+
},{}]},{},[1])(1)
|
|
3569
4055
|
});
|