less 3.8.1 → 3.9.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/CHANGELOG.md +19 -0
- package/Gruntfile.js +2 -1
- package/dist/less.js +254 -2136
- package/dist/less.min.js +7 -7
- package/lib/less/functions/list.js +44 -9
- package/lib/less/index.js +1 -1
- package/lib/less/tree/variable-call.js +6 -3
- package/package.json +1 -2
- package/test/browser/less.js +254 -2136
- package/test/css/functions-each.css +34 -0
- package/test/less/functions-each.less +51 -1
- package/test/less-bom/functions-each.less +51 -1
- package/test/css/3rd-party/bootstrap.css +0 -6814
- package/test/less/3rd-party/bootstrap.less +0 -1
- package/test/less-bom/3rd-party/bootstrap.less +0 -1
package/dist/less.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Less - Leaner CSS v3.
|
|
2
|
+
* Less - Leaner CSS v3.9.0
|
|
3
3
|
* http://lesscss.org
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2009-2018, Alexis Sellier <self@cloudhead.net>
|
|
@@ -130,7 +130,7 @@ if (options.onReady) {
|
|
|
130
130
|
less.pageLoadFinished = less.refresh(less.env === 'development').then(resolveOrReject, resolveOrReject);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
},{"../less/default-options":17,"./add-default-options":1,"./index":8,"promise/polyfill":
|
|
133
|
+
},{"../less/default-options":17,"./add-default-options":1,"./index":8,"promise/polyfill":104}],3:[function(require,module,exports){
|
|
134
134
|
var utils = require('./utils');
|
|
135
135
|
module.exports = {
|
|
136
136
|
createCSS: function (document, styles, sheet) {
|
|
@@ -2469,8 +2469,10 @@ module.exports = function(environment) {
|
|
|
2469
2469
|
};
|
|
2470
2470
|
|
|
2471
2471
|
},{"./boolean":21,"./color":23,"./color-blending":22,"./data-uri":24,"./default":25,"./function-caller":26,"./function-registry":27,"./list":29,"./math":31,"./number":32,"./string":33,"./svg":34,"./types":35}],29:[function(require,module,exports){
|
|
2472
|
-
var
|
|
2472
|
+
var Comment = require('../tree/comment'),
|
|
2473
|
+
Dimension = require('../tree/dimension'),
|
|
2473
2474
|
Declaration = require('../tree/declaration'),
|
|
2475
|
+
Expression = require('../tree/expression'),
|
|
2474
2476
|
Ruleset = require('../tree/ruleset'),
|
|
2475
2477
|
Selector = require('../tree/selector'),
|
|
2476
2478
|
Element = require('../tree/element'),
|
|
@@ -2497,8 +2499,36 @@ functionRegistry.addMultiple({
|
|
|
2497
2499
|
length: function(values) {
|
|
2498
2500
|
return new Dimension(getItemsFromNode(values).length);
|
|
2499
2501
|
},
|
|
2502
|
+
/**
|
|
2503
|
+
* Creates a Less list of incremental values.
|
|
2504
|
+
* Modeled after Lodash's range function, also exists natively in PHP
|
|
2505
|
+
*
|
|
2506
|
+
* @param {Dimension} [start=1]
|
|
2507
|
+
* @param {Dimension} end - e.g. 10 or 10px - unit is added to output
|
|
2508
|
+
* @param {Dimension} [step=1]
|
|
2509
|
+
*/
|
|
2510
|
+
range: function(start, end, step) {
|
|
2511
|
+
var from, to, stepValue = 1, list = [];
|
|
2512
|
+
if (end) {
|
|
2513
|
+
to = end;
|
|
2514
|
+
from = start.value;
|
|
2515
|
+
if (step) {
|
|
2516
|
+
stepValue = step.value;
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
else {
|
|
2520
|
+
from = 1;
|
|
2521
|
+
to = start;
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
for (var i = from; i <= to.value; i += stepValue) {
|
|
2525
|
+
list.push(new Dimension(i, to.unit));
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
return new Expression(list);
|
|
2529
|
+
},
|
|
2500
2530
|
each: function(list, rs) {
|
|
2501
|
-
var
|
|
2531
|
+
var rules = [], newRules, iterator;
|
|
2502
2532
|
|
|
2503
2533
|
if (list.value) {
|
|
2504
2534
|
if (Array.isArray(list.value)) {
|
|
@@ -2508,6 +2538,8 @@ functionRegistry.addMultiple({
|
|
|
2508
2538
|
}
|
|
2509
2539
|
} else if (list.ruleset) {
|
|
2510
2540
|
iterator = list.ruleset.rules;
|
|
2541
|
+
} else if (list.rules) {
|
|
2542
|
+
iterator = list.rules;
|
|
2511
2543
|
} else if (Array.isArray(list)) {
|
|
2512
2544
|
iterator = list;
|
|
2513
2545
|
} else {
|
|
@@ -2526,17 +2558,20 @@ functionRegistry.addMultiple({
|
|
|
2526
2558
|
} else {
|
|
2527
2559
|
rs = rs.ruleset;
|
|
2528
2560
|
}
|
|
2529
|
-
|
|
2530
|
-
iterator.
|
|
2531
|
-
|
|
2532
|
-
var key, value;
|
|
2561
|
+
|
|
2562
|
+
for (var i = 0; i < iterator.length; i++) {
|
|
2563
|
+
var key, value, item = iterator[i];
|
|
2533
2564
|
if (item instanceof Declaration) {
|
|
2534
2565
|
key = typeof item.name === 'string' ? item.name : item.name[0].value;
|
|
2535
2566
|
value = item.value;
|
|
2536
2567
|
} else {
|
|
2537
|
-
key = new Dimension(i);
|
|
2568
|
+
key = new Dimension(i + 1);
|
|
2538
2569
|
value = item;
|
|
2539
2570
|
}
|
|
2571
|
+
|
|
2572
|
+
if (item instanceof Comment) {
|
|
2573
|
+
continue;
|
|
2574
|
+
}
|
|
2540
2575
|
|
|
2541
2576
|
newRules = rs.rules.slice(0);
|
|
2542
2577
|
if (valueName) {
|
|
@@ -2546,7 +2581,7 @@ functionRegistry.addMultiple({
|
|
|
2546
2581
|
}
|
|
2547
2582
|
if (indexName) {
|
|
2548
2583
|
newRules.push(new Declaration(indexName,
|
|
2549
|
-
new Dimension(i),
|
|
2584
|
+
new Dimension(i + 1),
|
|
2550
2585
|
false, false, this.index, this.currentFileInfo));
|
|
2551
2586
|
}
|
|
2552
2587
|
if (keyName) {
|
|
@@ -2560,7 +2595,7 @@ functionRegistry.addMultiple({
|
|
|
2560
2595
|
rs.strictImports,
|
|
2561
2596
|
rs.visibilityInfo()
|
|
2562
2597
|
));
|
|
2563
|
-
}
|
|
2598
|
+
}
|
|
2564
2599
|
|
|
2565
2600
|
return new Ruleset([ new(Selector)([ new Element("", '&') ]) ],
|
|
2566
2601
|
rules,
|
|
@@ -2571,7 +2606,7 @@ functionRegistry.addMultiple({
|
|
|
2571
2606
|
}
|
|
2572
2607
|
});
|
|
2573
2608
|
|
|
2574
|
-
},{"../tree/declaration":60,"../tree/dimension":62,"../tree/element":63,"../tree/ruleset":81,"../tree/selector":82,"./function-registry":27}],30:[function(require,module,exports){
|
|
2609
|
+
},{"../tree/comment":57,"../tree/declaration":60,"../tree/dimension":62,"../tree/element":63,"../tree/expression":64,"../tree/ruleset":81,"../tree/selector":82,"./function-registry":27}],30:[function(require,module,exports){
|
|
2575
2610
|
var Dimension = require('../tree/dimension');
|
|
2576
2611
|
|
|
2577
2612
|
var MathHelper = function() {
|
|
@@ -3080,7 +3115,7 @@ module.exports = function(environment, fileManagers) {
|
|
|
3080
3115
|
var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment;
|
|
3081
3116
|
|
|
3082
3117
|
var initial = {
|
|
3083
|
-
version: [3,
|
|
3118
|
+
version: [3, 9, 0],
|
|
3084
3119
|
data: require('./data'),
|
|
3085
3120
|
tree: require('./tree'),
|
|
3086
3121
|
Environment: (Environment = require('./environment/environment')),
|
|
@@ -10476,16 +10511,19 @@ VariableCall.prototype.eval = function (context) {
|
|
|
10476
10511
|
error = new LessError({message: 'Could not evaluate variable call ' + this.variable});
|
|
10477
10512
|
|
|
10478
10513
|
if (!detachedRuleset.ruleset) {
|
|
10479
|
-
if (
|
|
10514
|
+
if (detachedRuleset.rules) {
|
|
10480
10515
|
rules = detachedRuleset;
|
|
10481
10516
|
}
|
|
10517
|
+
else if (Array.isArray(detachedRuleset)) {
|
|
10518
|
+
rules = new Ruleset('', detachedRuleset);
|
|
10519
|
+
}
|
|
10482
10520
|
else if (Array.isArray(detachedRuleset.value)) {
|
|
10483
|
-
rules = detachedRuleset.value;
|
|
10521
|
+
rules = new Ruleset('', detachedRuleset.value);
|
|
10484
10522
|
}
|
|
10485
10523
|
else {
|
|
10486
10524
|
throw error;
|
|
10487
10525
|
}
|
|
10488
|
-
detachedRuleset = new DetachedRuleset(
|
|
10526
|
+
detachedRuleset = new DetachedRuleset(rules);
|
|
10489
10527
|
}
|
|
10490
10528
|
if (detachedRuleset.ruleset) {
|
|
10491
10529
|
return detachedRuleset.callEval(context);
|
|
@@ -10677,7 +10715,7 @@ var utils = {
|
|
|
10677
10715
|
};
|
|
10678
10716
|
|
|
10679
10717
|
module.exports = utils;
|
|
10680
|
-
},{"./constants":12,"clone":
|
|
10718
|
+
},{"./constants":12,"clone":100}],90:[function(require,module,exports){
|
|
10681
10719
|
var tree = require('../tree'),
|
|
10682
10720
|
Visitor = require('./visitor'),
|
|
10683
10721
|
logger = require('../logger'),
|
|
@@ -12307,2070 +12345,237 @@ rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer;
|
|
|
12307
12345
|
|
|
12308
12346
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
12309
12347
|
},{}],100:[function(require,module,exports){
|
|
12310
|
-
|
|
12311
|
-
|
|
12312
|
-
exports.byteLength = byteLength
|
|
12313
|
-
exports.toByteArray = toByteArray
|
|
12314
|
-
exports.fromByteArray = fromByteArray
|
|
12315
|
-
|
|
12316
|
-
var lookup = []
|
|
12317
|
-
var revLookup = []
|
|
12318
|
-
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
|
|
12348
|
+
var clone = (function() {
|
|
12349
|
+
'use strict';
|
|
12319
12350
|
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
lookup[i] = code[i]
|
|
12323
|
-
revLookup[code.charCodeAt(i)] = i
|
|
12351
|
+
function _instanceof(obj, type) {
|
|
12352
|
+
return type != null && obj instanceof type;
|
|
12324
12353
|
}
|
|
12325
12354
|
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
|
|
12332
|
-
|
|
12333
|
-
}
|
|
12334
|
-
|
|
12335
|
-
// the number of equal signs (place holders)
|
|
12336
|
-
// if there are two placeholders, than the two characters before it
|
|
12337
|
-
// represent one byte
|
|
12338
|
-
// if there is only one, then the three characters before it represent 2 bytes
|
|
12339
|
-
// this is just a cheap hack to not do indexOf twice
|
|
12340
|
-
return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
|
|
12355
|
+
var nativeMap;
|
|
12356
|
+
try {
|
|
12357
|
+
nativeMap = Map;
|
|
12358
|
+
} catch(_) {
|
|
12359
|
+
// maybe a reference error because no `Map`. Give it a dummy value that no
|
|
12360
|
+
// value will ever be an instanceof.
|
|
12361
|
+
nativeMap = function() {};
|
|
12341
12362
|
}
|
|
12342
12363
|
|
|
12343
|
-
|
|
12344
|
-
|
|
12345
|
-
|
|
12364
|
+
var nativeSet;
|
|
12365
|
+
try {
|
|
12366
|
+
nativeSet = Set;
|
|
12367
|
+
} catch(_) {
|
|
12368
|
+
nativeSet = function() {};
|
|
12346
12369
|
}
|
|
12347
12370
|
|
|
12348
|
-
|
|
12349
|
-
|
|
12350
|
-
|
|
12351
|
-
|
|
12352
|
-
|
|
12353
|
-
|
|
12354
|
-
|
|
12355
|
-
// if there are placeholders, only get up to the last complete 4 chars
|
|
12356
|
-
l = placeHolders > 0 ? len - 4 : len
|
|
12357
|
-
|
|
12358
|
-
var L = 0
|
|
12371
|
+
var nativePromise;
|
|
12372
|
+
try {
|
|
12373
|
+
nativePromise = Promise;
|
|
12374
|
+
} catch(_) {
|
|
12375
|
+
nativePromise = function() {};
|
|
12376
|
+
}
|
|
12359
12377
|
|
|
12360
|
-
|
|
12361
|
-
|
|
12362
|
-
|
|
12363
|
-
|
|
12364
|
-
|
|
12378
|
+
/**
|
|
12379
|
+
* Clones (copies) an Object using deep copying.
|
|
12380
|
+
*
|
|
12381
|
+
* This function supports circular references by default, but if you are certain
|
|
12382
|
+
* there are no circular references in your object, you can save some CPU time
|
|
12383
|
+
* by calling clone(obj, false).
|
|
12384
|
+
*
|
|
12385
|
+
* Caution: if `circular` is false and `parent` contains circular references,
|
|
12386
|
+
* your program may enter an infinite loop and crash.
|
|
12387
|
+
*
|
|
12388
|
+
* @param `parent` - the object to be cloned
|
|
12389
|
+
* @param `circular` - set to true if the object to be cloned may contain
|
|
12390
|
+
* circular references. (optional - true by default)
|
|
12391
|
+
* @param `depth` - set to a number if the object is only to be cloned to
|
|
12392
|
+
* a particular depth. (optional - defaults to Infinity)
|
|
12393
|
+
* @param `prototype` - sets the prototype to be used when cloning an object.
|
|
12394
|
+
* (optional - defaults to parent prototype).
|
|
12395
|
+
* @param `includeNonEnumerable` - set to true if the non-enumerable properties
|
|
12396
|
+
* should be cloned as well. Non-enumerable properties on the prototype
|
|
12397
|
+
* chain will be ignored. (optional - false by default)
|
|
12398
|
+
*/
|
|
12399
|
+
function clone(parent, circular, depth, prototype, includeNonEnumerable) {
|
|
12400
|
+
if (typeof circular === 'object') {
|
|
12401
|
+
depth = circular.depth;
|
|
12402
|
+
prototype = circular.prototype;
|
|
12403
|
+
includeNonEnumerable = circular.includeNonEnumerable;
|
|
12404
|
+
circular = circular.circular;
|
|
12365
12405
|
}
|
|
12406
|
+
// maintain two arrays for circular references, where corresponding parents
|
|
12407
|
+
// and children have the same index
|
|
12408
|
+
var allParents = [];
|
|
12409
|
+
var allChildren = [];
|
|
12366
12410
|
|
|
12367
|
-
|
|
12368
|
-
tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
|
|
12369
|
-
arr[L++] = tmp & 0xFF
|
|
12370
|
-
} else if (placeHolders === 1) {
|
|
12371
|
-
tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
|
|
12372
|
-
arr[L++] = (tmp >> 8) & 0xFF
|
|
12373
|
-
arr[L++] = tmp & 0xFF
|
|
12374
|
-
}
|
|
12411
|
+
var useBuffer = typeof Buffer != 'undefined';
|
|
12375
12412
|
|
|
12376
|
-
|
|
12377
|
-
|
|
12413
|
+
if (typeof circular == 'undefined')
|
|
12414
|
+
circular = true;
|
|
12378
12415
|
|
|
12379
|
-
|
|
12380
|
-
|
|
12381
|
-
}
|
|
12416
|
+
if (typeof depth == 'undefined')
|
|
12417
|
+
depth = Infinity;
|
|
12382
12418
|
|
|
12383
|
-
function
|
|
12384
|
-
|
|
12385
|
-
|
|
12386
|
-
|
|
12387
|
-
|
|
12388
|
-
output.push(tripletToBase64(tmp))
|
|
12389
|
-
}
|
|
12390
|
-
return output.join('')
|
|
12391
|
-
}
|
|
12419
|
+
// recurse this function so we don't reset allParents and allChildren
|
|
12420
|
+
function _clone(parent, depth) {
|
|
12421
|
+
// cloning null always returns null
|
|
12422
|
+
if (parent === null)
|
|
12423
|
+
return null;
|
|
12392
12424
|
|
|
12393
|
-
|
|
12394
|
-
|
|
12395
|
-
var len = uint8.length
|
|
12396
|
-
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
|
|
12397
|
-
var output = ''
|
|
12398
|
-
var parts = []
|
|
12399
|
-
var maxChunkLength = 16383 // must be multiple of 3
|
|
12400
|
-
|
|
12401
|
-
// go through the array every three bytes, we'll deal with trailing stuff later
|
|
12402
|
-
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
|
12403
|
-
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
|
|
12404
|
-
}
|
|
12425
|
+
if (depth === 0)
|
|
12426
|
+
return parent;
|
|
12405
12427
|
|
|
12406
|
-
|
|
12407
|
-
|
|
12408
|
-
|
|
12409
|
-
|
|
12410
|
-
|
|
12411
|
-
output += '=='
|
|
12412
|
-
} else if (extraBytes === 2) {
|
|
12413
|
-
tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
|
|
12414
|
-
output += lookup[tmp >> 10]
|
|
12415
|
-
output += lookup[(tmp >> 4) & 0x3F]
|
|
12416
|
-
output += lookup[(tmp << 2) & 0x3F]
|
|
12417
|
-
output += '='
|
|
12418
|
-
}
|
|
12428
|
+
var child;
|
|
12429
|
+
var proto;
|
|
12430
|
+
if (typeof parent != 'object') {
|
|
12431
|
+
return parent;
|
|
12432
|
+
}
|
|
12419
12433
|
|
|
12420
|
-
|
|
12434
|
+
if (_instanceof(parent, nativeMap)) {
|
|
12435
|
+
child = new nativeMap();
|
|
12436
|
+
} else if (_instanceof(parent, nativeSet)) {
|
|
12437
|
+
child = new nativeSet();
|
|
12438
|
+
} else if (_instanceof(parent, nativePromise)) {
|
|
12439
|
+
child = new nativePromise(function (resolve, reject) {
|
|
12440
|
+
parent.then(function(value) {
|
|
12441
|
+
resolve(_clone(value, depth - 1));
|
|
12442
|
+
}, function(err) {
|
|
12443
|
+
reject(_clone(err, depth - 1));
|
|
12444
|
+
});
|
|
12445
|
+
});
|
|
12446
|
+
} else if (clone.__isArray(parent)) {
|
|
12447
|
+
child = [];
|
|
12448
|
+
} else if (clone.__isRegExp(parent)) {
|
|
12449
|
+
child = new RegExp(parent.source, __getRegExpFlags(parent));
|
|
12450
|
+
if (parent.lastIndex) child.lastIndex = parent.lastIndex;
|
|
12451
|
+
} else if (clone.__isDate(parent)) {
|
|
12452
|
+
child = new Date(parent.getTime());
|
|
12453
|
+
} else if (useBuffer && Buffer.isBuffer(parent)) {
|
|
12454
|
+
if (Buffer.allocUnsafe) {
|
|
12455
|
+
// Node.js >= 4.5.0
|
|
12456
|
+
child = Buffer.allocUnsafe(parent.length);
|
|
12457
|
+
} else {
|
|
12458
|
+
// Older Node.js versions
|
|
12459
|
+
child = new Buffer(parent.length);
|
|
12460
|
+
}
|
|
12461
|
+
parent.copy(child);
|
|
12462
|
+
return child;
|
|
12463
|
+
} else if (_instanceof(parent, Error)) {
|
|
12464
|
+
child = Object.create(parent);
|
|
12465
|
+
} else {
|
|
12466
|
+
if (typeof prototype == 'undefined') {
|
|
12467
|
+
proto = Object.getPrototypeOf(parent);
|
|
12468
|
+
child = Object.create(proto);
|
|
12469
|
+
}
|
|
12470
|
+
else {
|
|
12471
|
+
child = Object.create(prototype);
|
|
12472
|
+
proto = prototype;
|
|
12473
|
+
}
|
|
12474
|
+
}
|
|
12421
12475
|
|
|
12422
|
-
|
|
12423
|
-
|
|
12476
|
+
if (circular) {
|
|
12477
|
+
var index = allParents.indexOf(parent);
|
|
12424
12478
|
|
|
12425
|
-
|
|
12426
|
-
|
|
12427
|
-
|
|
12428
|
-
|
|
12429
|
-
|
|
12430
|
-
|
|
12431
|
-
*/
|
|
12432
|
-
/* eslint-disable no-proto */
|
|
12479
|
+
if (index != -1) {
|
|
12480
|
+
return allChildren[index];
|
|
12481
|
+
}
|
|
12482
|
+
allParents.push(parent);
|
|
12483
|
+
allChildren.push(child);
|
|
12484
|
+
}
|
|
12433
12485
|
|
|
12434
|
-
|
|
12486
|
+
if (_instanceof(parent, nativeMap)) {
|
|
12487
|
+
parent.forEach(function(value, key) {
|
|
12488
|
+
var keyChild = _clone(key, depth - 1);
|
|
12489
|
+
var valueChild = _clone(value, depth - 1);
|
|
12490
|
+
child.set(keyChild, valueChild);
|
|
12491
|
+
});
|
|
12492
|
+
}
|
|
12493
|
+
if (_instanceof(parent, nativeSet)) {
|
|
12494
|
+
parent.forEach(function(value) {
|
|
12495
|
+
var entryChild = _clone(value, depth - 1);
|
|
12496
|
+
child.add(entryChild);
|
|
12497
|
+
});
|
|
12498
|
+
}
|
|
12435
12499
|
|
|
12436
|
-
var
|
|
12437
|
-
var
|
|
12500
|
+
for (var i in parent) {
|
|
12501
|
+
var attrs;
|
|
12502
|
+
if (proto) {
|
|
12503
|
+
attrs = Object.getOwnPropertyDescriptor(proto, i);
|
|
12504
|
+
}
|
|
12438
12505
|
|
|
12439
|
-
|
|
12440
|
-
|
|
12441
|
-
|
|
12506
|
+
if (attrs && attrs.set == null) {
|
|
12507
|
+
continue;
|
|
12508
|
+
}
|
|
12509
|
+
child[i] = _clone(parent[i], depth - 1);
|
|
12510
|
+
}
|
|
12442
12511
|
|
|
12443
|
-
|
|
12444
|
-
|
|
12512
|
+
if (Object.getOwnPropertySymbols) {
|
|
12513
|
+
var symbols = Object.getOwnPropertySymbols(parent);
|
|
12514
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
12515
|
+
// Don't need to worry about cloning a symbol because it is a primitive,
|
|
12516
|
+
// like a number or string.
|
|
12517
|
+
var symbol = symbols[i];
|
|
12518
|
+
var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
|
|
12519
|
+
if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
|
|
12520
|
+
continue;
|
|
12521
|
+
}
|
|
12522
|
+
child[symbol] = _clone(parent[symbol], depth - 1);
|
|
12523
|
+
if (!descriptor.enumerable) {
|
|
12524
|
+
Object.defineProperty(child, symbol, {
|
|
12525
|
+
enumerable: false
|
|
12526
|
+
});
|
|
12527
|
+
}
|
|
12528
|
+
}
|
|
12529
|
+
}
|
|
12445
12530
|
|
|
12446
|
-
|
|
12447
|
-
|
|
12448
|
-
|
|
12449
|
-
|
|
12450
|
-
|
|
12451
|
-
|
|
12452
|
-
|
|
12453
|
-
|
|
12454
|
-
|
|
12455
|
-
|
|
12456
|
-
|
|
12457
|
-
|
|
12458
|
-
|
|
12459
|
-
|
|
12460
|
-
Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
|
|
12461
|
-
|
|
12462
|
-
if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
|
|
12463
|
-
typeof console.error === 'function') {
|
|
12464
|
-
console.error(
|
|
12465
|
-
'This browser lacks typed array (Uint8Array) support which is required by ' +
|
|
12466
|
-
'`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
|
|
12467
|
-
)
|
|
12468
|
-
}
|
|
12531
|
+
if (includeNonEnumerable) {
|
|
12532
|
+
var allPropertyNames = Object.getOwnPropertyNames(parent);
|
|
12533
|
+
for (var i = 0; i < allPropertyNames.length; i++) {
|
|
12534
|
+
var propertyName = allPropertyNames[i];
|
|
12535
|
+
var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
|
|
12536
|
+
if (descriptor && descriptor.enumerable) {
|
|
12537
|
+
continue;
|
|
12538
|
+
}
|
|
12539
|
+
child[propertyName] = _clone(parent[propertyName], depth - 1);
|
|
12540
|
+
Object.defineProperty(child, propertyName, {
|
|
12541
|
+
enumerable: false
|
|
12542
|
+
});
|
|
12543
|
+
}
|
|
12544
|
+
}
|
|
12469
12545
|
|
|
12470
|
-
|
|
12471
|
-
// Can typed array instances can be augmented?
|
|
12472
|
-
try {
|
|
12473
|
-
var arr = new Uint8Array(1)
|
|
12474
|
-
arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
|
|
12475
|
-
return arr.foo() === 42
|
|
12476
|
-
} catch (e) {
|
|
12477
|
-
return false
|
|
12546
|
+
return child;
|
|
12478
12547
|
}
|
|
12479
|
-
}
|
|
12480
12548
|
|
|
12481
|
-
|
|
12482
|
-
if (length > K_MAX_LENGTH) {
|
|
12483
|
-
throw new RangeError('Invalid typed array length')
|
|
12484
|
-
}
|
|
12485
|
-
// Return an augmented `Uint8Array` instance
|
|
12486
|
-
var buf = new Uint8Array(length)
|
|
12487
|
-
buf.__proto__ = Buffer.prototype
|
|
12488
|
-
return buf
|
|
12549
|
+
return _clone(parent, depth);
|
|
12489
12550
|
}
|
|
12490
12551
|
|
|
12491
12552
|
/**
|
|
12492
|
-
*
|
|
12493
|
-
*
|
|
12494
|
-
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
|
|
12495
|
-
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
|
|
12496
|
-
* returns a single octet.
|
|
12553
|
+
* Simple flat clone using prototype, accepts only objects, usefull for property
|
|
12554
|
+
* override on FLAT configuration object (no nested props).
|
|
12497
12555
|
*
|
|
12498
|
-
*
|
|
12556
|
+
* USE WITH CAUTION! This may not behave as you wish if you do not know how this
|
|
12557
|
+
* works.
|
|
12499
12558
|
*/
|
|
12559
|
+
clone.clonePrototype = function clonePrototype(parent) {
|
|
12560
|
+
if (parent === null)
|
|
12561
|
+
return null;
|
|
12500
12562
|
|
|
12501
|
-
|
|
12502
|
-
|
|
12503
|
-
|
|
12504
|
-
|
|
12505
|
-
throw new Error(
|
|
12506
|
-
'If encoding is specified then the first argument must be a string'
|
|
12507
|
-
)
|
|
12508
|
-
}
|
|
12509
|
-
return allocUnsafe(arg)
|
|
12510
|
-
}
|
|
12511
|
-
return from(arg, encodingOrOffset, length)
|
|
12512
|
-
}
|
|
12513
|
-
|
|
12514
|
-
// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
|
|
12515
|
-
if (typeof Symbol !== 'undefined' && Symbol.species &&
|
|
12516
|
-
Buffer[Symbol.species] === Buffer) {
|
|
12517
|
-
Object.defineProperty(Buffer, Symbol.species, {
|
|
12518
|
-
value: null,
|
|
12519
|
-
configurable: true,
|
|
12520
|
-
enumerable: false,
|
|
12521
|
-
writable: false
|
|
12522
|
-
})
|
|
12523
|
-
}
|
|
12524
|
-
|
|
12525
|
-
Buffer.poolSize = 8192 // not used by this implementation
|
|
12526
|
-
|
|
12527
|
-
function from (value, encodingOrOffset, length) {
|
|
12528
|
-
if (typeof value === 'number') {
|
|
12529
|
-
throw new TypeError('"value" argument must not be a number')
|
|
12530
|
-
}
|
|
12531
|
-
|
|
12532
|
-
if (isArrayBuffer(value)) {
|
|
12533
|
-
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
12534
|
-
}
|
|
12563
|
+
var c = function () {};
|
|
12564
|
+
c.prototype = parent;
|
|
12565
|
+
return new c();
|
|
12566
|
+
};
|
|
12535
12567
|
|
|
12536
|
-
|
|
12537
|
-
return fromString(value, encodingOrOffset)
|
|
12538
|
-
}
|
|
12568
|
+
// private utility functions
|
|
12539
12569
|
|
|
12540
|
-
|
|
12570
|
+
function __objToStr(o) {
|
|
12571
|
+
return Object.prototype.toString.call(o);
|
|
12541
12572
|
}
|
|
12573
|
+
clone.__objToStr = __objToStr;
|
|
12542
12574
|
|
|
12543
|
-
|
|
12544
|
-
|
|
12545
|
-
* if value is a number.
|
|
12546
|
-
* Buffer.from(str[, encoding])
|
|
12547
|
-
* Buffer.from(array)
|
|
12548
|
-
* Buffer.from(buffer)
|
|
12549
|
-
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
|
12550
|
-
**/
|
|
12551
|
-
Buffer.from = function (value, encodingOrOffset, length) {
|
|
12552
|
-
return from(value, encodingOrOffset, length)
|
|
12575
|
+
function __isDate(o) {
|
|
12576
|
+
return typeof o === 'object' && __objToStr(o) === '[object Date]';
|
|
12553
12577
|
}
|
|
12554
|
-
|
|
12555
|
-
// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
|
|
12556
|
-
// https://github.com/feross/buffer/pull/148
|
|
12557
|
-
Buffer.prototype.__proto__ = Uint8Array.prototype
|
|
12558
|
-
Buffer.__proto__ = Uint8Array
|
|
12559
|
-
|
|
12560
|
-
function assertSize (size) {
|
|
12561
|
-
if (typeof size !== 'number') {
|
|
12562
|
-
throw new TypeError('"size" argument must be a number')
|
|
12563
|
-
} else if (size < 0) {
|
|
12564
|
-
throw new RangeError('"size" argument must not be negative')
|
|
12565
|
-
}
|
|
12566
|
-
}
|
|
12567
|
-
|
|
12568
|
-
function alloc (size, fill, encoding) {
|
|
12569
|
-
assertSize(size)
|
|
12570
|
-
if (size <= 0) {
|
|
12571
|
-
return createBuffer(size)
|
|
12572
|
-
}
|
|
12573
|
-
if (fill !== undefined) {
|
|
12574
|
-
// Only pay attention to encoding if it's a string. This
|
|
12575
|
-
// prevents accidentally sending in a number that would
|
|
12576
|
-
// be interpretted as a start offset.
|
|
12577
|
-
return typeof encoding === 'string'
|
|
12578
|
-
? createBuffer(size).fill(fill, encoding)
|
|
12579
|
-
: createBuffer(size).fill(fill)
|
|
12580
|
-
}
|
|
12581
|
-
return createBuffer(size)
|
|
12582
|
-
}
|
|
12583
|
-
|
|
12584
|
-
/**
|
|
12585
|
-
* Creates a new filled Buffer instance.
|
|
12586
|
-
* alloc(size[, fill[, encoding]])
|
|
12587
|
-
**/
|
|
12588
|
-
Buffer.alloc = function (size, fill, encoding) {
|
|
12589
|
-
return alloc(size, fill, encoding)
|
|
12590
|
-
}
|
|
12591
|
-
|
|
12592
|
-
function allocUnsafe (size) {
|
|
12593
|
-
assertSize(size)
|
|
12594
|
-
return createBuffer(size < 0 ? 0 : checked(size) | 0)
|
|
12595
|
-
}
|
|
12596
|
-
|
|
12597
|
-
/**
|
|
12598
|
-
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
|
12599
|
-
* */
|
|
12600
|
-
Buffer.allocUnsafe = function (size) {
|
|
12601
|
-
return allocUnsafe(size)
|
|
12602
|
-
}
|
|
12603
|
-
/**
|
|
12604
|
-
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
|
12605
|
-
*/
|
|
12606
|
-
Buffer.allocUnsafeSlow = function (size) {
|
|
12607
|
-
return allocUnsafe(size)
|
|
12608
|
-
}
|
|
12609
|
-
|
|
12610
|
-
function fromString (string, encoding) {
|
|
12611
|
-
if (typeof encoding !== 'string' || encoding === '') {
|
|
12612
|
-
encoding = 'utf8'
|
|
12613
|
-
}
|
|
12614
|
-
|
|
12615
|
-
if (!Buffer.isEncoding(encoding)) {
|
|
12616
|
-
throw new TypeError('"encoding" must be a valid string encoding')
|
|
12617
|
-
}
|
|
12618
|
-
|
|
12619
|
-
var length = byteLength(string, encoding) | 0
|
|
12620
|
-
var buf = createBuffer(length)
|
|
12621
|
-
|
|
12622
|
-
var actual = buf.write(string, encoding)
|
|
12623
|
-
|
|
12624
|
-
if (actual !== length) {
|
|
12625
|
-
// Writing a hex string, for example, that contains invalid characters will
|
|
12626
|
-
// cause everything after the first invalid character to be ignored. (e.g.
|
|
12627
|
-
// 'abxxcd' will be treated as 'ab')
|
|
12628
|
-
buf = buf.slice(0, actual)
|
|
12629
|
-
}
|
|
12630
|
-
|
|
12631
|
-
return buf
|
|
12632
|
-
}
|
|
12633
|
-
|
|
12634
|
-
function fromArrayLike (array) {
|
|
12635
|
-
var length = array.length < 0 ? 0 : checked(array.length) | 0
|
|
12636
|
-
var buf = createBuffer(length)
|
|
12637
|
-
for (var i = 0; i < length; i += 1) {
|
|
12638
|
-
buf[i] = array[i] & 255
|
|
12639
|
-
}
|
|
12640
|
-
return buf
|
|
12641
|
-
}
|
|
12642
|
-
|
|
12643
|
-
function fromArrayBuffer (array, byteOffset, length) {
|
|
12644
|
-
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
12645
|
-
throw new RangeError('\'offset\' is out of bounds')
|
|
12646
|
-
}
|
|
12647
|
-
|
|
12648
|
-
if (array.byteLength < byteOffset + (length || 0)) {
|
|
12649
|
-
throw new RangeError('\'length\' is out of bounds')
|
|
12650
|
-
}
|
|
12651
|
-
|
|
12652
|
-
var buf
|
|
12653
|
-
if (byteOffset === undefined && length === undefined) {
|
|
12654
|
-
buf = new Uint8Array(array)
|
|
12655
|
-
} else if (length === undefined) {
|
|
12656
|
-
buf = new Uint8Array(array, byteOffset)
|
|
12657
|
-
} else {
|
|
12658
|
-
buf = new Uint8Array(array, byteOffset, length)
|
|
12659
|
-
}
|
|
12660
|
-
|
|
12661
|
-
// Return an augmented `Uint8Array` instance
|
|
12662
|
-
buf.__proto__ = Buffer.prototype
|
|
12663
|
-
return buf
|
|
12664
|
-
}
|
|
12665
|
-
|
|
12666
|
-
function fromObject (obj) {
|
|
12667
|
-
if (Buffer.isBuffer(obj)) {
|
|
12668
|
-
var len = checked(obj.length) | 0
|
|
12669
|
-
var buf = createBuffer(len)
|
|
12670
|
-
|
|
12671
|
-
if (buf.length === 0) {
|
|
12672
|
-
return buf
|
|
12673
|
-
}
|
|
12674
|
-
|
|
12675
|
-
obj.copy(buf, 0, 0, len)
|
|
12676
|
-
return buf
|
|
12677
|
-
}
|
|
12678
|
-
|
|
12679
|
-
if (obj) {
|
|
12680
|
-
if (isArrayBufferView(obj) || 'length' in obj) {
|
|
12681
|
-
if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
|
|
12682
|
-
return createBuffer(0)
|
|
12683
|
-
}
|
|
12684
|
-
return fromArrayLike(obj)
|
|
12685
|
-
}
|
|
12686
|
-
|
|
12687
|
-
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
|
|
12688
|
-
return fromArrayLike(obj.data)
|
|
12689
|
-
}
|
|
12690
|
-
}
|
|
12691
|
-
|
|
12692
|
-
throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
|
|
12693
|
-
}
|
|
12694
|
-
|
|
12695
|
-
function checked (length) {
|
|
12696
|
-
// Note: cannot use `length < K_MAX_LENGTH` here because that fails when
|
|
12697
|
-
// length is NaN (which is otherwise coerced to zero.)
|
|
12698
|
-
if (length >= K_MAX_LENGTH) {
|
|
12699
|
-
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
|
12700
|
-
'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
|
|
12701
|
-
}
|
|
12702
|
-
return length | 0
|
|
12703
|
-
}
|
|
12704
|
-
|
|
12705
|
-
function SlowBuffer (length) {
|
|
12706
|
-
if (+length != length) { // eslint-disable-line eqeqeq
|
|
12707
|
-
length = 0
|
|
12708
|
-
}
|
|
12709
|
-
return Buffer.alloc(+length)
|
|
12710
|
-
}
|
|
12711
|
-
|
|
12712
|
-
Buffer.isBuffer = function isBuffer (b) {
|
|
12713
|
-
return b != null && b._isBuffer === true
|
|
12714
|
-
}
|
|
12715
|
-
|
|
12716
|
-
Buffer.compare = function compare (a, b) {
|
|
12717
|
-
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
12718
|
-
throw new TypeError('Arguments must be Buffers')
|
|
12719
|
-
}
|
|
12720
|
-
|
|
12721
|
-
if (a === b) return 0
|
|
12722
|
-
|
|
12723
|
-
var x = a.length
|
|
12724
|
-
var y = b.length
|
|
12725
|
-
|
|
12726
|
-
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
12727
|
-
if (a[i] !== b[i]) {
|
|
12728
|
-
x = a[i]
|
|
12729
|
-
y = b[i]
|
|
12730
|
-
break
|
|
12731
|
-
}
|
|
12732
|
-
}
|
|
12733
|
-
|
|
12734
|
-
if (x < y) return -1
|
|
12735
|
-
if (y < x) return 1
|
|
12736
|
-
return 0
|
|
12737
|
-
}
|
|
12738
|
-
|
|
12739
|
-
Buffer.isEncoding = function isEncoding (encoding) {
|
|
12740
|
-
switch (String(encoding).toLowerCase()) {
|
|
12741
|
-
case 'hex':
|
|
12742
|
-
case 'utf8':
|
|
12743
|
-
case 'utf-8':
|
|
12744
|
-
case 'ascii':
|
|
12745
|
-
case 'latin1':
|
|
12746
|
-
case 'binary':
|
|
12747
|
-
case 'base64':
|
|
12748
|
-
case 'ucs2':
|
|
12749
|
-
case 'ucs-2':
|
|
12750
|
-
case 'utf16le':
|
|
12751
|
-
case 'utf-16le':
|
|
12752
|
-
return true
|
|
12753
|
-
default:
|
|
12754
|
-
return false
|
|
12755
|
-
}
|
|
12756
|
-
}
|
|
12757
|
-
|
|
12758
|
-
Buffer.concat = function concat (list, length) {
|
|
12759
|
-
if (!Array.isArray(list)) {
|
|
12760
|
-
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
12761
|
-
}
|
|
12762
|
-
|
|
12763
|
-
if (list.length === 0) {
|
|
12764
|
-
return Buffer.alloc(0)
|
|
12765
|
-
}
|
|
12766
|
-
|
|
12767
|
-
var i
|
|
12768
|
-
if (length === undefined) {
|
|
12769
|
-
length = 0
|
|
12770
|
-
for (i = 0; i < list.length; ++i) {
|
|
12771
|
-
length += list[i].length
|
|
12772
|
-
}
|
|
12773
|
-
}
|
|
12774
|
-
|
|
12775
|
-
var buffer = Buffer.allocUnsafe(length)
|
|
12776
|
-
var pos = 0
|
|
12777
|
-
for (i = 0; i < list.length; ++i) {
|
|
12778
|
-
var buf = list[i]
|
|
12779
|
-
if (!Buffer.isBuffer(buf)) {
|
|
12780
|
-
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
12781
|
-
}
|
|
12782
|
-
buf.copy(buffer, pos)
|
|
12783
|
-
pos += buf.length
|
|
12784
|
-
}
|
|
12785
|
-
return buffer
|
|
12786
|
-
}
|
|
12787
|
-
|
|
12788
|
-
function byteLength (string, encoding) {
|
|
12789
|
-
if (Buffer.isBuffer(string)) {
|
|
12790
|
-
return string.length
|
|
12791
|
-
}
|
|
12792
|
-
if (isArrayBufferView(string) || isArrayBuffer(string)) {
|
|
12793
|
-
return string.byteLength
|
|
12794
|
-
}
|
|
12795
|
-
if (typeof string !== 'string') {
|
|
12796
|
-
string = '' + string
|
|
12797
|
-
}
|
|
12798
|
-
|
|
12799
|
-
var len = string.length
|
|
12800
|
-
if (len === 0) return 0
|
|
12801
|
-
|
|
12802
|
-
// Use a for loop to avoid recursion
|
|
12803
|
-
var loweredCase = false
|
|
12804
|
-
for (;;) {
|
|
12805
|
-
switch (encoding) {
|
|
12806
|
-
case 'ascii':
|
|
12807
|
-
case 'latin1':
|
|
12808
|
-
case 'binary':
|
|
12809
|
-
return len
|
|
12810
|
-
case 'utf8':
|
|
12811
|
-
case 'utf-8':
|
|
12812
|
-
case undefined:
|
|
12813
|
-
return utf8ToBytes(string).length
|
|
12814
|
-
case 'ucs2':
|
|
12815
|
-
case 'ucs-2':
|
|
12816
|
-
case 'utf16le':
|
|
12817
|
-
case 'utf-16le':
|
|
12818
|
-
return len * 2
|
|
12819
|
-
case 'hex':
|
|
12820
|
-
return len >>> 1
|
|
12821
|
-
case 'base64':
|
|
12822
|
-
return base64ToBytes(string).length
|
|
12823
|
-
default:
|
|
12824
|
-
if (loweredCase) return utf8ToBytes(string).length // assume utf8
|
|
12825
|
-
encoding = ('' + encoding).toLowerCase()
|
|
12826
|
-
loweredCase = true
|
|
12827
|
-
}
|
|
12828
|
-
}
|
|
12829
|
-
}
|
|
12830
|
-
Buffer.byteLength = byteLength
|
|
12831
|
-
|
|
12832
|
-
function slowToString (encoding, start, end) {
|
|
12833
|
-
var loweredCase = false
|
|
12834
|
-
|
|
12835
|
-
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
|
|
12836
|
-
// property of a typed array.
|
|
12837
|
-
|
|
12838
|
-
// This behaves neither like String nor Uint8Array in that we set start/end
|
|
12839
|
-
// to their upper/lower bounds if the value passed is out of range.
|
|
12840
|
-
// undefined is handled specially as per ECMA-262 6th Edition,
|
|
12841
|
-
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
|
|
12842
|
-
if (start === undefined || start < 0) {
|
|
12843
|
-
start = 0
|
|
12844
|
-
}
|
|
12845
|
-
// Return early if start > this.length. Done here to prevent potential uint32
|
|
12846
|
-
// coercion fail below.
|
|
12847
|
-
if (start > this.length) {
|
|
12848
|
-
return ''
|
|
12849
|
-
}
|
|
12850
|
-
|
|
12851
|
-
if (end === undefined || end > this.length) {
|
|
12852
|
-
end = this.length
|
|
12853
|
-
}
|
|
12854
|
-
|
|
12855
|
-
if (end <= 0) {
|
|
12856
|
-
return ''
|
|
12857
|
-
}
|
|
12858
|
-
|
|
12859
|
-
// Force coersion to uint32. This will also coerce falsey/NaN values to 0.
|
|
12860
|
-
end >>>= 0
|
|
12861
|
-
start >>>= 0
|
|
12862
|
-
|
|
12863
|
-
if (end <= start) {
|
|
12864
|
-
return ''
|
|
12865
|
-
}
|
|
12866
|
-
|
|
12867
|
-
if (!encoding) encoding = 'utf8'
|
|
12868
|
-
|
|
12869
|
-
while (true) {
|
|
12870
|
-
switch (encoding) {
|
|
12871
|
-
case 'hex':
|
|
12872
|
-
return hexSlice(this, start, end)
|
|
12873
|
-
|
|
12874
|
-
case 'utf8':
|
|
12875
|
-
case 'utf-8':
|
|
12876
|
-
return utf8Slice(this, start, end)
|
|
12877
|
-
|
|
12878
|
-
case 'ascii':
|
|
12879
|
-
return asciiSlice(this, start, end)
|
|
12880
|
-
|
|
12881
|
-
case 'latin1':
|
|
12882
|
-
case 'binary':
|
|
12883
|
-
return latin1Slice(this, start, end)
|
|
12884
|
-
|
|
12885
|
-
case 'base64':
|
|
12886
|
-
return base64Slice(this, start, end)
|
|
12887
|
-
|
|
12888
|
-
case 'ucs2':
|
|
12889
|
-
case 'ucs-2':
|
|
12890
|
-
case 'utf16le':
|
|
12891
|
-
case 'utf-16le':
|
|
12892
|
-
return utf16leSlice(this, start, end)
|
|
12893
|
-
|
|
12894
|
-
default:
|
|
12895
|
-
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
12896
|
-
encoding = (encoding + '').toLowerCase()
|
|
12897
|
-
loweredCase = true
|
|
12898
|
-
}
|
|
12899
|
-
}
|
|
12900
|
-
}
|
|
12901
|
-
|
|
12902
|
-
// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
|
|
12903
|
-
// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
|
|
12904
|
-
// reliably in a browserify context because there could be multiple different
|
|
12905
|
-
// copies of the 'buffer' package in use. This method works even for Buffer
|
|
12906
|
-
// instances that were created from another copy of the `buffer` package.
|
|
12907
|
-
// See: https://github.com/feross/buffer/issues/154
|
|
12908
|
-
Buffer.prototype._isBuffer = true
|
|
12909
|
-
|
|
12910
|
-
function swap (b, n, m) {
|
|
12911
|
-
var i = b[n]
|
|
12912
|
-
b[n] = b[m]
|
|
12913
|
-
b[m] = i
|
|
12914
|
-
}
|
|
12915
|
-
|
|
12916
|
-
Buffer.prototype.swap16 = function swap16 () {
|
|
12917
|
-
var len = this.length
|
|
12918
|
-
if (len % 2 !== 0) {
|
|
12919
|
-
throw new RangeError('Buffer size must be a multiple of 16-bits')
|
|
12920
|
-
}
|
|
12921
|
-
for (var i = 0; i < len; i += 2) {
|
|
12922
|
-
swap(this, i, i + 1)
|
|
12923
|
-
}
|
|
12924
|
-
return this
|
|
12925
|
-
}
|
|
12926
|
-
|
|
12927
|
-
Buffer.prototype.swap32 = function swap32 () {
|
|
12928
|
-
var len = this.length
|
|
12929
|
-
if (len % 4 !== 0) {
|
|
12930
|
-
throw new RangeError('Buffer size must be a multiple of 32-bits')
|
|
12931
|
-
}
|
|
12932
|
-
for (var i = 0; i < len; i += 4) {
|
|
12933
|
-
swap(this, i, i + 3)
|
|
12934
|
-
swap(this, i + 1, i + 2)
|
|
12935
|
-
}
|
|
12936
|
-
return this
|
|
12937
|
-
}
|
|
12938
|
-
|
|
12939
|
-
Buffer.prototype.swap64 = function swap64 () {
|
|
12940
|
-
var len = this.length
|
|
12941
|
-
if (len % 8 !== 0) {
|
|
12942
|
-
throw new RangeError('Buffer size must be a multiple of 64-bits')
|
|
12943
|
-
}
|
|
12944
|
-
for (var i = 0; i < len; i += 8) {
|
|
12945
|
-
swap(this, i, i + 7)
|
|
12946
|
-
swap(this, i + 1, i + 6)
|
|
12947
|
-
swap(this, i + 2, i + 5)
|
|
12948
|
-
swap(this, i + 3, i + 4)
|
|
12949
|
-
}
|
|
12950
|
-
return this
|
|
12951
|
-
}
|
|
12952
|
-
|
|
12953
|
-
Buffer.prototype.toString = function toString () {
|
|
12954
|
-
var length = this.length
|
|
12955
|
-
if (length === 0) return ''
|
|
12956
|
-
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
|
12957
|
-
return slowToString.apply(this, arguments)
|
|
12958
|
-
}
|
|
12959
|
-
|
|
12960
|
-
Buffer.prototype.equals = function equals (b) {
|
|
12961
|
-
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
|
12962
|
-
if (this === b) return true
|
|
12963
|
-
return Buffer.compare(this, b) === 0
|
|
12964
|
-
}
|
|
12965
|
-
|
|
12966
|
-
Buffer.prototype.inspect = function inspect () {
|
|
12967
|
-
var str = ''
|
|
12968
|
-
var max = exports.INSPECT_MAX_BYTES
|
|
12969
|
-
if (this.length > 0) {
|
|
12970
|
-
str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
|
|
12971
|
-
if (this.length > max) str += ' ... '
|
|
12972
|
-
}
|
|
12973
|
-
return '<Buffer ' + str + '>'
|
|
12974
|
-
}
|
|
12975
|
-
|
|
12976
|
-
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
|
12977
|
-
if (!Buffer.isBuffer(target)) {
|
|
12978
|
-
throw new TypeError('Argument must be a Buffer')
|
|
12979
|
-
}
|
|
12980
|
-
|
|
12981
|
-
if (start === undefined) {
|
|
12982
|
-
start = 0
|
|
12983
|
-
}
|
|
12984
|
-
if (end === undefined) {
|
|
12985
|
-
end = target ? target.length : 0
|
|
12986
|
-
}
|
|
12987
|
-
if (thisStart === undefined) {
|
|
12988
|
-
thisStart = 0
|
|
12989
|
-
}
|
|
12990
|
-
if (thisEnd === undefined) {
|
|
12991
|
-
thisEnd = this.length
|
|
12992
|
-
}
|
|
12993
|
-
|
|
12994
|
-
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
12995
|
-
throw new RangeError('out of range index')
|
|
12996
|
-
}
|
|
12997
|
-
|
|
12998
|
-
if (thisStart >= thisEnd && start >= end) {
|
|
12999
|
-
return 0
|
|
13000
|
-
}
|
|
13001
|
-
if (thisStart >= thisEnd) {
|
|
13002
|
-
return -1
|
|
13003
|
-
}
|
|
13004
|
-
if (start >= end) {
|
|
13005
|
-
return 1
|
|
13006
|
-
}
|
|
13007
|
-
|
|
13008
|
-
start >>>= 0
|
|
13009
|
-
end >>>= 0
|
|
13010
|
-
thisStart >>>= 0
|
|
13011
|
-
thisEnd >>>= 0
|
|
13012
|
-
|
|
13013
|
-
if (this === target) return 0
|
|
13014
|
-
|
|
13015
|
-
var x = thisEnd - thisStart
|
|
13016
|
-
var y = end - start
|
|
13017
|
-
var len = Math.min(x, y)
|
|
13018
|
-
|
|
13019
|
-
var thisCopy = this.slice(thisStart, thisEnd)
|
|
13020
|
-
var targetCopy = target.slice(start, end)
|
|
13021
|
-
|
|
13022
|
-
for (var i = 0; i < len; ++i) {
|
|
13023
|
-
if (thisCopy[i] !== targetCopy[i]) {
|
|
13024
|
-
x = thisCopy[i]
|
|
13025
|
-
y = targetCopy[i]
|
|
13026
|
-
break
|
|
13027
|
-
}
|
|
13028
|
-
}
|
|
13029
|
-
|
|
13030
|
-
if (x < y) return -1
|
|
13031
|
-
if (y < x) return 1
|
|
13032
|
-
return 0
|
|
13033
|
-
}
|
|
13034
|
-
|
|
13035
|
-
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
|
|
13036
|
-
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
|
|
13037
|
-
//
|
|
13038
|
-
// Arguments:
|
|
13039
|
-
// - buffer - a Buffer to search
|
|
13040
|
-
// - val - a string, Buffer, or number
|
|
13041
|
-
// - byteOffset - an index into `buffer`; will be clamped to an int32
|
|
13042
|
-
// - encoding - an optional encoding, relevant is val is a string
|
|
13043
|
-
// - dir - true for indexOf, false for lastIndexOf
|
|
13044
|
-
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
|
13045
|
-
// Empty buffer means no match
|
|
13046
|
-
if (buffer.length === 0) return -1
|
|
13047
|
-
|
|
13048
|
-
// Normalize byteOffset
|
|
13049
|
-
if (typeof byteOffset === 'string') {
|
|
13050
|
-
encoding = byteOffset
|
|
13051
|
-
byteOffset = 0
|
|
13052
|
-
} else if (byteOffset > 0x7fffffff) {
|
|
13053
|
-
byteOffset = 0x7fffffff
|
|
13054
|
-
} else if (byteOffset < -0x80000000) {
|
|
13055
|
-
byteOffset = -0x80000000
|
|
13056
|
-
}
|
|
13057
|
-
byteOffset = +byteOffset // Coerce to Number.
|
|
13058
|
-
if (numberIsNaN(byteOffset)) {
|
|
13059
|
-
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
|
13060
|
-
byteOffset = dir ? 0 : (buffer.length - 1)
|
|
13061
|
-
}
|
|
13062
|
-
|
|
13063
|
-
// Normalize byteOffset: negative offsets start from the end of the buffer
|
|
13064
|
-
if (byteOffset < 0) byteOffset = buffer.length + byteOffset
|
|
13065
|
-
if (byteOffset >= buffer.length) {
|
|
13066
|
-
if (dir) return -1
|
|
13067
|
-
else byteOffset = buffer.length - 1
|
|
13068
|
-
} else if (byteOffset < 0) {
|
|
13069
|
-
if (dir) byteOffset = 0
|
|
13070
|
-
else return -1
|
|
13071
|
-
}
|
|
13072
|
-
|
|
13073
|
-
// Normalize val
|
|
13074
|
-
if (typeof val === 'string') {
|
|
13075
|
-
val = Buffer.from(val, encoding)
|
|
13076
|
-
}
|
|
13077
|
-
|
|
13078
|
-
// Finally, search either indexOf (if dir is true) or lastIndexOf
|
|
13079
|
-
if (Buffer.isBuffer(val)) {
|
|
13080
|
-
// Special case: looking for empty string/buffer always fails
|
|
13081
|
-
if (val.length === 0) {
|
|
13082
|
-
return -1
|
|
13083
|
-
}
|
|
13084
|
-
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
|
|
13085
|
-
} else if (typeof val === 'number') {
|
|
13086
|
-
val = val & 0xFF // Search for a byte value [0-255]
|
|
13087
|
-
if (typeof Uint8Array.prototype.indexOf === 'function') {
|
|
13088
|
-
if (dir) {
|
|
13089
|
-
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
|
|
13090
|
-
} else {
|
|
13091
|
-
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
|
13092
|
-
}
|
|
13093
|
-
}
|
|
13094
|
-
return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
|
|
13095
|
-
}
|
|
13096
|
-
|
|
13097
|
-
throw new TypeError('val must be string, number or Buffer')
|
|
13098
|
-
}
|
|
13099
|
-
|
|
13100
|
-
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
|
13101
|
-
var indexSize = 1
|
|
13102
|
-
var arrLength = arr.length
|
|
13103
|
-
var valLength = val.length
|
|
13104
|
-
|
|
13105
|
-
if (encoding !== undefined) {
|
|
13106
|
-
encoding = String(encoding).toLowerCase()
|
|
13107
|
-
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
|
|
13108
|
-
encoding === 'utf16le' || encoding === 'utf-16le') {
|
|
13109
|
-
if (arr.length < 2 || val.length < 2) {
|
|
13110
|
-
return -1
|
|
13111
|
-
}
|
|
13112
|
-
indexSize = 2
|
|
13113
|
-
arrLength /= 2
|
|
13114
|
-
valLength /= 2
|
|
13115
|
-
byteOffset /= 2
|
|
13116
|
-
}
|
|
13117
|
-
}
|
|
13118
|
-
|
|
13119
|
-
function read (buf, i) {
|
|
13120
|
-
if (indexSize === 1) {
|
|
13121
|
-
return buf[i]
|
|
13122
|
-
} else {
|
|
13123
|
-
return buf.readUInt16BE(i * indexSize)
|
|
13124
|
-
}
|
|
13125
|
-
}
|
|
13126
|
-
|
|
13127
|
-
var i
|
|
13128
|
-
if (dir) {
|
|
13129
|
-
var foundIndex = -1
|
|
13130
|
-
for (i = byteOffset; i < arrLength; i++) {
|
|
13131
|
-
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
13132
|
-
if (foundIndex === -1) foundIndex = i
|
|
13133
|
-
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
|
|
13134
|
-
} else {
|
|
13135
|
-
if (foundIndex !== -1) i -= i - foundIndex
|
|
13136
|
-
foundIndex = -1
|
|
13137
|
-
}
|
|
13138
|
-
}
|
|
13139
|
-
} else {
|
|
13140
|
-
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
|
|
13141
|
-
for (i = byteOffset; i >= 0; i--) {
|
|
13142
|
-
var found = true
|
|
13143
|
-
for (var j = 0; j < valLength; j++) {
|
|
13144
|
-
if (read(arr, i + j) !== read(val, j)) {
|
|
13145
|
-
found = false
|
|
13146
|
-
break
|
|
13147
|
-
}
|
|
13148
|
-
}
|
|
13149
|
-
if (found) return i
|
|
13150
|
-
}
|
|
13151
|
-
}
|
|
13152
|
-
|
|
13153
|
-
return -1
|
|
13154
|
-
}
|
|
13155
|
-
|
|
13156
|
-
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
|
13157
|
-
return this.indexOf(val, byteOffset, encoding) !== -1
|
|
13158
|
-
}
|
|
13159
|
-
|
|
13160
|
-
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
|
13161
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
|
|
13162
|
-
}
|
|
13163
|
-
|
|
13164
|
-
Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
|
|
13165
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
|
|
13166
|
-
}
|
|
13167
|
-
|
|
13168
|
-
function hexWrite (buf, string, offset, length) {
|
|
13169
|
-
offset = Number(offset) || 0
|
|
13170
|
-
var remaining = buf.length - offset
|
|
13171
|
-
if (!length) {
|
|
13172
|
-
length = remaining
|
|
13173
|
-
} else {
|
|
13174
|
-
length = Number(length)
|
|
13175
|
-
if (length > remaining) {
|
|
13176
|
-
length = remaining
|
|
13177
|
-
}
|
|
13178
|
-
}
|
|
13179
|
-
|
|
13180
|
-
// must be an even number of digits
|
|
13181
|
-
var strLen = string.length
|
|
13182
|
-
if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
|
|
13183
|
-
|
|
13184
|
-
if (length > strLen / 2) {
|
|
13185
|
-
length = strLen / 2
|
|
13186
|
-
}
|
|
13187
|
-
for (var i = 0; i < length; ++i) {
|
|
13188
|
-
var parsed = parseInt(string.substr(i * 2, 2), 16)
|
|
13189
|
-
if (numberIsNaN(parsed)) return i
|
|
13190
|
-
buf[offset + i] = parsed
|
|
13191
|
-
}
|
|
13192
|
-
return i
|
|
13193
|
-
}
|
|
13194
|
-
|
|
13195
|
-
function utf8Write (buf, string, offset, length) {
|
|
13196
|
-
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
|
13197
|
-
}
|
|
13198
|
-
|
|
13199
|
-
function asciiWrite (buf, string, offset, length) {
|
|
13200
|
-
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
13201
|
-
}
|
|
13202
|
-
|
|
13203
|
-
function latin1Write (buf, string, offset, length) {
|
|
13204
|
-
return asciiWrite(buf, string, offset, length)
|
|
13205
|
-
}
|
|
13206
|
-
|
|
13207
|
-
function base64Write (buf, string, offset, length) {
|
|
13208
|
-
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
13209
|
-
}
|
|
13210
|
-
|
|
13211
|
-
function ucs2Write (buf, string, offset, length) {
|
|
13212
|
-
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
|
13213
|
-
}
|
|
13214
|
-
|
|
13215
|
-
Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
13216
|
-
// Buffer#write(string)
|
|
13217
|
-
if (offset === undefined) {
|
|
13218
|
-
encoding = 'utf8'
|
|
13219
|
-
length = this.length
|
|
13220
|
-
offset = 0
|
|
13221
|
-
// Buffer#write(string, encoding)
|
|
13222
|
-
} else if (length === undefined && typeof offset === 'string') {
|
|
13223
|
-
encoding = offset
|
|
13224
|
-
length = this.length
|
|
13225
|
-
offset = 0
|
|
13226
|
-
// Buffer#write(string, offset[, length][, encoding])
|
|
13227
|
-
} else if (isFinite(offset)) {
|
|
13228
|
-
offset = offset >>> 0
|
|
13229
|
-
if (isFinite(length)) {
|
|
13230
|
-
length = length >>> 0
|
|
13231
|
-
if (encoding === undefined) encoding = 'utf8'
|
|
13232
|
-
} else {
|
|
13233
|
-
encoding = length
|
|
13234
|
-
length = undefined
|
|
13235
|
-
}
|
|
13236
|
-
} else {
|
|
13237
|
-
throw new Error(
|
|
13238
|
-
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
|
13239
|
-
)
|
|
13240
|
-
}
|
|
13241
|
-
|
|
13242
|
-
var remaining = this.length - offset
|
|
13243
|
-
if (length === undefined || length > remaining) length = remaining
|
|
13244
|
-
|
|
13245
|
-
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
|
13246
|
-
throw new RangeError('Attempt to write outside buffer bounds')
|
|
13247
|
-
}
|
|
13248
|
-
|
|
13249
|
-
if (!encoding) encoding = 'utf8'
|
|
13250
|
-
|
|
13251
|
-
var loweredCase = false
|
|
13252
|
-
for (;;) {
|
|
13253
|
-
switch (encoding) {
|
|
13254
|
-
case 'hex':
|
|
13255
|
-
return hexWrite(this, string, offset, length)
|
|
13256
|
-
|
|
13257
|
-
case 'utf8':
|
|
13258
|
-
case 'utf-8':
|
|
13259
|
-
return utf8Write(this, string, offset, length)
|
|
13260
|
-
|
|
13261
|
-
case 'ascii':
|
|
13262
|
-
return asciiWrite(this, string, offset, length)
|
|
13263
|
-
|
|
13264
|
-
case 'latin1':
|
|
13265
|
-
case 'binary':
|
|
13266
|
-
return latin1Write(this, string, offset, length)
|
|
13267
|
-
|
|
13268
|
-
case 'base64':
|
|
13269
|
-
// Warning: maxLength not taken into account in base64Write
|
|
13270
|
-
return base64Write(this, string, offset, length)
|
|
13271
|
-
|
|
13272
|
-
case 'ucs2':
|
|
13273
|
-
case 'ucs-2':
|
|
13274
|
-
case 'utf16le':
|
|
13275
|
-
case 'utf-16le':
|
|
13276
|
-
return ucs2Write(this, string, offset, length)
|
|
13277
|
-
|
|
13278
|
-
default:
|
|
13279
|
-
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
13280
|
-
encoding = ('' + encoding).toLowerCase()
|
|
13281
|
-
loweredCase = true
|
|
13282
|
-
}
|
|
13283
|
-
}
|
|
13284
|
-
}
|
|
13285
|
-
|
|
13286
|
-
Buffer.prototype.toJSON = function toJSON () {
|
|
13287
|
-
return {
|
|
13288
|
-
type: 'Buffer',
|
|
13289
|
-
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
13290
|
-
}
|
|
13291
|
-
}
|
|
13292
|
-
|
|
13293
|
-
function base64Slice (buf, start, end) {
|
|
13294
|
-
if (start === 0 && end === buf.length) {
|
|
13295
|
-
return base64.fromByteArray(buf)
|
|
13296
|
-
} else {
|
|
13297
|
-
return base64.fromByteArray(buf.slice(start, end))
|
|
13298
|
-
}
|
|
13299
|
-
}
|
|
13300
|
-
|
|
13301
|
-
function utf8Slice (buf, start, end) {
|
|
13302
|
-
end = Math.min(buf.length, end)
|
|
13303
|
-
var res = []
|
|
13304
|
-
|
|
13305
|
-
var i = start
|
|
13306
|
-
while (i < end) {
|
|
13307
|
-
var firstByte = buf[i]
|
|
13308
|
-
var codePoint = null
|
|
13309
|
-
var bytesPerSequence = (firstByte > 0xEF) ? 4
|
|
13310
|
-
: (firstByte > 0xDF) ? 3
|
|
13311
|
-
: (firstByte > 0xBF) ? 2
|
|
13312
|
-
: 1
|
|
13313
|
-
|
|
13314
|
-
if (i + bytesPerSequence <= end) {
|
|
13315
|
-
var secondByte, thirdByte, fourthByte, tempCodePoint
|
|
13316
|
-
|
|
13317
|
-
switch (bytesPerSequence) {
|
|
13318
|
-
case 1:
|
|
13319
|
-
if (firstByte < 0x80) {
|
|
13320
|
-
codePoint = firstByte
|
|
13321
|
-
}
|
|
13322
|
-
break
|
|
13323
|
-
case 2:
|
|
13324
|
-
secondByte = buf[i + 1]
|
|
13325
|
-
if ((secondByte & 0xC0) === 0x80) {
|
|
13326
|
-
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
|
|
13327
|
-
if (tempCodePoint > 0x7F) {
|
|
13328
|
-
codePoint = tempCodePoint
|
|
13329
|
-
}
|
|
13330
|
-
}
|
|
13331
|
-
break
|
|
13332
|
-
case 3:
|
|
13333
|
-
secondByte = buf[i + 1]
|
|
13334
|
-
thirdByte = buf[i + 2]
|
|
13335
|
-
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
13336
|
-
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
|
|
13337
|
-
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
13338
|
-
codePoint = tempCodePoint
|
|
13339
|
-
}
|
|
13340
|
-
}
|
|
13341
|
-
break
|
|
13342
|
-
case 4:
|
|
13343
|
-
secondByte = buf[i + 1]
|
|
13344
|
-
thirdByte = buf[i + 2]
|
|
13345
|
-
fourthByte = buf[i + 3]
|
|
13346
|
-
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
13347
|
-
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
|
|
13348
|
-
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
13349
|
-
codePoint = tempCodePoint
|
|
13350
|
-
}
|
|
13351
|
-
}
|
|
13352
|
-
}
|
|
13353
|
-
}
|
|
13354
|
-
|
|
13355
|
-
if (codePoint === null) {
|
|
13356
|
-
// we did not generate a valid codePoint so insert a
|
|
13357
|
-
// replacement char (U+FFFD) and advance only 1 byte
|
|
13358
|
-
codePoint = 0xFFFD
|
|
13359
|
-
bytesPerSequence = 1
|
|
13360
|
-
} else if (codePoint > 0xFFFF) {
|
|
13361
|
-
// encode to utf16 (surrogate pair dance)
|
|
13362
|
-
codePoint -= 0x10000
|
|
13363
|
-
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
|
|
13364
|
-
codePoint = 0xDC00 | codePoint & 0x3FF
|
|
13365
|
-
}
|
|
13366
|
-
|
|
13367
|
-
res.push(codePoint)
|
|
13368
|
-
i += bytesPerSequence
|
|
13369
|
-
}
|
|
13370
|
-
|
|
13371
|
-
return decodeCodePointsArray(res)
|
|
13372
|
-
}
|
|
13373
|
-
|
|
13374
|
-
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
|
13375
|
-
// the lowest limit is Chrome, with 0x10000 args.
|
|
13376
|
-
// We go 1 magnitude less, for safety
|
|
13377
|
-
var MAX_ARGUMENTS_LENGTH = 0x1000
|
|
13378
|
-
|
|
13379
|
-
function decodeCodePointsArray (codePoints) {
|
|
13380
|
-
var len = codePoints.length
|
|
13381
|
-
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
13382
|
-
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
|
13383
|
-
}
|
|
13384
|
-
|
|
13385
|
-
// Decode in chunks to avoid "call stack size exceeded".
|
|
13386
|
-
var res = ''
|
|
13387
|
-
var i = 0
|
|
13388
|
-
while (i < len) {
|
|
13389
|
-
res += String.fromCharCode.apply(
|
|
13390
|
-
String,
|
|
13391
|
-
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
13392
|
-
)
|
|
13393
|
-
}
|
|
13394
|
-
return res
|
|
13395
|
-
}
|
|
13396
|
-
|
|
13397
|
-
function asciiSlice (buf, start, end) {
|
|
13398
|
-
var ret = ''
|
|
13399
|
-
end = Math.min(buf.length, end)
|
|
13400
|
-
|
|
13401
|
-
for (var i = start; i < end; ++i) {
|
|
13402
|
-
ret += String.fromCharCode(buf[i] & 0x7F)
|
|
13403
|
-
}
|
|
13404
|
-
return ret
|
|
13405
|
-
}
|
|
13406
|
-
|
|
13407
|
-
function latin1Slice (buf, start, end) {
|
|
13408
|
-
var ret = ''
|
|
13409
|
-
end = Math.min(buf.length, end)
|
|
13410
|
-
|
|
13411
|
-
for (var i = start; i < end; ++i) {
|
|
13412
|
-
ret += String.fromCharCode(buf[i])
|
|
13413
|
-
}
|
|
13414
|
-
return ret
|
|
13415
|
-
}
|
|
13416
|
-
|
|
13417
|
-
function hexSlice (buf, start, end) {
|
|
13418
|
-
var len = buf.length
|
|
13419
|
-
|
|
13420
|
-
if (!start || start < 0) start = 0
|
|
13421
|
-
if (!end || end < 0 || end > len) end = len
|
|
13422
|
-
|
|
13423
|
-
var out = ''
|
|
13424
|
-
for (var i = start; i < end; ++i) {
|
|
13425
|
-
out += toHex(buf[i])
|
|
13426
|
-
}
|
|
13427
|
-
return out
|
|
13428
|
-
}
|
|
13429
|
-
|
|
13430
|
-
function utf16leSlice (buf, start, end) {
|
|
13431
|
-
var bytes = buf.slice(start, end)
|
|
13432
|
-
var res = ''
|
|
13433
|
-
for (var i = 0; i < bytes.length; i += 2) {
|
|
13434
|
-
res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
|
|
13435
|
-
}
|
|
13436
|
-
return res
|
|
13437
|
-
}
|
|
13438
|
-
|
|
13439
|
-
Buffer.prototype.slice = function slice (start, end) {
|
|
13440
|
-
var len = this.length
|
|
13441
|
-
start = ~~start
|
|
13442
|
-
end = end === undefined ? len : ~~end
|
|
13443
|
-
|
|
13444
|
-
if (start < 0) {
|
|
13445
|
-
start += len
|
|
13446
|
-
if (start < 0) start = 0
|
|
13447
|
-
} else if (start > len) {
|
|
13448
|
-
start = len
|
|
13449
|
-
}
|
|
13450
|
-
|
|
13451
|
-
if (end < 0) {
|
|
13452
|
-
end += len
|
|
13453
|
-
if (end < 0) end = 0
|
|
13454
|
-
} else if (end > len) {
|
|
13455
|
-
end = len
|
|
13456
|
-
}
|
|
13457
|
-
|
|
13458
|
-
if (end < start) end = start
|
|
13459
|
-
|
|
13460
|
-
var newBuf = this.subarray(start, end)
|
|
13461
|
-
// Return an augmented `Uint8Array` instance
|
|
13462
|
-
newBuf.__proto__ = Buffer.prototype
|
|
13463
|
-
return newBuf
|
|
13464
|
-
}
|
|
13465
|
-
|
|
13466
|
-
/*
|
|
13467
|
-
* Need to make sure that buffer isn't trying to write out of bounds.
|
|
13468
|
-
*/
|
|
13469
|
-
function checkOffset (offset, ext, length) {
|
|
13470
|
-
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
|
13471
|
-
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
|
13472
|
-
}
|
|
13473
|
-
|
|
13474
|
-
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
|
13475
|
-
offset = offset >>> 0
|
|
13476
|
-
byteLength = byteLength >>> 0
|
|
13477
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
13478
|
-
|
|
13479
|
-
var val = this[offset]
|
|
13480
|
-
var mul = 1
|
|
13481
|
-
var i = 0
|
|
13482
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
13483
|
-
val += this[offset + i] * mul
|
|
13484
|
-
}
|
|
13485
|
-
|
|
13486
|
-
return val
|
|
13487
|
-
}
|
|
13488
|
-
|
|
13489
|
-
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
|
13490
|
-
offset = offset >>> 0
|
|
13491
|
-
byteLength = byteLength >>> 0
|
|
13492
|
-
if (!noAssert) {
|
|
13493
|
-
checkOffset(offset, byteLength, this.length)
|
|
13494
|
-
}
|
|
13495
|
-
|
|
13496
|
-
var val = this[offset + --byteLength]
|
|
13497
|
-
var mul = 1
|
|
13498
|
-
while (byteLength > 0 && (mul *= 0x100)) {
|
|
13499
|
-
val += this[offset + --byteLength] * mul
|
|
13500
|
-
}
|
|
13501
|
-
|
|
13502
|
-
return val
|
|
13503
|
-
}
|
|
13504
|
-
|
|
13505
|
-
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
|
13506
|
-
offset = offset >>> 0
|
|
13507
|
-
if (!noAssert) checkOffset(offset, 1, this.length)
|
|
13508
|
-
return this[offset]
|
|
13509
|
-
}
|
|
13510
|
-
|
|
13511
|
-
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
|
13512
|
-
offset = offset >>> 0
|
|
13513
|
-
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
13514
|
-
return this[offset] | (this[offset + 1] << 8)
|
|
13515
|
-
}
|
|
13516
|
-
|
|
13517
|
-
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
|
13518
|
-
offset = offset >>> 0
|
|
13519
|
-
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
13520
|
-
return (this[offset] << 8) | this[offset + 1]
|
|
13521
|
-
}
|
|
13522
|
-
|
|
13523
|
-
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
|
13524
|
-
offset = offset >>> 0
|
|
13525
|
-
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
13526
|
-
|
|
13527
|
-
return ((this[offset]) |
|
|
13528
|
-
(this[offset + 1] << 8) |
|
|
13529
|
-
(this[offset + 2] << 16)) +
|
|
13530
|
-
(this[offset + 3] * 0x1000000)
|
|
13531
|
-
}
|
|
13532
|
-
|
|
13533
|
-
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
|
13534
|
-
offset = offset >>> 0
|
|
13535
|
-
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
13536
|
-
|
|
13537
|
-
return (this[offset] * 0x1000000) +
|
|
13538
|
-
((this[offset + 1] << 16) |
|
|
13539
|
-
(this[offset + 2] << 8) |
|
|
13540
|
-
this[offset + 3])
|
|
13541
|
-
}
|
|
13542
|
-
|
|
13543
|
-
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
|
13544
|
-
offset = offset >>> 0
|
|
13545
|
-
byteLength = byteLength >>> 0
|
|
13546
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
13547
|
-
|
|
13548
|
-
var val = this[offset]
|
|
13549
|
-
var mul = 1
|
|
13550
|
-
var i = 0
|
|
13551
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
13552
|
-
val += this[offset + i] * mul
|
|
13553
|
-
}
|
|
13554
|
-
mul *= 0x80
|
|
13555
|
-
|
|
13556
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
|
13557
|
-
|
|
13558
|
-
return val
|
|
13559
|
-
}
|
|
13560
|
-
|
|
13561
|
-
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
|
13562
|
-
offset = offset >>> 0
|
|
13563
|
-
byteLength = byteLength >>> 0
|
|
13564
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
13565
|
-
|
|
13566
|
-
var i = byteLength
|
|
13567
|
-
var mul = 1
|
|
13568
|
-
var val = this[offset + --i]
|
|
13569
|
-
while (i > 0 && (mul *= 0x100)) {
|
|
13570
|
-
val += this[offset + --i] * mul
|
|
13571
|
-
}
|
|
13572
|
-
mul *= 0x80
|
|
13573
|
-
|
|
13574
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
|
13575
|
-
|
|
13576
|
-
return val
|
|
13577
|
-
}
|
|
13578
|
-
|
|
13579
|
-
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
|
13580
|
-
offset = offset >>> 0
|
|
13581
|
-
if (!noAssert) checkOffset(offset, 1, this.length)
|
|
13582
|
-
if (!(this[offset] & 0x80)) return (this[offset])
|
|
13583
|
-
return ((0xff - this[offset] + 1) * -1)
|
|
13584
|
-
}
|
|
13585
|
-
|
|
13586
|
-
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
|
13587
|
-
offset = offset >>> 0
|
|
13588
|
-
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
13589
|
-
var val = this[offset] | (this[offset + 1] << 8)
|
|
13590
|
-
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
13591
|
-
}
|
|
13592
|
-
|
|
13593
|
-
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
|
13594
|
-
offset = offset >>> 0
|
|
13595
|
-
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
13596
|
-
var val = this[offset + 1] | (this[offset] << 8)
|
|
13597
|
-
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
13598
|
-
}
|
|
13599
|
-
|
|
13600
|
-
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
|
13601
|
-
offset = offset >>> 0
|
|
13602
|
-
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
13603
|
-
|
|
13604
|
-
return (this[offset]) |
|
|
13605
|
-
(this[offset + 1] << 8) |
|
|
13606
|
-
(this[offset + 2] << 16) |
|
|
13607
|
-
(this[offset + 3] << 24)
|
|
13608
|
-
}
|
|
13609
|
-
|
|
13610
|
-
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
|
13611
|
-
offset = offset >>> 0
|
|
13612
|
-
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
13613
|
-
|
|
13614
|
-
return (this[offset] << 24) |
|
|
13615
|
-
(this[offset + 1] << 16) |
|
|
13616
|
-
(this[offset + 2] << 8) |
|
|
13617
|
-
(this[offset + 3])
|
|
13618
|
-
}
|
|
13619
|
-
|
|
13620
|
-
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
|
13621
|
-
offset = offset >>> 0
|
|
13622
|
-
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
13623
|
-
return ieee754.read(this, offset, true, 23, 4)
|
|
13624
|
-
}
|
|
13625
|
-
|
|
13626
|
-
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
|
13627
|
-
offset = offset >>> 0
|
|
13628
|
-
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
13629
|
-
return ieee754.read(this, offset, false, 23, 4)
|
|
13630
|
-
}
|
|
13631
|
-
|
|
13632
|
-
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
|
13633
|
-
offset = offset >>> 0
|
|
13634
|
-
if (!noAssert) checkOffset(offset, 8, this.length)
|
|
13635
|
-
return ieee754.read(this, offset, true, 52, 8)
|
|
13636
|
-
}
|
|
13637
|
-
|
|
13638
|
-
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
|
13639
|
-
offset = offset >>> 0
|
|
13640
|
-
if (!noAssert) checkOffset(offset, 8, this.length)
|
|
13641
|
-
return ieee754.read(this, offset, false, 52, 8)
|
|
13642
|
-
}
|
|
13643
|
-
|
|
13644
|
-
function checkInt (buf, value, offset, ext, max, min) {
|
|
13645
|
-
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
|
|
13646
|
-
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
|
|
13647
|
-
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
13648
|
-
}
|
|
13649
|
-
|
|
13650
|
-
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
|
13651
|
-
value = +value
|
|
13652
|
-
offset = offset >>> 0
|
|
13653
|
-
byteLength = byteLength >>> 0
|
|
13654
|
-
if (!noAssert) {
|
|
13655
|
-
var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
|
13656
|
-
checkInt(this, value, offset, byteLength, maxBytes, 0)
|
|
13657
|
-
}
|
|
13658
|
-
|
|
13659
|
-
var mul = 1
|
|
13660
|
-
var i = 0
|
|
13661
|
-
this[offset] = value & 0xFF
|
|
13662
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
13663
|
-
this[offset + i] = (value / mul) & 0xFF
|
|
13664
|
-
}
|
|
13665
|
-
|
|
13666
|
-
return offset + byteLength
|
|
13667
|
-
}
|
|
13668
|
-
|
|
13669
|
-
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
|
13670
|
-
value = +value
|
|
13671
|
-
offset = offset >>> 0
|
|
13672
|
-
byteLength = byteLength >>> 0
|
|
13673
|
-
if (!noAssert) {
|
|
13674
|
-
var maxBytes = Math.pow(2, 8 * byteLength) - 1
|
|
13675
|
-
checkInt(this, value, offset, byteLength, maxBytes, 0)
|
|
13676
|
-
}
|
|
13677
|
-
|
|
13678
|
-
var i = byteLength - 1
|
|
13679
|
-
var mul = 1
|
|
13680
|
-
this[offset + i] = value & 0xFF
|
|
13681
|
-
while (--i >= 0 && (mul *= 0x100)) {
|
|
13682
|
-
this[offset + i] = (value / mul) & 0xFF
|
|
13683
|
-
}
|
|
13684
|
-
|
|
13685
|
-
return offset + byteLength
|
|
13686
|
-
}
|
|
13687
|
-
|
|
13688
|
-
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
|
13689
|
-
value = +value
|
|
13690
|
-
offset = offset >>> 0
|
|
13691
|
-
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
|
|
13692
|
-
this[offset] = (value & 0xff)
|
|
13693
|
-
return offset + 1
|
|
13694
|
-
}
|
|
13695
|
-
|
|
13696
|
-
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
|
13697
|
-
value = +value
|
|
13698
|
-
offset = offset >>> 0
|
|
13699
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
|
13700
|
-
this[offset] = (value & 0xff)
|
|
13701
|
-
this[offset + 1] = (value >>> 8)
|
|
13702
|
-
return offset + 2
|
|
13703
|
-
}
|
|
13704
|
-
|
|
13705
|
-
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
|
13706
|
-
value = +value
|
|
13707
|
-
offset = offset >>> 0
|
|
13708
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
|
13709
|
-
this[offset] = (value >>> 8)
|
|
13710
|
-
this[offset + 1] = (value & 0xff)
|
|
13711
|
-
return offset + 2
|
|
13712
|
-
}
|
|
13713
|
-
|
|
13714
|
-
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
|
13715
|
-
value = +value
|
|
13716
|
-
offset = offset >>> 0
|
|
13717
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
|
13718
|
-
this[offset + 3] = (value >>> 24)
|
|
13719
|
-
this[offset + 2] = (value >>> 16)
|
|
13720
|
-
this[offset + 1] = (value >>> 8)
|
|
13721
|
-
this[offset] = (value & 0xff)
|
|
13722
|
-
return offset + 4
|
|
13723
|
-
}
|
|
13724
|
-
|
|
13725
|
-
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
|
13726
|
-
value = +value
|
|
13727
|
-
offset = offset >>> 0
|
|
13728
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
|
13729
|
-
this[offset] = (value >>> 24)
|
|
13730
|
-
this[offset + 1] = (value >>> 16)
|
|
13731
|
-
this[offset + 2] = (value >>> 8)
|
|
13732
|
-
this[offset + 3] = (value & 0xff)
|
|
13733
|
-
return offset + 4
|
|
13734
|
-
}
|
|
13735
|
-
|
|
13736
|
-
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
|
13737
|
-
value = +value
|
|
13738
|
-
offset = offset >>> 0
|
|
13739
|
-
if (!noAssert) {
|
|
13740
|
-
var limit = Math.pow(2, (8 * byteLength) - 1)
|
|
13741
|
-
|
|
13742
|
-
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
|
13743
|
-
}
|
|
13744
|
-
|
|
13745
|
-
var i = 0
|
|
13746
|
-
var mul = 1
|
|
13747
|
-
var sub = 0
|
|
13748
|
-
this[offset] = value & 0xFF
|
|
13749
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
13750
|
-
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
13751
|
-
sub = 1
|
|
13752
|
-
}
|
|
13753
|
-
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
|
13754
|
-
}
|
|
13755
|
-
|
|
13756
|
-
return offset + byteLength
|
|
13757
|
-
}
|
|
13758
|
-
|
|
13759
|
-
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
|
13760
|
-
value = +value
|
|
13761
|
-
offset = offset >>> 0
|
|
13762
|
-
if (!noAssert) {
|
|
13763
|
-
var limit = Math.pow(2, (8 * byteLength) - 1)
|
|
13764
|
-
|
|
13765
|
-
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
|
13766
|
-
}
|
|
13767
|
-
|
|
13768
|
-
var i = byteLength - 1
|
|
13769
|
-
var mul = 1
|
|
13770
|
-
var sub = 0
|
|
13771
|
-
this[offset + i] = value & 0xFF
|
|
13772
|
-
while (--i >= 0 && (mul *= 0x100)) {
|
|
13773
|
-
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
13774
|
-
sub = 1
|
|
13775
|
-
}
|
|
13776
|
-
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
|
13777
|
-
}
|
|
13778
|
-
|
|
13779
|
-
return offset + byteLength
|
|
13780
|
-
}
|
|
13781
|
-
|
|
13782
|
-
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
|
13783
|
-
value = +value
|
|
13784
|
-
offset = offset >>> 0
|
|
13785
|
-
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
|
|
13786
|
-
if (value < 0) value = 0xff + value + 1
|
|
13787
|
-
this[offset] = (value & 0xff)
|
|
13788
|
-
return offset + 1
|
|
13789
|
-
}
|
|
13790
|
-
|
|
13791
|
-
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
|
13792
|
-
value = +value
|
|
13793
|
-
offset = offset >>> 0
|
|
13794
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
|
13795
|
-
this[offset] = (value & 0xff)
|
|
13796
|
-
this[offset + 1] = (value >>> 8)
|
|
13797
|
-
return offset + 2
|
|
13798
|
-
}
|
|
13799
|
-
|
|
13800
|
-
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
|
13801
|
-
value = +value
|
|
13802
|
-
offset = offset >>> 0
|
|
13803
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
|
13804
|
-
this[offset] = (value >>> 8)
|
|
13805
|
-
this[offset + 1] = (value & 0xff)
|
|
13806
|
-
return offset + 2
|
|
13807
|
-
}
|
|
13808
|
-
|
|
13809
|
-
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
|
13810
|
-
value = +value
|
|
13811
|
-
offset = offset >>> 0
|
|
13812
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
|
13813
|
-
this[offset] = (value & 0xff)
|
|
13814
|
-
this[offset + 1] = (value >>> 8)
|
|
13815
|
-
this[offset + 2] = (value >>> 16)
|
|
13816
|
-
this[offset + 3] = (value >>> 24)
|
|
13817
|
-
return offset + 4
|
|
13818
|
-
}
|
|
13819
|
-
|
|
13820
|
-
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
|
13821
|
-
value = +value
|
|
13822
|
-
offset = offset >>> 0
|
|
13823
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
|
13824
|
-
if (value < 0) value = 0xffffffff + value + 1
|
|
13825
|
-
this[offset] = (value >>> 24)
|
|
13826
|
-
this[offset + 1] = (value >>> 16)
|
|
13827
|
-
this[offset + 2] = (value >>> 8)
|
|
13828
|
-
this[offset + 3] = (value & 0xff)
|
|
13829
|
-
return offset + 4
|
|
13830
|
-
}
|
|
13831
|
-
|
|
13832
|
-
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
|
13833
|
-
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
13834
|
-
if (offset < 0) throw new RangeError('Index out of range')
|
|
13835
|
-
}
|
|
13836
|
-
|
|
13837
|
-
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
13838
|
-
value = +value
|
|
13839
|
-
offset = offset >>> 0
|
|
13840
|
-
if (!noAssert) {
|
|
13841
|
-
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
|
13842
|
-
}
|
|
13843
|
-
ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
|
13844
|
-
return offset + 4
|
|
13845
|
-
}
|
|
13846
|
-
|
|
13847
|
-
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
|
13848
|
-
return writeFloat(this, value, offset, true, noAssert)
|
|
13849
|
-
}
|
|
13850
|
-
|
|
13851
|
-
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
|
13852
|
-
return writeFloat(this, value, offset, false, noAssert)
|
|
13853
|
-
}
|
|
13854
|
-
|
|
13855
|
-
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
13856
|
-
value = +value
|
|
13857
|
-
offset = offset >>> 0
|
|
13858
|
-
if (!noAssert) {
|
|
13859
|
-
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
|
13860
|
-
}
|
|
13861
|
-
ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
|
13862
|
-
return offset + 8
|
|
13863
|
-
}
|
|
13864
|
-
|
|
13865
|
-
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
|
13866
|
-
return writeDouble(this, value, offset, true, noAssert)
|
|
13867
|
-
}
|
|
13868
|
-
|
|
13869
|
-
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
|
13870
|
-
return writeDouble(this, value, offset, false, noAssert)
|
|
13871
|
-
}
|
|
13872
|
-
|
|
13873
|
-
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
13874
|
-
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
|
13875
|
-
if (!start) start = 0
|
|
13876
|
-
if (!end && end !== 0) end = this.length
|
|
13877
|
-
if (targetStart >= target.length) targetStart = target.length
|
|
13878
|
-
if (!targetStart) targetStart = 0
|
|
13879
|
-
if (end > 0 && end < start) end = start
|
|
13880
|
-
|
|
13881
|
-
// Copy 0 bytes; we're done
|
|
13882
|
-
if (end === start) return 0
|
|
13883
|
-
if (target.length === 0 || this.length === 0) return 0
|
|
13884
|
-
|
|
13885
|
-
// Fatal error conditions
|
|
13886
|
-
if (targetStart < 0) {
|
|
13887
|
-
throw new RangeError('targetStart out of bounds')
|
|
13888
|
-
}
|
|
13889
|
-
if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
|
|
13890
|
-
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
|
13891
|
-
|
|
13892
|
-
// Are we oob?
|
|
13893
|
-
if (end > this.length) end = this.length
|
|
13894
|
-
if (target.length - targetStart < end - start) {
|
|
13895
|
-
end = target.length - targetStart + start
|
|
13896
|
-
}
|
|
13897
|
-
|
|
13898
|
-
var len = end - start
|
|
13899
|
-
var i
|
|
13900
|
-
|
|
13901
|
-
if (this === target && start < targetStart && targetStart < end) {
|
|
13902
|
-
// descending copy from end
|
|
13903
|
-
for (i = len - 1; i >= 0; --i) {
|
|
13904
|
-
target[i + targetStart] = this[i + start]
|
|
13905
|
-
}
|
|
13906
|
-
} else if (len < 1000) {
|
|
13907
|
-
// ascending copy from start
|
|
13908
|
-
for (i = 0; i < len; ++i) {
|
|
13909
|
-
target[i + targetStart] = this[i + start]
|
|
13910
|
-
}
|
|
13911
|
-
} else {
|
|
13912
|
-
Uint8Array.prototype.set.call(
|
|
13913
|
-
target,
|
|
13914
|
-
this.subarray(start, start + len),
|
|
13915
|
-
targetStart
|
|
13916
|
-
)
|
|
13917
|
-
}
|
|
13918
|
-
|
|
13919
|
-
return len
|
|
13920
|
-
}
|
|
13921
|
-
|
|
13922
|
-
// Usage:
|
|
13923
|
-
// buffer.fill(number[, offset[, end]])
|
|
13924
|
-
// buffer.fill(buffer[, offset[, end]])
|
|
13925
|
-
// buffer.fill(string[, offset[, end]][, encoding])
|
|
13926
|
-
Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
13927
|
-
// Handle string cases:
|
|
13928
|
-
if (typeof val === 'string') {
|
|
13929
|
-
if (typeof start === 'string') {
|
|
13930
|
-
encoding = start
|
|
13931
|
-
start = 0
|
|
13932
|
-
end = this.length
|
|
13933
|
-
} else if (typeof end === 'string') {
|
|
13934
|
-
encoding = end
|
|
13935
|
-
end = this.length
|
|
13936
|
-
}
|
|
13937
|
-
if (val.length === 1) {
|
|
13938
|
-
var code = val.charCodeAt(0)
|
|
13939
|
-
if (code < 256) {
|
|
13940
|
-
val = code
|
|
13941
|
-
}
|
|
13942
|
-
}
|
|
13943
|
-
if (encoding !== undefined && typeof encoding !== 'string') {
|
|
13944
|
-
throw new TypeError('encoding must be a string')
|
|
13945
|
-
}
|
|
13946
|
-
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
|
13947
|
-
throw new TypeError('Unknown encoding: ' + encoding)
|
|
13948
|
-
}
|
|
13949
|
-
} else if (typeof val === 'number') {
|
|
13950
|
-
val = val & 255
|
|
13951
|
-
}
|
|
13952
|
-
|
|
13953
|
-
// Invalid ranges are not set to a default, so can range check early.
|
|
13954
|
-
if (start < 0 || this.length < start || this.length < end) {
|
|
13955
|
-
throw new RangeError('Out of range index')
|
|
13956
|
-
}
|
|
13957
|
-
|
|
13958
|
-
if (end <= start) {
|
|
13959
|
-
return this
|
|
13960
|
-
}
|
|
13961
|
-
|
|
13962
|
-
start = start >>> 0
|
|
13963
|
-
end = end === undefined ? this.length : end >>> 0
|
|
13964
|
-
|
|
13965
|
-
if (!val) val = 0
|
|
13966
|
-
|
|
13967
|
-
var i
|
|
13968
|
-
if (typeof val === 'number') {
|
|
13969
|
-
for (i = start; i < end; ++i) {
|
|
13970
|
-
this[i] = val
|
|
13971
|
-
}
|
|
13972
|
-
} else {
|
|
13973
|
-
var bytes = Buffer.isBuffer(val)
|
|
13974
|
-
? val
|
|
13975
|
-
: new Buffer(val, encoding)
|
|
13976
|
-
var len = bytes.length
|
|
13977
|
-
for (i = 0; i < end - start; ++i) {
|
|
13978
|
-
this[i + start] = bytes[i % len]
|
|
13979
|
-
}
|
|
13980
|
-
}
|
|
13981
|
-
|
|
13982
|
-
return this
|
|
13983
|
-
}
|
|
13984
|
-
|
|
13985
|
-
// HELPER FUNCTIONS
|
|
13986
|
-
// ================
|
|
13987
|
-
|
|
13988
|
-
var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
|
|
13989
|
-
|
|
13990
|
-
function base64clean (str) {
|
|
13991
|
-
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
|
13992
|
-
str = str.trim().replace(INVALID_BASE64_RE, '')
|
|
13993
|
-
// Node converts strings with length < 2 to ''
|
|
13994
|
-
if (str.length < 2) return ''
|
|
13995
|
-
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
|
13996
|
-
while (str.length % 4 !== 0) {
|
|
13997
|
-
str = str + '='
|
|
13998
|
-
}
|
|
13999
|
-
return str
|
|
14000
|
-
}
|
|
14001
|
-
|
|
14002
|
-
function toHex (n) {
|
|
14003
|
-
if (n < 16) return '0' + n.toString(16)
|
|
14004
|
-
return n.toString(16)
|
|
14005
|
-
}
|
|
14006
|
-
|
|
14007
|
-
function utf8ToBytes (string, units) {
|
|
14008
|
-
units = units || Infinity
|
|
14009
|
-
var codePoint
|
|
14010
|
-
var length = string.length
|
|
14011
|
-
var leadSurrogate = null
|
|
14012
|
-
var bytes = []
|
|
14013
|
-
|
|
14014
|
-
for (var i = 0; i < length; ++i) {
|
|
14015
|
-
codePoint = string.charCodeAt(i)
|
|
14016
|
-
|
|
14017
|
-
// is surrogate component
|
|
14018
|
-
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
|
14019
|
-
// last char was a lead
|
|
14020
|
-
if (!leadSurrogate) {
|
|
14021
|
-
// no lead yet
|
|
14022
|
-
if (codePoint > 0xDBFF) {
|
|
14023
|
-
// unexpected trail
|
|
14024
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
14025
|
-
continue
|
|
14026
|
-
} else if (i + 1 === length) {
|
|
14027
|
-
// unpaired lead
|
|
14028
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
14029
|
-
continue
|
|
14030
|
-
}
|
|
14031
|
-
|
|
14032
|
-
// valid lead
|
|
14033
|
-
leadSurrogate = codePoint
|
|
14034
|
-
|
|
14035
|
-
continue
|
|
14036
|
-
}
|
|
14037
|
-
|
|
14038
|
-
// 2 leads in a row
|
|
14039
|
-
if (codePoint < 0xDC00) {
|
|
14040
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
14041
|
-
leadSurrogate = codePoint
|
|
14042
|
-
continue
|
|
14043
|
-
}
|
|
14044
|
-
|
|
14045
|
-
// valid surrogate pair
|
|
14046
|
-
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
|
|
14047
|
-
} else if (leadSurrogate) {
|
|
14048
|
-
// valid bmp char, but last char was a lead
|
|
14049
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
14050
|
-
}
|
|
14051
|
-
|
|
14052
|
-
leadSurrogate = null
|
|
14053
|
-
|
|
14054
|
-
// encode utf8
|
|
14055
|
-
if (codePoint < 0x80) {
|
|
14056
|
-
if ((units -= 1) < 0) break
|
|
14057
|
-
bytes.push(codePoint)
|
|
14058
|
-
} else if (codePoint < 0x800) {
|
|
14059
|
-
if ((units -= 2) < 0) break
|
|
14060
|
-
bytes.push(
|
|
14061
|
-
codePoint >> 0x6 | 0xC0,
|
|
14062
|
-
codePoint & 0x3F | 0x80
|
|
14063
|
-
)
|
|
14064
|
-
} else if (codePoint < 0x10000) {
|
|
14065
|
-
if ((units -= 3) < 0) break
|
|
14066
|
-
bytes.push(
|
|
14067
|
-
codePoint >> 0xC | 0xE0,
|
|
14068
|
-
codePoint >> 0x6 & 0x3F | 0x80,
|
|
14069
|
-
codePoint & 0x3F | 0x80
|
|
14070
|
-
)
|
|
14071
|
-
} else if (codePoint < 0x110000) {
|
|
14072
|
-
if ((units -= 4) < 0) break
|
|
14073
|
-
bytes.push(
|
|
14074
|
-
codePoint >> 0x12 | 0xF0,
|
|
14075
|
-
codePoint >> 0xC & 0x3F | 0x80,
|
|
14076
|
-
codePoint >> 0x6 & 0x3F | 0x80,
|
|
14077
|
-
codePoint & 0x3F | 0x80
|
|
14078
|
-
)
|
|
14079
|
-
} else {
|
|
14080
|
-
throw new Error('Invalid code point')
|
|
14081
|
-
}
|
|
14082
|
-
}
|
|
14083
|
-
|
|
14084
|
-
return bytes
|
|
14085
|
-
}
|
|
14086
|
-
|
|
14087
|
-
function asciiToBytes (str) {
|
|
14088
|
-
var byteArray = []
|
|
14089
|
-
for (var i = 0; i < str.length; ++i) {
|
|
14090
|
-
// Node's code seems to be doing this and not & 0x7F..
|
|
14091
|
-
byteArray.push(str.charCodeAt(i) & 0xFF)
|
|
14092
|
-
}
|
|
14093
|
-
return byteArray
|
|
14094
|
-
}
|
|
14095
|
-
|
|
14096
|
-
function utf16leToBytes (str, units) {
|
|
14097
|
-
var c, hi, lo
|
|
14098
|
-
var byteArray = []
|
|
14099
|
-
for (var i = 0; i < str.length; ++i) {
|
|
14100
|
-
if ((units -= 2) < 0) break
|
|
14101
|
-
|
|
14102
|
-
c = str.charCodeAt(i)
|
|
14103
|
-
hi = c >> 8
|
|
14104
|
-
lo = c % 256
|
|
14105
|
-
byteArray.push(lo)
|
|
14106
|
-
byteArray.push(hi)
|
|
14107
|
-
}
|
|
14108
|
-
|
|
14109
|
-
return byteArray
|
|
14110
|
-
}
|
|
14111
|
-
|
|
14112
|
-
function base64ToBytes (str) {
|
|
14113
|
-
return base64.toByteArray(base64clean(str))
|
|
14114
|
-
}
|
|
14115
|
-
|
|
14116
|
-
function blitBuffer (src, dst, offset, length) {
|
|
14117
|
-
for (var i = 0; i < length; ++i) {
|
|
14118
|
-
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
14119
|
-
dst[i + offset] = src[i]
|
|
14120
|
-
}
|
|
14121
|
-
return i
|
|
14122
|
-
}
|
|
14123
|
-
|
|
14124
|
-
// ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check
|
|
14125
|
-
// but they should be treated as valid. See: https://github.com/feross/buffer/issues/166
|
|
14126
|
-
function isArrayBuffer (obj) {
|
|
14127
|
-
return obj instanceof ArrayBuffer ||
|
|
14128
|
-
(obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' &&
|
|
14129
|
-
typeof obj.byteLength === 'number')
|
|
14130
|
-
}
|
|
14131
|
-
|
|
14132
|
-
// Node 0.10 supports `ArrayBuffer` but lacks `ArrayBuffer.isView`
|
|
14133
|
-
function isArrayBufferView (obj) {
|
|
14134
|
-
return (typeof ArrayBuffer.isView === 'function') && ArrayBuffer.isView(obj)
|
|
14135
|
-
}
|
|
14136
|
-
|
|
14137
|
-
function numberIsNaN (obj) {
|
|
14138
|
-
return obj !== obj // eslint-disable-line no-self-compare
|
|
14139
|
-
}
|
|
14140
|
-
|
|
14141
|
-
},{"base64-js":100,"ieee754":103}],102:[function(require,module,exports){
|
|
14142
|
-
(function (Buffer){
|
|
14143
|
-
var clone = (function() {
|
|
14144
|
-
'use strict';
|
|
14145
|
-
|
|
14146
|
-
function _instanceof(obj, type) {
|
|
14147
|
-
return type != null && obj instanceof type;
|
|
14148
|
-
}
|
|
14149
|
-
|
|
14150
|
-
var nativeMap;
|
|
14151
|
-
try {
|
|
14152
|
-
nativeMap = Map;
|
|
14153
|
-
} catch(_) {
|
|
14154
|
-
// maybe a reference error because no `Map`. Give it a dummy value that no
|
|
14155
|
-
// value will ever be an instanceof.
|
|
14156
|
-
nativeMap = function() {};
|
|
14157
|
-
}
|
|
14158
|
-
|
|
14159
|
-
var nativeSet;
|
|
14160
|
-
try {
|
|
14161
|
-
nativeSet = Set;
|
|
14162
|
-
} catch(_) {
|
|
14163
|
-
nativeSet = function() {};
|
|
14164
|
-
}
|
|
14165
|
-
|
|
14166
|
-
var nativePromise;
|
|
14167
|
-
try {
|
|
14168
|
-
nativePromise = Promise;
|
|
14169
|
-
} catch(_) {
|
|
14170
|
-
nativePromise = function() {};
|
|
14171
|
-
}
|
|
14172
|
-
|
|
14173
|
-
/**
|
|
14174
|
-
* Clones (copies) an Object using deep copying.
|
|
14175
|
-
*
|
|
14176
|
-
* This function supports circular references by default, but if you are certain
|
|
14177
|
-
* there are no circular references in your object, you can save some CPU time
|
|
14178
|
-
* by calling clone(obj, false).
|
|
14179
|
-
*
|
|
14180
|
-
* Caution: if `circular` is false and `parent` contains circular references,
|
|
14181
|
-
* your program may enter an infinite loop and crash.
|
|
14182
|
-
*
|
|
14183
|
-
* @param `parent` - the object to be cloned
|
|
14184
|
-
* @param `circular` - set to true if the object to be cloned may contain
|
|
14185
|
-
* circular references. (optional - true by default)
|
|
14186
|
-
* @param `depth` - set to a number if the object is only to be cloned to
|
|
14187
|
-
* a particular depth. (optional - defaults to Infinity)
|
|
14188
|
-
* @param `prototype` - sets the prototype to be used when cloning an object.
|
|
14189
|
-
* (optional - defaults to parent prototype).
|
|
14190
|
-
* @param `includeNonEnumerable` - set to true if the non-enumerable properties
|
|
14191
|
-
* should be cloned as well. Non-enumerable properties on the prototype
|
|
14192
|
-
* chain will be ignored. (optional - false by default)
|
|
14193
|
-
*/
|
|
14194
|
-
function clone(parent, circular, depth, prototype, includeNonEnumerable) {
|
|
14195
|
-
if (typeof circular === 'object') {
|
|
14196
|
-
depth = circular.depth;
|
|
14197
|
-
prototype = circular.prototype;
|
|
14198
|
-
includeNonEnumerable = circular.includeNonEnumerable;
|
|
14199
|
-
circular = circular.circular;
|
|
14200
|
-
}
|
|
14201
|
-
// maintain two arrays for circular references, where corresponding parents
|
|
14202
|
-
// and children have the same index
|
|
14203
|
-
var allParents = [];
|
|
14204
|
-
var allChildren = [];
|
|
14205
|
-
|
|
14206
|
-
var useBuffer = typeof Buffer != 'undefined';
|
|
14207
|
-
|
|
14208
|
-
if (typeof circular == 'undefined')
|
|
14209
|
-
circular = true;
|
|
14210
|
-
|
|
14211
|
-
if (typeof depth == 'undefined')
|
|
14212
|
-
depth = Infinity;
|
|
14213
|
-
|
|
14214
|
-
// recurse this function so we don't reset allParents and allChildren
|
|
14215
|
-
function _clone(parent, depth) {
|
|
14216
|
-
// cloning null always returns null
|
|
14217
|
-
if (parent === null)
|
|
14218
|
-
return null;
|
|
14219
|
-
|
|
14220
|
-
if (depth === 0)
|
|
14221
|
-
return parent;
|
|
14222
|
-
|
|
14223
|
-
var child;
|
|
14224
|
-
var proto;
|
|
14225
|
-
if (typeof parent != 'object') {
|
|
14226
|
-
return parent;
|
|
14227
|
-
}
|
|
14228
|
-
|
|
14229
|
-
if (_instanceof(parent, nativeMap)) {
|
|
14230
|
-
child = new nativeMap();
|
|
14231
|
-
} else if (_instanceof(parent, nativeSet)) {
|
|
14232
|
-
child = new nativeSet();
|
|
14233
|
-
} else if (_instanceof(parent, nativePromise)) {
|
|
14234
|
-
child = new nativePromise(function (resolve, reject) {
|
|
14235
|
-
parent.then(function(value) {
|
|
14236
|
-
resolve(_clone(value, depth - 1));
|
|
14237
|
-
}, function(err) {
|
|
14238
|
-
reject(_clone(err, depth - 1));
|
|
14239
|
-
});
|
|
14240
|
-
});
|
|
14241
|
-
} else if (clone.__isArray(parent)) {
|
|
14242
|
-
child = [];
|
|
14243
|
-
} else if (clone.__isRegExp(parent)) {
|
|
14244
|
-
child = new RegExp(parent.source, __getRegExpFlags(parent));
|
|
14245
|
-
if (parent.lastIndex) child.lastIndex = parent.lastIndex;
|
|
14246
|
-
} else if (clone.__isDate(parent)) {
|
|
14247
|
-
child = new Date(parent.getTime());
|
|
14248
|
-
} else if (useBuffer && Buffer.isBuffer(parent)) {
|
|
14249
|
-
if (Buffer.allocUnsafe) {
|
|
14250
|
-
// Node.js >= 4.5.0
|
|
14251
|
-
child = Buffer.allocUnsafe(parent.length);
|
|
14252
|
-
} else {
|
|
14253
|
-
// Older Node.js versions
|
|
14254
|
-
child = new Buffer(parent.length);
|
|
14255
|
-
}
|
|
14256
|
-
parent.copy(child);
|
|
14257
|
-
return child;
|
|
14258
|
-
} else if (_instanceof(parent, Error)) {
|
|
14259
|
-
child = Object.create(parent);
|
|
14260
|
-
} else {
|
|
14261
|
-
if (typeof prototype == 'undefined') {
|
|
14262
|
-
proto = Object.getPrototypeOf(parent);
|
|
14263
|
-
child = Object.create(proto);
|
|
14264
|
-
}
|
|
14265
|
-
else {
|
|
14266
|
-
child = Object.create(prototype);
|
|
14267
|
-
proto = prototype;
|
|
14268
|
-
}
|
|
14269
|
-
}
|
|
14270
|
-
|
|
14271
|
-
if (circular) {
|
|
14272
|
-
var index = allParents.indexOf(parent);
|
|
14273
|
-
|
|
14274
|
-
if (index != -1) {
|
|
14275
|
-
return allChildren[index];
|
|
14276
|
-
}
|
|
14277
|
-
allParents.push(parent);
|
|
14278
|
-
allChildren.push(child);
|
|
14279
|
-
}
|
|
14280
|
-
|
|
14281
|
-
if (_instanceof(parent, nativeMap)) {
|
|
14282
|
-
parent.forEach(function(value, key) {
|
|
14283
|
-
var keyChild = _clone(key, depth - 1);
|
|
14284
|
-
var valueChild = _clone(value, depth - 1);
|
|
14285
|
-
child.set(keyChild, valueChild);
|
|
14286
|
-
});
|
|
14287
|
-
}
|
|
14288
|
-
if (_instanceof(parent, nativeSet)) {
|
|
14289
|
-
parent.forEach(function(value) {
|
|
14290
|
-
var entryChild = _clone(value, depth - 1);
|
|
14291
|
-
child.add(entryChild);
|
|
14292
|
-
});
|
|
14293
|
-
}
|
|
14294
|
-
|
|
14295
|
-
for (var i in parent) {
|
|
14296
|
-
var attrs;
|
|
14297
|
-
if (proto) {
|
|
14298
|
-
attrs = Object.getOwnPropertyDescriptor(proto, i);
|
|
14299
|
-
}
|
|
14300
|
-
|
|
14301
|
-
if (attrs && attrs.set == null) {
|
|
14302
|
-
continue;
|
|
14303
|
-
}
|
|
14304
|
-
child[i] = _clone(parent[i], depth - 1);
|
|
14305
|
-
}
|
|
14306
|
-
|
|
14307
|
-
if (Object.getOwnPropertySymbols) {
|
|
14308
|
-
var symbols = Object.getOwnPropertySymbols(parent);
|
|
14309
|
-
for (var i = 0; i < symbols.length; i++) {
|
|
14310
|
-
// Don't need to worry about cloning a symbol because it is a primitive,
|
|
14311
|
-
// like a number or string.
|
|
14312
|
-
var symbol = symbols[i];
|
|
14313
|
-
var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
|
|
14314
|
-
if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
|
|
14315
|
-
continue;
|
|
14316
|
-
}
|
|
14317
|
-
child[symbol] = _clone(parent[symbol], depth - 1);
|
|
14318
|
-
if (!descriptor.enumerable) {
|
|
14319
|
-
Object.defineProperty(child, symbol, {
|
|
14320
|
-
enumerable: false
|
|
14321
|
-
});
|
|
14322
|
-
}
|
|
14323
|
-
}
|
|
14324
|
-
}
|
|
14325
|
-
|
|
14326
|
-
if (includeNonEnumerable) {
|
|
14327
|
-
var allPropertyNames = Object.getOwnPropertyNames(parent);
|
|
14328
|
-
for (var i = 0; i < allPropertyNames.length; i++) {
|
|
14329
|
-
var propertyName = allPropertyNames[i];
|
|
14330
|
-
var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
|
|
14331
|
-
if (descriptor && descriptor.enumerable) {
|
|
14332
|
-
continue;
|
|
14333
|
-
}
|
|
14334
|
-
child[propertyName] = _clone(parent[propertyName], depth - 1);
|
|
14335
|
-
Object.defineProperty(child, propertyName, {
|
|
14336
|
-
enumerable: false
|
|
14337
|
-
});
|
|
14338
|
-
}
|
|
14339
|
-
}
|
|
14340
|
-
|
|
14341
|
-
return child;
|
|
14342
|
-
}
|
|
14343
|
-
|
|
14344
|
-
return _clone(parent, depth);
|
|
14345
|
-
}
|
|
14346
|
-
|
|
14347
|
-
/**
|
|
14348
|
-
* Simple flat clone using prototype, accepts only objects, usefull for property
|
|
14349
|
-
* override on FLAT configuration object (no nested props).
|
|
14350
|
-
*
|
|
14351
|
-
* USE WITH CAUTION! This may not behave as you wish if you do not know how this
|
|
14352
|
-
* works.
|
|
14353
|
-
*/
|
|
14354
|
-
clone.clonePrototype = function clonePrototype(parent) {
|
|
14355
|
-
if (parent === null)
|
|
14356
|
-
return null;
|
|
14357
|
-
|
|
14358
|
-
var c = function () {};
|
|
14359
|
-
c.prototype = parent;
|
|
14360
|
-
return new c();
|
|
14361
|
-
};
|
|
14362
|
-
|
|
14363
|
-
// private utility functions
|
|
14364
|
-
|
|
14365
|
-
function __objToStr(o) {
|
|
14366
|
-
return Object.prototype.toString.call(o);
|
|
14367
|
-
}
|
|
14368
|
-
clone.__objToStr = __objToStr;
|
|
14369
|
-
|
|
14370
|
-
function __isDate(o) {
|
|
14371
|
-
return typeof o === 'object' && __objToStr(o) === '[object Date]';
|
|
14372
|
-
}
|
|
14373
|
-
clone.__isDate = __isDate;
|
|
12578
|
+
clone.__isDate = __isDate;
|
|
14374
12579
|
|
|
14375
12580
|
function __isArray(o) {
|
|
14376
12581
|
return typeof o === 'object' && __objToStr(o) === '[object Array]';
|
|
@@ -14398,94 +12603,7 @@ if (typeof module === 'object' && module.exports) {
|
|
|
14398
12603
|
module.exports = clone;
|
|
14399
12604
|
}
|
|
14400
12605
|
|
|
14401
|
-
}
|
|
14402
|
-
},{"buffer":101}],103:[function(require,module,exports){
|
|
14403
|
-
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
14404
|
-
var e, m
|
|
14405
|
-
var eLen = nBytes * 8 - mLen - 1
|
|
14406
|
-
var eMax = (1 << eLen) - 1
|
|
14407
|
-
var eBias = eMax >> 1
|
|
14408
|
-
var nBits = -7
|
|
14409
|
-
var i = isLE ? (nBytes - 1) : 0
|
|
14410
|
-
var d = isLE ? -1 : 1
|
|
14411
|
-
var s = buffer[offset + i]
|
|
14412
|
-
|
|
14413
|
-
i += d
|
|
14414
|
-
|
|
14415
|
-
e = s & ((1 << (-nBits)) - 1)
|
|
14416
|
-
s >>= (-nBits)
|
|
14417
|
-
nBits += eLen
|
|
14418
|
-
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
|
14419
|
-
|
|
14420
|
-
m = e & ((1 << (-nBits)) - 1)
|
|
14421
|
-
e >>= (-nBits)
|
|
14422
|
-
nBits += mLen
|
|
14423
|
-
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
|
14424
|
-
|
|
14425
|
-
if (e === 0) {
|
|
14426
|
-
e = 1 - eBias
|
|
14427
|
-
} else if (e === eMax) {
|
|
14428
|
-
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
|
14429
|
-
} else {
|
|
14430
|
-
m = m + Math.pow(2, mLen)
|
|
14431
|
-
e = e - eBias
|
|
14432
|
-
}
|
|
14433
|
-
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
14434
|
-
}
|
|
14435
|
-
|
|
14436
|
-
exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
14437
|
-
var e, m, c
|
|
14438
|
-
var eLen = nBytes * 8 - mLen - 1
|
|
14439
|
-
var eMax = (1 << eLen) - 1
|
|
14440
|
-
var eBias = eMax >> 1
|
|
14441
|
-
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
|
|
14442
|
-
var i = isLE ? 0 : (nBytes - 1)
|
|
14443
|
-
var d = isLE ? 1 : -1
|
|
14444
|
-
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
|
|
14445
|
-
|
|
14446
|
-
value = Math.abs(value)
|
|
14447
|
-
|
|
14448
|
-
if (isNaN(value) || value === Infinity) {
|
|
14449
|
-
m = isNaN(value) ? 1 : 0
|
|
14450
|
-
e = eMax
|
|
14451
|
-
} else {
|
|
14452
|
-
e = Math.floor(Math.log(value) / Math.LN2)
|
|
14453
|
-
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
14454
|
-
e--
|
|
14455
|
-
c *= 2
|
|
14456
|
-
}
|
|
14457
|
-
if (e + eBias >= 1) {
|
|
14458
|
-
value += rt / c
|
|
14459
|
-
} else {
|
|
14460
|
-
value += rt * Math.pow(2, 1 - eBias)
|
|
14461
|
-
}
|
|
14462
|
-
if (value * c >= 2) {
|
|
14463
|
-
e++
|
|
14464
|
-
c /= 2
|
|
14465
|
-
}
|
|
14466
|
-
|
|
14467
|
-
if (e + eBias >= eMax) {
|
|
14468
|
-
m = 0
|
|
14469
|
-
e = eMax
|
|
14470
|
-
} else if (e + eBias >= 1) {
|
|
14471
|
-
m = (value * c - 1) * Math.pow(2, mLen)
|
|
14472
|
-
e = e + eBias
|
|
14473
|
-
} else {
|
|
14474
|
-
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
|
14475
|
-
e = 0
|
|
14476
|
-
}
|
|
14477
|
-
}
|
|
14478
|
-
|
|
14479
|
-
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
|
14480
|
-
|
|
14481
|
-
e = (e << mLen) | m
|
|
14482
|
-
eLen += mLen
|
|
14483
|
-
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
|
14484
|
-
|
|
14485
|
-
buffer[offset + i - d] |= s * 128
|
|
14486
|
-
}
|
|
14487
|
-
|
|
14488
|
-
},{}],104:[function(require,module,exports){
|
|
12606
|
+
},{}],101:[function(require,module,exports){
|
|
14489
12607
|
'use strict';
|
|
14490
12608
|
|
|
14491
12609
|
var asap = require('asap/raw');
|
|
@@ -14700,7 +12818,7 @@ function doResolve(fn, promise) {
|
|
|
14700
12818
|
}
|
|
14701
12819
|
}
|
|
14702
12820
|
|
|
14703
|
-
},{"asap/raw":99}],
|
|
12821
|
+
},{"asap/raw":99}],102:[function(require,module,exports){
|
|
14704
12822
|
'use strict';
|
|
14705
12823
|
|
|
14706
12824
|
//This file contains the ES6 extensions to the core Promises/A+ API
|
|
@@ -14809,7 +12927,7 @@ Promise.prototype['catch'] = function (onRejected) {
|
|
|
14809
12927
|
return this.then(null, onRejected);
|
|
14810
12928
|
};
|
|
14811
12929
|
|
|
14812
|
-
},{"./core.js":
|
|
12930
|
+
},{"./core.js":101}],103:[function(require,module,exports){
|
|
14813
12931
|
// should work in any browser without browserify
|
|
14814
12932
|
|
|
14815
12933
|
if (typeof Promise.prototype.done !== 'function') {
|
|
@@ -14822,7 +12940,7 @@ if (typeof Promise.prototype.done !== 'function') {
|
|
|
14822
12940
|
})
|
|
14823
12941
|
}
|
|
14824
12942
|
}
|
|
14825
|
-
},{}],
|
|
12943
|
+
},{}],104:[function(require,module,exports){
|
|
14826
12944
|
// not "use strict" so we can declare global "Promise"
|
|
14827
12945
|
|
|
14828
12946
|
var asap = require('asap');
|
|
@@ -14834,5 +12952,5 @@ if (typeof Promise === 'undefined') {
|
|
|
14834
12952
|
|
|
14835
12953
|
require('./polyfill-done.js');
|
|
14836
12954
|
|
|
14837
|
-
},{"./lib/core.js":
|
|
12955
|
+
},{"./lib/core.js":101,"./lib/es6-extensions.js":102,"./polyfill-done.js":103,"asap":98}]},{},[2])(2)
|
|
14838
12956
|
});
|