Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50641 views
1
(function webpackUniversalModuleDefinition(root, factory) {
2
if(typeof exports === 'object' && typeof module === 'object')
3
module.exports = factory();
4
else if(typeof define === 'function' && define.amd)
5
define([], factory);
6
else if(typeof exports === 'object')
7
exports["expect"] = factory();
8
else
9
root["expect"] = factory();
10
})(this, function() {
11
return /******/ (function(modules) { // webpackBootstrap
12
/******/ // The module cache
13
/******/ var installedModules = {};
14
15
/******/ // The require function
16
/******/ function __webpack_require__(moduleId) {
17
18
/******/ // Check if module is in cache
19
/******/ if(installedModules[moduleId])
20
/******/ return installedModules[moduleId].exports;
21
22
/******/ // Create a new module (and put it into the cache)
23
/******/ var module = installedModules[moduleId] = {
24
/******/ exports: {},
25
/******/ id: moduleId,
26
/******/ loaded: false
27
/******/ };
28
29
/******/ // Execute the module function
30
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
32
/******/ // Flag the module as loaded
33
/******/ module.loaded = true;
34
35
/******/ // Return the exports of the module
36
/******/ return module.exports;
37
/******/ }
38
39
40
/******/ // expose the modules object (__webpack_modules__)
41
/******/ __webpack_require__.m = modules;
42
43
/******/ // expose the module cache
44
/******/ __webpack_require__.c = installedModules;
45
46
/******/ // __webpack_public_path__
47
/******/ __webpack_require__.p = "";
48
49
/******/ // Load entry module and return exports
50
/******/ return __webpack_require__(0);
51
/******/ })
52
/************************************************************************/
53
/******/ ([
54
/* 0 */
55
/***/ function(module, exports, __webpack_require__) {
56
57
'use strict';
58
59
var _Expectation = __webpack_require__(1);
60
61
var _Expectation2 = _interopRequireDefault(_Expectation);
62
63
var _SpyUtils = __webpack_require__(13);
64
65
var _assert = __webpack_require__(11);
66
67
var _assert2 = _interopRequireDefault(_assert);
68
69
var _extend = __webpack_require__(31);
70
71
var _extend2 = _interopRequireDefault(_extend);
72
73
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
74
75
function expect(actual) {
76
return new _Expectation2.default(actual);
77
}
78
79
expect.createSpy = _SpyUtils.createSpy;
80
expect.spyOn = _SpyUtils.spyOn;
81
expect.isSpy = _SpyUtils.isSpy;
82
expect.restoreSpies = _SpyUtils.restoreSpies;
83
expect.assert = _assert2.default;
84
expect.extend = _extend2.default;
85
86
module.exports = expect;
87
88
/***/ },
89
/* 1 */
90
/***/ function(module, exports, __webpack_require__) {
91
92
'use strict';
93
94
Object.defineProperty(exports, "__esModule", {
95
value: true
96
});
97
98
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
99
100
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
101
102
var _has = __webpack_require__(2);
103
104
var _has2 = _interopRequireDefault(_has);
105
106
var _tmatch = __webpack_require__(5);
107
108
var _tmatch2 = _interopRequireDefault(_tmatch);
109
110
var _assert = __webpack_require__(11);
111
112
var _assert2 = _interopRequireDefault(_assert);
113
114
var _SpyUtils = __webpack_require__(13);
115
116
var _TestUtils = __webpack_require__(18);
117
118
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
119
120
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
121
122
/**
123
* An Expectation is a wrapper around an assertion that allows it to be written
124
* in a more natural style, without the need to remember the order of arguments.
125
* This helps prevent you from making mistakes when writing tests.
126
*/
127
128
var Expectation = function () {
129
function Expectation(actual) {
130
_classCallCheck(this, Expectation);
131
132
this.actual = actual;
133
134
if ((0, _TestUtils.isFunction)(actual)) {
135
this.context = null;
136
this.args = [];
137
}
138
}
139
140
_createClass(Expectation, [{
141
key: 'toExist',
142
value: function toExist(message) {
143
(0, _assert2.default)(this.actual, message || 'Expected %s to exist', this.actual);
144
145
return this;
146
}
147
}, {
148
key: 'toNotExist',
149
value: function toNotExist(message) {
150
(0, _assert2.default)(!this.actual, message || 'Expected %s to not exist', this.actual);
151
152
return this;
153
}
154
}, {
155
key: 'toBe',
156
value: function toBe(value, message) {
157
(0, _assert2.default)(this.actual === value, message || 'Expected %s to be %s', this.actual, value);
158
159
return this;
160
}
161
}, {
162
key: 'toNotBe',
163
value: function toNotBe(value, message) {
164
(0, _assert2.default)(this.actual !== value, message || 'Expected %s to not be %s', this.actual, value);
165
166
return this;
167
}
168
}, {
169
key: 'toEqual',
170
value: function toEqual(value, message) {
171
try {
172
(0, _assert2.default)((0, _TestUtils.isEqual)(this.actual, value), message || 'Expected %s to equal %s', this.actual, value);
173
} catch (error) {
174
// These attributes are consumed by Mocha to produce a diff output.
175
error.actual = this.actual;
176
error.expected = value;
177
error.showDiff = true;
178
throw error;
179
}
180
181
return this;
182
}
183
}, {
184
key: 'toNotEqual',
185
value: function toNotEqual(value, message) {
186
(0, _assert2.default)(!(0, _TestUtils.isEqual)(this.actual, value), message || 'Expected %s to not equal %s', this.actual, value);
187
188
return this;
189
}
190
}, {
191
key: 'toThrow',
192
value: function toThrow(value, message) {
193
(0, _assert2.default)((0, _TestUtils.isFunction)(this.actual), 'The "actual" argument in expect(actual).toThrow() must be a function, %s was given', this.actual);
194
195
(0, _assert2.default)((0, _TestUtils.functionThrows)(this.actual, this.context, this.args, value), message || 'Expected %s to throw %s', this.actual, value || 'an error');
196
197
return this;
198
}
199
}, {
200
key: 'toNotThrow',
201
value: function toNotThrow(value, message) {
202
(0, _assert2.default)((0, _TestUtils.isFunction)(this.actual), 'The "actual" argument in expect(actual).toNotThrow() must be a function, %s was given', this.actual);
203
204
(0, _assert2.default)(!(0, _TestUtils.functionThrows)(this.actual, this.context, this.args, value), message || 'Expected %s to not throw %s', this.actual, value || 'an error');
205
206
return this;
207
}
208
}, {
209
key: 'toBeA',
210
value: function toBeA(value, message) {
211
(0, _assert2.default)((0, _TestUtils.isFunction)(value) || typeof value === 'string', 'The "value" argument in toBeA(value) must be a function or a string');
212
213
(0, _assert2.default)((0, _TestUtils.isA)(this.actual, value), message || 'Expected %s to be a %s', this.actual, value);
214
215
return this;
216
}
217
}, {
218
key: 'toNotBeA',
219
value: function toNotBeA(value, message) {
220
(0, _assert2.default)((0, _TestUtils.isFunction)(value) || typeof value === 'string', 'The "value" argument in toNotBeA(value) must be a function or a string');
221
222
(0, _assert2.default)(!(0, _TestUtils.isA)(this.actual, value), message || 'Expected %s to not be a %s', this.actual, value);
223
224
return this;
225
}
226
}, {
227
key: 'toMatch',
228
value: function toMatch(pattern, message) {
229
(0, _assert2.default)((0, _tmatch2.default)(this.actual, pattern), message || 'Expected %s to match %s', this.actual, pattern);
230
231
return this;
232
}
233
}, {
234
key: 'toNotMatch',
235
value: function toNotMatch(pattern, message) {
236
(0, _assert2.default)(!(0, _tmatch2.default)(this.actual, pattern), message || 'Expected %s to not match %s', this.actual, pattern);
237
238
return this;
239
}
240
}, {
241
key: 'toBeLessThan',
242
value: function toBeLessThan(value, message) {
243
(0, _assert2.default)(typeof this.actual === 'number', 'The "actual" argument in expect(actual).toBeLessThan() must be a number');
244
245
(0, _assert2.default)(typeof value === 'number', 'The "value" argument in toBeLessThan(value) must be a number');
246
247
(0, _assert2.default)(this.actual < value, message || 'Expected %s to be less than %s', this.actual, value);
248
249
return this;
250
}
251
}, {
252
key: 'toBeLessThanOrEqualTo',
253
value: function toBeLessThanOrEqualTo(value, message) {
254
(0, _assert2.default)(typeof this.actual === 'number', 'The "actual" argument in expect(actual).toBeLessThanOrEqualTo() must be a number');
255
256
(0, _assert2.default)(typeof value === 'number', 'The "value" argument in toBeLessThanOrEqualTo(value) must be a number');
257
258
(0, _assert2.default)(this.actual <= value, message || 'Expected %s to be less than or equal to %s', this.actual, value);
259
260
return this;
261
}
262
}, {
263
key: 'toBeGreaterThan',
264
value: function toBeGreaterThan(value, message) {
265
(0, _assert2.default)(typeof this.actual === 'number', 'The "actual" argument in expect(actual).toBeGreaterThan() must be a number');
266
267
(0, _assert2.default)(typeof value === 'number', 'The "value" argument in toBeGreaterThan(value) must be a number');
268
269
(0, _assert2.default)(this.actual > value, message || 'Expected %s to be greater than %s', this.actual, value);
270
271
return this;
272
}
273
}, {
274
key: 'toBeGreaterThanOrEqualTo',
275
value: function toBeGreaterThanOrEqualTo(value, message) {
276
(0, _assert2.default)(typeof this.actual === 'number', 'The "actual" argument in expect(actual).toBeGreaterThanOrEqualTo() must be a number');
277
278
(0, _assert2.default)(typeof value === 'number', 'The "value" argument in toBeGreaterThanOrEqualTo(value) must be a number');
279
280
(0, _assert2.default)(this.actual >= value, message || 'Expected %s to be greater than or equal to %s', this.actual, value);
281
282
return this;
283
}
284
}, {
285
key: 'toInclude',
286
value: function toInclude(value, compareValues, message) {
287
if (typeof compareValues === 'string') {
288
message = compareValues;
289
compareValues = null;
290
}
291
292
if (compareValues == null) compareValues = _TestUtils.isEqual;
293
294
var contains = false;
295
296
if ((0, _TestUtils.isArray)(this.actual)) {
297
contains = (0, _TestUtils.arrayContains)(this.actual, value, compareValues);
298
} else if ((0, _TestUtils.isObject)(this.actual)) {
299
contains = (0, _TestUtils.objectContains)(this.actual, value, compareValues);
300
} else if (typeof this.actual === 'string') {
301
contains = (0, _TestUtils.stringContains)(this.actual, value);
302
} else {
303
(0, _assert2.default)(false, 'The "actual" argument in expect(actual).toInclude() must be an array, object, or a string');
304
}
305
306
(0, _assert2.default)(contains, message || 'Expected %s to include %s', this.actual, value);
307
308
return this;
309
}
310
}, {
311
key: 'toExclude',
312
value: function toExclude(value, compareValues, message) {
313
if (typeof compareValues === 'string') {
314
message = compareValues;
315
compareValues = null;
316
}
317
318
if (compareValues == null) compareValues = _TestUtils.isEqual;
319
320
var contains = false;
321
322
if ((0, _TestUtils.isArray)(this.actual)) {
323
contains = (0, _TestUtils.arrayContains)(this.actual, value, compareValues);
324
} else if ((0, _TestUtils.isObject)(this.actual)) {
325
contains = (0, _TestUtils.objectContains)(this.actual, value, compareValues);
326
} else if (typeof this.actual === 'string') {
327
contains = (0, _TestUtils.stringContains)(this.actual, value);
328
} else {
329
(0, _assert2.default)(false, 'The "actual" argument in expect(actual).toExclude() must be an array, object, or a string');
330
}
331
332
(0, _assert2.default)(!contains, message || 'Expected %s to exclude %s', this.actual, value);
333
334
return this;
335
}
336
}, {
337
key: 'toIncludeKeys',
338
value: function toIncludeKeys(keys, comparator, message) {
339
var _this = this;
340
341
if (typeof comparator === 'string') {
342
message = comparator;
343
comparator = null;
344
}
345
346
if (comparator == null) comparator = _has2.default;
347
348
(0, _assert2.default)(_typeof(this.actual) === 'object', 'The "actual" argument in expect(actual).toIncludeKeys() must be an object, not %s', this.actual);
349
350
(0, _assert2.default)((0, _TestUtils.isArray)(keys), 'The "keys" argument in expect(actual).toIncludeKeys(keys) must be an array, not %s', keys);
351
352
var contains = keys.every(function (key) {
353
return comparator(_this.actual, key);
354
});
355
356
(0, _assert2.default)(contains, message || 'Expected %s to include key(s) %s', this.actual, keys.join(', '));
357
358
return this;
359
}
360
}, {
361
key: 'toIncludeKey',
362
value: function toIncludeKey(key) {
363
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
364
args[_key - 1] = arguments[_key];
365
}
366
367
return this.toIncludeKeys.apply(this, [[key]].concat(args));
368
}
369
}, {
370
key: 'toExcludeKeys',
371
value: function toExcludeKeys(keys, comparator, message) {
372
var _this2 = this;
373
374
if (typeof comparator === 'string') {
375
message = comparator;
376
comparator = null;
377
}
378
379
if (comparator == null) comparator = _has2.default;
380
381
(0, _assert2.default)(_typeof(this.actual) === 'object', 'The "actual" argument in expect(actual).toExcludeKeys() must be an object, not %s', this.actual);
382
383
(0, _assert2.default)((0, _TestUtils.isArray)(keys), 'The "keys" argument in expect(actual).toIncludeKeys(keys) must be an array, not %s', keys);
384
385
var contains = keys.every(function (key) {
386
return comparator(_this2.actual, key);
387
});
388
389
(0, _assert2.default)(!contains, message || 'Expected %s to exclude key(s) %s', this.actual, keys.join(', '));
390
391
return this;
392
}
393
}, {
394
key: 'toExcludeKey',
395
value: function toExcludeKey(key) {
396
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
397
args[_key2 - 1] = arguments[_key2];
398
}
399
400
return this.toExcludeKeys.apply(this, [[key]].concat(args));
401
}
402
}, {
403
key: 'toHaveBeenCalled',
404
value: function toHaveBeenCalled(message) {
405
var spy = this.actual;
406
407
(0, _assert2.default)((0, _SpyUtils.isSpy)(spy), 'The "actual" argument in expect(actual).toHaveBeenCalled() must be a spy');
408
409
(0, _assert2.default)(spy.calls.length > 0, message || 'spy was not called');
410
411
return this;
412
}
413
}, {
414
key: 'toHaveBeenCalledWith',
415
value: function toHaveBeenCalledWith() {
416
for (var _len3 = arguments.length, expectedArgs = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
417
expectedArgs[_key3] = arguments[_key3];
418
}
419
420
var spy = this.actual;
421
422
(0, _assert2.default)((0, _SpyUtils.isSpy)(spy), 'The "actual" argument in expect(actual).toHaveBeenCalledWith() must be a spy');
423
424
(0, _assert2.default)(spy.calls.some(function (call) {
425
return (0, _TestUtils.isEqual)(call.arguments, expectedArgs);
426
}), 'spy was never called with %s', expectedArgs);
427
428
return this;
429
}
430
}, {
431
key: 'toNotHaveBeenCalled',
432
value: function toNotHaveBeenCalled(message) {
433
var spy = this.actual;
434
435
(0, _assert2.default)((0, _SpyUtils.isSpy)(spy), 'The "actual" argument in expect(actual).toNotHaveBeenCalled() must be a spy');
436
437
(0, _assert2.default)(spy.calls.length === 0, message || 'spy was not supposed to be called');
438
439
return this;
440
}
441
}]);
442
443
return Expectation;
444
}();
445
446
var deprecate = function deprecate(fn, message) {
447
var alreadyWarned = false;
448
449
return function () {
450
if (!alreadyWarned) {
451
alreadyWarned = true;
452
console.warn(message);
453
}
454
455
for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
456
args[_key4] = arguments[_key4];
457
}
458
459
return fn.apply(this, args);
460
};
461
};
462
463
Expectation.prototype.withContext = deprecate(function (context) {
464
(0, _assert2.default)((0, _TestUtils.isFunction)(this.actual), 'The "actual" argument in expect(actual).withContext() must be a function');
465
466
this.context = context;
467
468
return this;
469
}, '\nwithContext is deprecated; use a closure instead.\n\n expect(fn).withContext(context).toThrow()\n\nbecomes\n\n expect(() => fn.call(context)).toThrow()\n');
470
471
Expectation.prototype.withArgs = deprecate(function () {
472
var _args;
473
474
(0, _assert2.default)((0, _TestUtils.isFunction)(this.actual), 'The "actual" argument in expect(actual).withArgs() must be a function');
475
476
if (arguments.length) this.args = (_args = this.args).concat.apply(_args, arguments);
477
478
return this;
479
}, '\nwithArgs is deprecated; use a closure instead.\n\n expect(fn).withArgs(a, b, c).toThrow()\n\nbecomes\n\n expect(() => fn(a, b, c)).toThrow()\n');
480
481
var aliases = {
482
toBeAn: 'toBeA',
483
toNotBeAn: 'toNotBeA',
484
toBeTruthy: 'toExist',
485
toBeFalsy: 'toNotExist',
486
toBeFewerThan: 'toBeLessThan',
487
toBeMoreThan: 'toBeGreaterThan',
488
toContain: 'toInclude',
489
toNotContain: 'toExclude',
490
toNotInclude: 'toExclude',
491
toContainKeys: 'toIncludeKeys',
492
toNotContainKeys: 'toExcludeKeys',
493
toNotIncludeKeys: 'toExcludeKeys',
494
toContainKey: 'toIncludeKey',
495
toNotContainKey: 'toExcludeKey',
496
toNotIncludeKey: 'toExcludeKey'
497
};
498
499
for (var alias in aliases) {
500
if (aliases.hasOwnProperty(alias)) Expectation.prototype[alias] = Expectation.prototype[aliases[alias]];
501
}exports.default = Expectation;
502
503
/***/ },
504
/* 2 */
505
/***/ function(module, exports, __webpack_require__) {
506
507
var bind = __webpack_require__(3);
508
509
module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
510
511
512
/***/ },
513
/* 3 */
514
/***/ function(module, exports, __webpack_require__) {
515
516
var implementation = __webpack_require__(4);
517
518
module.exports = Function.prototype.bind || implementation;
519
520
521
/***/ },
522
/* 4 */
523
/***/ function(module, exports) {
524
525
var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
526
var slice = Array.prototype.slice;
527
var toStr = Object.prototype.toString;
528
var funcType = '[object Function]';
529
530
module.exports = function bind(that) {
531
var target = this;
532
if (typeof target !== 'function' || toStr.call(target) !== funcType) {
533
throw new TypeError(ERROR_MESSAGE + target);
534
}
535
var args = slice.call(arguments, 1);
536
537
var bound;
538
var binder = function () {
539
if (this instanceof bound) {
540
var result = target.apply(
541
this,
542
args.concat(slice.call(arguments))
543
);
544
if (Object(result) === result) {
545
return result;
546
}
547
return this;
548
} else {
549
return target.apply(
550
that,
551
args.concat(slice.call(arguments))
552
);
553
}
554
};
555
556
var boundLength = Math.max(0, target.length - args.length);
557
var boundArgs = [];
558
for (var i = 0; i < boundLength; i++) {
559
boundArgs.push('$' + i);
560
}
561
562
bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
563
564
if (target.prototype) {
565
var Empty = function Empty() {};
566
Empty.prototype = target.prototype;
567
bound.prototype = new Empty();
568
Empty.prototype = null;
569
}
570
571
return bound;
572
};
573
574
575
/***/ },
576
/* 5 */
577
/***/ function(module, exports, __webpack_require__) {
578
579
/* WEBPACK VAR INJECTION */(function(process, Buffer) {'use strict'
580
581
function isArguments (obj) {
582
return Object.prototype.toString.call(obj) === '[object Arguments]'
583
}
584
585
module.exports = match
586
587
function match (obj, pattern) {
588
return match_(obj, pattern, [], [])
589
}
590
591
/* istanbul ignore next */
592
var log = (/\btmatch\b/.test(process.env.NODE_DEBUG || '')) ?
593
console.error : function () {}
594
595
function match_ (obj, pattern, ca, cb) {
596
log('TMATCH', typeof obj, pattern)
597
if (obj == pattern) {
598
log('TMATCH same object or simple value, or problem')
599
// if one is object, and the other isn't, then this is bogus
600
if (obj === null || pattern === null) {
601
return true
602
603
} else if (typeof obj === 'object' && typeof pattern === 'object') {
604
return true
605
606
} else if (typeof obj === 'object' && typeof pattern !== 'object') {
607
return false
608
609
} else if (typeof obj !== 'object' && typeof pattern === 'object') {
610
return false
611
612
} else {
613
return true
614
}
615
616
} else if (obj === null || pattern === null) {
617
log('TMATCH null test, already failed ==')
618
return false
619
620
} else if (typeof obj === 'string' && pattern instanceof RegExp) {
621
log('TMATCH string~=regexp test')
622
return pattern.test(obj)
623
624
} else if (typeof obj === 'string' && typeof pattern === 'string' && pattern) {
625
log('TMATCH string~=string test')
626
return obj.indexOf(pattern) !== -1
627
628
} else if (obj instanceof Date && pattern instanceof Date) {
629
log('TMATCH date test')
630
return obj.getTime() === pattern.getTime()
631
632
} else if (obj instanceof Date && typeof pattern === 'string') {
633
log('TMATCH date~=string test')
634
return obj.getTime() === new Date(pattern).getTime()
635
636
} else if (isArguments(obj) || isArguments(pattern)) {
637
log('TMATCH arguments test')
638
var slice = Array.prototype.slice
639
return match_(slice.call(obj), slice.call(pattern), ca, cb)
640
641
} else if (pattern === Buffer) {
642
log('TMATCH Buffer ctor')
643
return Buffer.isBuffer(obj)
644
645
} else if (pattern === Function) {
646
log('TMATCH Function ctor')
647
return typeof obj === 'function'
648
649
} else if (pattern === Number) {
650
log('TMATCH Number ctor (finite, not NaN)')
651
return typeof obj === 'number' && obj === obj && isFinite(obj)
652
653
} else if (pattern !== pattern) {
654
log('TMATCH NaN')
655
return obj !== obj
656
657
} else if (pattern === String) {
658
log('TMATCH String ctor')
659
return typeof obj === 'string'
660
661
} else if (pattern === Boolean) {
662
log('TMATCH Boolean ctor')
663
return typeof obj === 'boolean'
664
665
} else if (pattern === Array) {
666
log('TMATCH Array ctor', pattern, Array.isArray(obj))
667
return Array.isArray(obj)
668
669
} else if (typeof pattern === 'function' && typeof obj === 'object') {
670
log('TMATCH object~=function')
671
return obj instanceof pattern
672
673
} else if (typeof obj !== 'object' || typeof pattern !== 'object') {
674
log('TMATCH obj is not object, pattern is not object, false')
675
return false
676
677
} else if (obj instanceof RegExp && pattern instanceof RegExp) {
678
log('TMATCH regexp~=regexp test')
679
return obj.source === pattern.source &&
680
obj.global === pattern.global &&
681
obj.multiline === pattern.multiline &&
682
obj.lastIndex === pattern.lastIndex &&
683
obj.ignoreCase === pattern.ignoreCase
684
685
} else if (Buffer.isBuffer(obj) && Buffer.isBuffer(pattern)) {
686
log('TMATCH buffer test')
687
if (obj.equals) {
688
return obj.equals(pattern)
689
} else {
690
if (obj.length !== pattern.length) return false
691
692
for (var j = 0; j < obj.length; j++) if (obj[j] != pattern[j]) return false
693
694
return true
695
}
696
697
} else {
698
// both are objects. interesting case!
699
log('TMATCH object~=object test')
700
var kobj = Object.keys(obj)
701
var kpat = Object.keys(pattern)
702
log(' TMATCH patternkeys=%j objkeys=%j', kpat, kobj)
703
704
// don't bother with stack acrobatics if there's nothing there
705
if (kobj.length === 0 && kpat.length === 0) return true
706
707
// if we've seen this exact pattern and object already, then
708
// it means that pattern and obj have matching cyclicalness
709
// however, non-cyclical patterns can match cyclical objects
710
log(' TMATCH check seen objects...')
711
var cal = ca.length
712
while (cal--) if (ca[cal] === obj && cb[cal] === pattern) return true
713
ca.push(obj); cb.push(pattern)
714
log(' TMATCH not seen previously')
715
716
var key
717
for (var l = kpat.length - 1; l >= 0; l--) {
718
key = kpat[l]
719
log(' TMATCH test obj[%j]', key, obj[key], pattern[key])
720
if (!match_(obj[key], pattern[key], ca, cb)) return false
721
}
722
723
ca.pop()
724
cb.pop()
725
726
log(' TMATCH object pass')
727
return true
728
}
729
730
/* istanbul ignore next */
731
throw new Error('impossible to reach this point')
732
}
733
734
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6), __webpack_require__(7).Buffer))
735
736
/***/ },
737
/* 6 */
738
/***/ function(module, exports) {
739
740
// shim for using process in browser
741
742
var process = module.exports = {};
743
var queue = [];
744
var draining = false;
745
var currentQueue;
746
var queueIndex = -1;
747
748
function cleanUpNextTick() {
749
if (!draining || !currentQueue) {
750
return;
751
}
752
draining = false;
753
if (currentQueue.length) {
754
queue = currentQueue.concat(queue);
755
} else {
756
queueIndex = -1;
757
}
758
if (queue.length) {
759
drainQueue();
760
}
761
}
762
763
function drainQueue() {
764
if (draining) {
765
return;
766
}
767
var timeout = setTimeout(cleanUpNextTick);
768
draining = true;
769
770
var len = queue.length;
771
while(len) {
772
currentQueue = queue;
773
queue = [];
774
while (++queueIndex < len) {
775
if (currentQueue) {
776
currentQueue[queueIndex].run();
777
}
778
}
779
queueIndex = -1;
780
len = queue.length;
781
}
782
currentQueue = null;
783
draining = false;
784
clearTimeout(timeout);
785
}
786
787
process.nextTick = function (fun) {
788
var args = new Array(arguments.length - 1);
789
if (arguments.length > 1) {
790
for (var i = 1; i < arguments.length; i++) {
791
args[i - 1] = arguments[i];
792
}
793
}
794
queue.push(new Item(fun, args));
795
if (queue.length === 1 && !draining) {
796
setTimeout(drainQueue, 0);
797
}
798
};
799
800
// v8 likes predictible objects
801
function Item(fun, array) {
802
this.fun = fun;
803
this.array = array;
804
}
805
Item.prototype.run = function () {
806
this.fun.apply(null, this.array);
807
};
808
process.title = 'browser';
809
process.browser = true;
810
process.env = {};
811
process.argv = [];
812
process.version = ''; // empty string to avoid regexp issues
813
process.versions = {};
814
815
function noop() {}
816
817
process.on = noop;
818
process.addListener = noop;
819
process.once = noop;
820
process.off = noop;
821
process.removeListener = noop;
822
process.removeAllListeners = noop;
823
process.emit = noop;
824
825
process.binding = function (name) {
826
throw new Error('process.binding is not supported');
827
};
828
829
process.cwd = function () { return '/' };
830
process.chdir = function (dir) {
831
throw new Error('process.chdir is not supported');
832
};
833
process.umask = function() { return 0; };
834
835
836
/***/ },
837
/* 7 */
838
/***/ function(module, exports, __webpack_require__) {
839
840
/* WEBPACK VAR INJECTION */(function(Buffer, global) {/*!
841
* The buffer module from node.js, for the browser.
842
*
843
* @author Feross Aboukhadijeh <[email protected]> <http://feross.org>
844
* @license MIT
845
*/
846
/* eslint-disable no-proto */
847
848
'use strict'
849
850
var base64 = __webpack_require__(8)
851
var ieee754 = __webpack_require__(9)
852
var isArray = __webpack_require__(10)
853
854
exports.Buffer = Buffer
855
exports.SlowBuffer = SlowBuffer
856
exports.INSPECT_MAX_BYTES = 50
857
Buffer.poolSize = 8192 // not used by this implementation
858
859
var rootParent = {}
860
861
/**
862
* If `Buffer.TYPED_ARRAY_SUPPORT`:
863
* === true Use Uint8Array implementation (fastest)
864
* === false Use Object implementation (most compatible, even IE6)
865
*
866
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
867
* Opera 11.6+, iOS 4.2+.
868
*
869
* Due to various browser bugs, sometimes the Object implementation will be used even
870
* when the browser supports typed arrays.
871
*
872
* Note:
873
*
874
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
875
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
876
*
877
* - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property
878
* on objects.
879
*
880
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
881
*
882
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
883
* incorrect length in some situations.
884
885
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
886
* get the Object implementation, which is slower but behaves correctly.
887
*/
888
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
889
? global.TYPED_ARRAY_SUPPORT
890
: typedArraySupport()
891
892
function typedArraySupport () {
893
function Bar () {}
894
try {
895
var arr = new Uint8Array(1)
896
arr.foo = function () { return 42 }
897
arr.constructor = Bar
898
return arr.foo() === 42 && // typed array instances can be augmented
899
arr.constructor === Bar && // constructor can be set
900
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
901
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
902
} catch (e) {
903
return false
904
}
905
}
906
907
function kMaxLength () {
908
return Buffer.TYPED_ARRAY_SUPPORT
909
? 0x7fffffff
910
: 0x3fffffff
911
}
912
913
/**
914
* Class: Buffer
915
* =============
916
*
917
* The Buffer constructor returns instances of `Uint8Array` that are augmented
918
* with function properties for all the node `Buffer` API functions. We use
919
* `Uint8Array` so that square bracket notation works as expected -- it returns
920
* a single octet.
921
*
922
* By augmenting the instances, we can avoid modifying the `Uint8Array`
923
* prototype.
924
*/
925
function Buffer (arg) {
926
if (!(this instanceof Buffer)) {
927
// Avoid going through an ArgumentsAdaptorTrampoline in the common case.
928
if (arguments.length > 1) return new Buffer(arg, arguments[1])
929
return new Buffer(arg)
930
}
931
932
if (!Buffer.TYPED_ARRAY_SUPPORT) {
933
this.length = 0
934
this.parent = undefined
935
}
936
937
// Common case.
938
if (typeof arg === 'number') {
939
return fromNumber(this, arg)
940
}
941
942
// Slightly less common case.
943
if (typeof arg === 'string') {
944
return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8')
945
}
946
947
// Unusual.
948
return fromObject(this, arg)
949
}
950
951
function fromNumber (that, length) {
952
that = allocate(that, length < 0 ? 0 : checked(length) | 0)
953
if (!Buffer.TYPED_ARRAY_SUPPORT) {
954
for (var i = 0; i < length; i++) {
955
that[i] = 0
956
}
957
}
958
return that
959
}
960
961
function fromString (that, string, encoding) {
962
if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8'
963
964
// Assumption: byteLength() return value is always < kMaxLength.
965
var length = byteLength(string, encoding) | 0
966
that = allocate(that, length)
967
968
that.write(string, encoding)
969
return that
970
}
971
972
function fromObject (that, object) {
973
if (Buffer.isBuffer(object)) return fromBuffer(that, object)
974
975
if (isArray(object)) return fromArray(that, object)
976
977
if (object == null) {
978
throw new TypeError('must start with number, buffer, array or string')
979
}
980
981
if (typeof ArrayBuffer !== 'undefined') {
982
if (object.buffer instanceof ArrayBuffer) {
983
return fromTypedArray(that, object)
984
}
985
if (object instanceof ArrayBuffer) {
986
return fromArrayBuffer(that, object)
987
}
988
}
989
990
if (object.length) return fromArrayLike(that, object)
991
992
return fromJsonObject(that, object)
993
}
994
995
function fromBuffer (that, buffer) {
996
var length = checked(buffer.length) | 0
997
that = allocate(that, length)
998
buffer.copy(that, 0, 0, length)
999
return that
1000
}
1001
1002
function fromArray (that, array) {
1003
var length = checked(array.length) | 0
1004
that = allocate(that, length)
1005
for (var i = 0; i < length; i += 1) {
1006
that[i] = array[i] & 255
1007
}
1008
return that
1009
}
1010
1011
// Duplicate of fromArray() to keep fromArray() monomorphic.
1012
function fromTypedArray (that, array) {
1013
var length = checked(array.length) | 0
1014
that = allocate(that, length)
1015
// Truncating the elements is probably not what people expect from typed
1016
// arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior
1017
// of the old Buffer constructor.
1018
for (var i = 0; i < length; i += 1) {
1019
that[i] = array[i] & 255
1020
}
1021
return that
1022
}
1023
1024
function fromArrayBuffer (that, array) {
1025
if (Buffer.TYPED_ARRAY_SUPPORT) {
1026
// Return an augmented `Uint8Array` instance, for best performance
1027
array.byteLength
1028
that = Buffer._augment(new Uint8Array(array))
1029
} else {
1030
// Fallback: Return an object instance of the Buffer class
1031
that = fromTypedArray(that, new Uint8Array(array))
1032
}
1033
return that
1034
}
1035
1036
function fromArrayLike (that, array) {
1037
var length = checked(array.length) | 0
1038
that = allocate(that, length)
1039
for (var i = 0; i < length; i += 1) {
1040
that[i] = array[i] & 255
1041
}
1042
return that
1043
}
1044
1045
// Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object.
1046
// Returns a zero-length buffer for inputs that don't conform to the spec.
1047
function fromJsonObject (that, object) {
1048
var array
1049
var length = 0
1050
1051
if (object.type === 'Buffer' && isArray(object.data)) {
1052
array = object.data
1053
length = checked(array.length) | 0
1054
}
1055
that = allocate(that, length)
1056
1057
for (var i = 0; i < length; i += 1) {
1058
that[i] = array[i] & 255
1059
}
1060
return that
1061
}
1062
1063
if (Buffer.TYPED_ARRAY_SUPPORT) {
1064
Buffer.prototype.__proto__ = Uint8Array.prototype
1065
Buffer.__proto__ = Uint8Array
1066
} else {
1067
// pre-set for values that may exist in the future
1068
Buffer.prototype.length = undefined
1069
Buffer.prototype.parent = undefined
1070
}
1071
1072
function allocate (that, length) {
1073
if (Buffer.TYPED_ARRAY_SUPPORT) {
1074
// Return an augmented `Uint8Array` instance, for best performance
1075
that = Buffer._augment(new Uint8Array(length))
1076
that.__proto__ = Buffer.prototype
1077
} else {
1078
// Fallback: Return an object instance of the Buffer class
1079
that.length = length
1080
that._isBuffer = true
1081
}
1082
1083
var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1
1084
if (fromPool) that.parent = rootParent
1085
1086
return that
1087
}
1088
1089
function checked (length) {
1090
// Note: cannot use `length < kMaxLength` here because that fails when
1091
// length is NaN (which is otherwise coerced to zero.)
1092
if (length >= kMaxLength()) {
1093
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
1094
'size: 0x' + kMaxLength().toString(16) + ' bytes')
1095
}
1096
return length | 0
1097
}
1098
1099
function SlowBuffer (subject, encoding) {
1100
if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
1101
1102
var buf = new Buffer(subject, encoding)
1103
delete buf.parent
1104
return buf
1105
}
1106
1107
Buffer.isBuffer = function isBuffer (b) {
1108
return !!(b != null && b._isBuffer)
1109
}
1110
1111
Buffer.compare = function compare (a, b) {
1112
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
1113
throw new TypeError('Arguments must be Buffers')
1114
}
1115
1116
if (a === b) return 0
1117
1118
var x = a.length
1119
var y = b.length
1120
1121
var i = 0
1122
var len = Math.min(x, y)
1123
while (i < len) {
1124
if (a[i] !== b[i]) break
1125
1126
++i
1127
}
1128
1129
if (i !== len) {
1130
x = a[i]
1131
y = b[i]
1132
}
1133
1134
if (x < y) return -1
1135
if (y < x) return 1
1136
return 0
1137
}
1138
1139
Buffer.isEncoding = function isEncoding (encoding) {
1140
switch (String(encoding).toLowerCase()) {
1141
case 'hex':
1142
case 'utf8':
1143
case 'utf-8':
1144
case 'ascii':
1145
case 'binary':
1146
case 'base64':
1147
case 'raw':
1148
case 'ucs2':
1149
case 'ucs-2':
1150
case 'utf16le':
1151
case 'utf-16le':
1152
return true
1153
default:
1154
return false
1155
}
1156
}
1157
1158
Buffer.concat = function concat (list, length) {
1159
if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
1160
1161
if (list.length === 0) {
1162
return new Buffer(0)
1163
}
1164
1165
var i
1166
if (length === undefined) {
1167
length = 0
1168
for (i = 0; i < list.length; i++) {
1169
length += list[i].length
1170
}
1171
}
1172
1173
var buf = new Buffer(length)
1174
var pos = 0
1175
for (i = 0; i < list.length; i++) {
1176
var item = list[i]
1177
item.copy(buf, pos)
1178
pos += item.length
1179
}
1180
return buf
1181
}
1182
1183
function byteLength (string, encoding) {
1184
if (typeof string !== 'string') string = '' + string
1185
1186
var len = string.length
1187
if (len === 0) return 0
1188
1189
// Use a for loop to avoid recursion
1190
var loweredCase = false
1191
for (;;) {
1192
switch (encoding) {
1193
case 'ascii':
1194
case 'binary':
1195
// Deprecated
1196
case 'raw':
1197
case 'raws':
1198
return len
1199
case 'utf8':
1200
case 'utf-8':
1201
return utf8ToBytes(string).length
1202
case 'ucs2':
1203
case 'ucs-2':
1204
case 'utf16le':
1205
case 'utf-16le':
1206
return len * 2
1207
case 'hex':
1208
return len >>> 1
1209
case 'base64':
1210
return base64ToBytes(string).length
1211
default:
1212
if (loweredCase) return utf8ToBytes(string).length // assume utf8
1213
encoding = ('' + encoding).toLowerCase()
1214
loweredCase = true
1215
}
1216
}
1217
}
1218
Buffer.byteLength = byteLength
1219
1220
function slowToString (encoding, start, end) {
1221
var loweredCase = false
1222
1223
start = start | 0
1224
end = end === undefined || end === Infinity ? this.length : end | 0
1225
1226
if (!encoding) encoding = 'utf8'
1227
if (start < 0) start = 0
1228
if (end > this.length) end = this.length
1229
if (end <= start) return ''
1230
1231
while (true) {
1232
switch (encoding) {
1233
case 'hex':
1234
return hexSlice(this, start, end)
1235
1236
case 'utf8':
1237
case 'utf-8':
1238
return utf8Slice(this, start, end)
1239
1240
case 'ascii':
1241
return asciiSlice(this, start, end)
1242
1243
case 'binary':
1244
return binarySlice(this, start, end)
1245
1246
case 'base64':
1247
return base64Slice(this, start, end)
1248
1249
case 'ucs2':
1250
case 'ucs-2':
1251
case 'utf16le':
1252
case 'utf-16le':
1253
return utf16leSlice(this, start, end)
1254
1255
default:
1256
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1257
encoding = (encoding + '').toLowerCase()
1258
loweredCase = true
1259
}
1260
}
1261
}
1262
1263
Buffer.prototype.toString = function toString () {
1264
var length = this.length | 0
1265
if (length === 0) return ''
1266
if (arguments.length === 0) return utf8Slice(this, 0, length)
1267
return slowToString.apply(this, arguments)
1268
}
1269
1270
Buffer.prototype.equals = function equals (b) {
1271
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
1272
if (this === b) return true
1273
return Buffer.compare(this, b) === 0
1274
}
1275
1276
Buffer.prototype.inspect = function inspect () {
1277
var str = ''
1278
var max = exports.INSPECT_MAX_BYTES
1279
if (this.length > 0) {
1280
str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
1281
if (this.length > max) str += ' ... '
1282
}
1283
return '<Buffer ' + str + '>'
1284
}
1285
1286
Buffer.prototype.compare = function compare (b) {
1287
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
1288
if (this === b) return 0
1289
return Buffer.compare(this, b)
1290
}
1291
1292
Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
1293
if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
1294
else if (byteOffset < -0x80000000) byteOffset = -0x80000000
1295
byteOffset >>= 0
1296
1297
if (this.length === 0) return -1
1298
if (byteOffset >= this.length) return -1
1299
1300
// Negative offsets start from the end of the buffer
1301
if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
1302
1303
if (typeof val === 'string') {
1304
if (val.length === 0) return -1 // special case: looking for empty string always fails
1305
return String.prototype.indexOf.call(this, val, byteOffset)
1306
}
1307
if (Buffer.isBuffer(val)) {
1308
return arrayIndexOf(this, val, byteOffset)
1309
}
1310
if (typeof val === 'number') {
1311
if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
1312
return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
1313
}
1314
return arrayIndexOf(this, [ val ], byteOffset)
1315
}
1316
1317
function arrayIndexOf (arr, val, byteOffset) {
1318
var foundIndex = -1
1319
for (var i = 0; byteOffset + i < arr.length; i++) {
1320
if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
1321
if (foundIndex === -1) foundIndex = i
1322
if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
1323
} else {
1324
foundIndex = -1
1325
}
1326
}
1327
return -1
1328
}
1329
1330
throw new TypeError('val must be string, number or Buffer')
1331
}
1332
1333
// `get` is deprecated
1334
Buffer.prototype.get = function get (offset) {
1335
console.log('.get() is deprecated. Access using array indexes instead.')
1336
return this.readUInt8(offset)
1337
}
1338
1339
// `set` is deprecated
1340
Buffer.prototype.set = function set (v, offset) {
1341
console.log('.set() is deprecated. Access using array indexes instead.')
1342
return this.writeUInt8(v, offset)
1343
}
1344
1345
function hexWrite (buf, string, offset, length) {
1346
offset = Number(offset) || 0
1347
var remaining = buf.length - offset
1348
if (!length) {
1349
length = remaining
1350
} else {
1351
length = Number(length)
1352
if (length > remaining) {
1353
length = remaining
1354
}
1355
}
1356
1357
// must be an even number of digits
1358
var strLen = string.length
1359
if (strLen % 2 !== 0) throw new Error('Invalid hex string')
1360
1361
if (length > strLen / 2) {
1362
length = strLen / 2
1363
}
1364
for (var i = 0; i < length; i++) {
1365
var parsed = parseInt(string.substr(i * 2, 2), 16)
1366
if (isNaN(parsed)) throw new Error('Invalid hex string')
1367
buf[offset + i] = parsed
1368
}
1369
return i
1370
}
1371
1372
function utf8Write (buf, string, offset, length) {
1373
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
1374
}
1375
1376
function asciiWrite (buf, string, offset, length) {
1377
return blitBuffer(asciiToBytes(string), buf, offset, length)
1378
}
1379
1380
function binaryWrite (buf, string, offset, length) {
1381
return asciiWrite(buf, string, offset, length)
1382
}
1383
1384
function base64Write (buf, string, offset, length) {
1385
return blitBuffer(base64ToBytes(string), buf, offset, length)
1386
}
1387
1388
function ucs2Write (buf, string, offset, length) {
1389
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
1390
}
1391
1392
Buffer.prototype.write = function write (string, offset, length, encoding) {
1393
// Buffer#write(string)
1394
if (offset === undefined) {
1395
encoding = 'utf8'
1396
length = this.length
1397
offset = 0
1398
// Buffer#write(string, encoding)
1399
} else if (length === undefined && typeof offset === 'string') {
1400
encoding = offset
1401
length = this.length
1402
offset = 0
1403
// Buffer#write(string, offset[, length][, encoding])
1404
} else if (isFinite(offset)) {
1405
offset = offset | 0
1406
if (isFinite(length)) {
1407
length = length | 0
1408
if (encoding === undefined) encoding = 'utf8'
1409
} else {
1410
encoding = length
1411
length = undefined
1412
}
1413
// legacy write(string, encoding, offset, length) - remove in v0.13
1414
} else {
1415
var swap = encoding
1416
encoding = offset
1417
offset = length | 0
1418
length = swap
1419
}
1420
1421
var remaining = this.length - offset
1422
if (length === undefined || length > remaining) length = remaining
1423
1424
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1425
throw new RangeError('attempt to write outside buffer bounds')
1426
}
1427
1428
if (!encoding) encoding = 'utf8'
1429
1430
var loweredCase = false
1431
for (;;) {
1432
switch (encoding) {
1433
case 'hex':
1434
return hexWrite(this, string, offset, length)
1435
1436
case 'utf8':
1437
case 'utf-8':
1438
return utf8Write(this, string, offset, length)
1439
1440
case 'ascii':
1441
return asciiWrite(this, string, offset, length)
1442
1443
case 'binary':
1444
return binaryWrite(this, string, offset, length)
1445
1446
case 'base64':
1447
// Warning: maxLength not taken into account in base64Write
1448
return base64Write(this, string, offset, length)
1449
1450
case 'ucs2':
1451
case 'ucs-2':
1452
case 'utf16le':
1453
case 'utf-16le':
1454
return ucs2Write(this, string, offset, length)
1455
1456
default:
1457
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1458
encoding = ('' + encoding).toLowerCase()
1459
loweredCase = true
1460
}
1461
}
1462
}
1463
1464
Buffer.prototype.toJSON = function toJSON () {
1465
return {
1466
type: 'Buffer',
1467
data: Array.prototype.slice.call(this._arr || this, 0)
1468
}
1469
}
1470
1471
function base64Slice (buf, start, end) {
1472
if (start === 0 && end === buf.length) {
1473
return base64.fromByteArray(buf)
1474
} else {
1475
return base64.fromByteArray(buf.slice(start, end))
1476
}
1477
}
1478
1479
function utf8Slice (buf, start, end) {
1480
end = Math.min(buf.length, end)
1481
var res = []
1482
1483
var i = start
1484
while (i < end) {
1485
var firstByte = buf[i]
1486
var codePoint = null
1487
var bytesPerSequence = (firstByte > 0xEF) ? 4
1488
: (firstByte > 0xDF) ? 3
1489
: (firstByte > 0xBF) ? 2
1490
: 1
1491
1492
if (i + bytesPerSequence <= end) {
1493
var secondByte, thirdByte, fourthByte, tempCodePoint
1494
1495
switch (bytesPerSequence) {
1496
case 1:
1497
if (firstByte < 0x80) {
1498
codePoint = firstByte
1499
}
1500
break
1501
case 2:
1502
secondByte = buf[i + 1]
1503
if ((secondByte & 0xC0) === 0x80) {
1504
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
1505
if (tempCodePoint > 0x7F) {
1506
codePoint = tempCodePoint
1507
}
1508
}
1509
break
1510
case 3:
1511
secondByte = buf[i + 1]
1512
thirdByte = buf[i + 2]
1513
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1514
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
1515
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1516
codePoint = tempCodePoint
1517
}
1518
}
1519
break
1520
case 4:
1521
secondByte = buf[i + 1]
1522
thirdByte = buf[i + 2]
1523
fourthByte = buf[i + 3]
1524
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1525
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
1526
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1527
codePoint = tempCodePoint
1528
}
1529
}
1530
}
1531
}
1532
1533
if (codePoint === null) {
1534
// we did not generate a valid codePoint so insert a
1535
// replacement char (U+FFFD) and advance only 1 byte
1536
codePoint = 0xFFFD
1537
bytesPerSequence = 1
1538
} else if (codePoint > 0xFFFF) {
1539
// encode to utf16 (surrogate pair dance)
1540
codePoint -= 0x10000
1541
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
1542
codePoint = 0xDC00 | codePoint & 0x3FF
1543
}
1544
1545
res.push(codePoint)
1546
i += bytesPerSequence
1547
}
1548
1549
return decodeCodePointsArray(res)
1550
}
1551
1552
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
1553
// the lowest limit is Chrome, with 0x10000 args.
1554
// We go 1 magnitude less, for safety
1555
var MAX_ARGUMENTS_LENGTH = 0x1000
1556
1557
function decodeCodePointsArray (codePoints) {
1558
var len = codePoints.length
1559
if (len <= MAX_ARGUMENTS_LENGTH) {
1560
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1561
}
1562
1563
// Decode in chunks to avoid "call stack size exceeded".
1564
var res = ''
1565
var i = 0
1566
while (i < len) {
1567
res += String.fromCharCode.apply(
1568
String,
1569
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1570
)
1571
}
1572
return res
1573
}
1574
1575
function asciiSlice (buf, start, end) {
1576
var ret = ''
1577
end = Math.min(buf.length, end)
1578
1579
for (var i = start; i < end; i++) {
1580
ret += String.fromCharCode(buf[i] & 0x7F)
1581
}
1582
return ret
1583
}
1584
1585
function binarySlice (buf, start, end) {
1586
var ret = ''
1587
end = Math.min(buf.length, end)
1588
1589
for (var i = start; i < end; i++) {
1590
ret += String.fromCharCode(buf[i])
1591
}
1592
return ret
1593
}
1594
1595
function hexSlice (buf, start, end) {
1596
var len = buf.length
1597
1598
if (!start || start < 0) start = 0
1599
if (!end || end < 0 || end > len) end = len
1600
1601
var out = ''
1602
for (var i = start; i < end; i++) {
1603
out += toHex(buf[i])
1604
}
1605
return out
1606
}
1607
1608
function utf16leSlice (buf, start, end) {
1609
var bytes = buf.slice(start, end)
1610
var res = ''
1611
for (var i = 0; i < bytes.length; i += 2) {
1612
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
1613
}
1614
return res
1615
}
1616
1617
Buffer.prototype.slice = function slice (start, end) {
1618
var len = this.length
1619
start = ~~start
1620
end = end === undefined ? len : ~~end
1621
1622
if (start < 0) {
1623
start += len
1624
if (start < 0) start = 0
1625
} else if (start > len) {
1626
start = len
1627
}
1628
1629
if (end < 0) {
1630
end += len
1631
if (end < 0) end = 0
1632
} else if (end > len) {
1633
end = len
1634
}
1635
1636
if (end < start) end = start
1637
1638
var newBuf
1639
if (Buffer.TYPED_ARRAY_SUPPORT) {
1640
newBuf = Buffer._augment(this.subarray(start, end))
1641
} else {
1642
var sliceLen = end - start
1643
newBuf = new Buffer(sliceLen, undefined)
1644
for (var i = 0; i < sliceLen; i++) {
1645
newBuf[i] = this[i + start]
1646
}
1647
}
1648
1649
if (newBuf.length) newBuf.parent = this.parent || this
1650
1651
return newBuf
1652
}
1653
1654
/*
1655
* Need to make sure that buffer isn't trying to write out of bounds.
1656
*/
1657
function checkOffset (offset, ext, length) {
1658
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1659
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1660
}
1661
1662
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1663
offset = offset | 0
1664
byteLength = byteLength | 0
1665
if (!noAssert) checkOffset(offset, byteLength, this.length)
1666
1667
var val = this[offset]
1668
var mul = 1
1669
var i = 0
1670
while (++i < byteLength && (mul *= 0x100)) {
1671
val += this[offset + i] * mul
1672
}
1673
1674
return val
1675
}
1676
1677
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1678
offset = offset | 0
1679
byteLength = byteLength | 0
1680
if (!noAssert) {
1681
checkOffset(offset, byteLength, this.length)
1682
}
1683
1684
var val = this[offset + --byteLength]
1685
var mul = 1
1686
while (byteLength > 0 && (mul *= 0x100)) {
1687
val += this[offset + --byteLength] * mul
1688
}
1689
1690
return val
1691
}
1692
1693
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1694
if (!noAssert) checkOffset(offset, 1, this.length)
1695
return this[offset]
1696
}
1697
1698
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1699
if (!noAssert) checkOffset(offset, 2, this.length)
1700
return this[offset] | (this[offset + 1] << 8)
1701
}
1702
1703
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1704
if (!noAssert) checkOffset(offset, 2, this.length)
1705
return (this[offset] << 8) | this[offset + 1]
1706
}
1707
1708
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1709
if (!noAssert) checkOffset(offset, 4, this.length)
1710
1711
return ((this[offset]) |
1712
(this[offset + 1] << 8) |
1713
(this[offset + 2] << 16)) +
1714
(this[offset + 3] * 0x1000000)
1715
}
1716
1717
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1718
if (!noAssert) checkOffset(offset, 4, this.length)
1719
1720
return (this[offset] * 0x1000000) +
1721
((this[offset + 1] << 16) |
1722
(this[offset + 2] << 8) |
1723
this[offset + 3])
1724
}
1725
1726
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1727
offset = offset | 0
1728
byteLength = byteLength | 0
1729
if (!noAssert) checkOffset(offset, byteLength, this.length)
1730
1731
var val = this[offset]
1732
var mul = 1
1733
var i = 0
1734
while (++i < byteLength && (mul *= 0x100)) {
1735
val += this[offset + i] * mul
1736
}
1737
mul *= 0x80
1738
1739
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1740
1741
return val
1742
}
1743
1744
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1745
offset = offset | 0
1746
byteLength = byteLength | 0
1747
if (!noAssert) checkOffset(offset, byteLength, this.length)
1748
1749
var i = byteLength
1750
var mul = 1
1751
var val = this[offset + --i]
1752
while (i > 0 && (mul *= 0x100)) {
1753
val += this[offset + --i] * mul
1754
}
1755
mul *= 0x80
1756
1757
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1758
1759
return val
1760
}
1761
1762
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1763
if (!noAssert) checkOffset(offset, 1, this.length)
1764
if (!(this[offset] & 0x80)) return (this[offset])
1765
return ((0xff - this[offset] + 1) * -1)
1766
}
1767
1768
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1769
if (!noAssert) checkOffset(offset, 2, this.length)
1770
var val = this[offset] | (this[offset + 1] << 8)
1771
return (val & 0x8000) ? val | 0xFFFF0000 : val
1772
}
1773
1774
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1775
if (!noAssert) checkOffset(offset, 2, this.length)
1776
var val = this[offset + 1] | (this[offset] << 8)
1777
return (val & 0x8000) ? val | 0xFFFF0000 : val
1778
}
1779
1780
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1781
if (!noAssert) checkOffset(offset, 4, this.length)
1782
1783
return (this[offset]) |
1784
(this[offset + 1] << 8) |
1785
(this[offset + 2] << 16) |
1786
(this[offset + 3] << 24)
1787
}
1788
1789
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1790
if (!noAssert) checkOffset(offset, 4, this.length)
1791
1792
return (this[offset] << 24) |
1793
(this[offset + 1] << 16) |
1794
(this[offset + 2] << 8) |
1795
(this[offset + 3])
1796
}
1797
1798
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1799
if (!noAssert) checkOffset(offset, 4, this.length)
1800
return ieee754.read(this, offset, true, 23, 4)
1801
}
1802
1803
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1804
if (!noAssert) checkOffset(offset, 4, this.length)
1805
return ieee754.read(this, offset, false, 23, 4)
1806
}
1807
1808
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1809
if (!noAssert) checkOffset(offset, 8, this.length)
1810
return ieee754.read(this, offset, true, 52, 8)
1811
}
1812
1813
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1814
if (!noAssert) checkOffset(offset, 8, this.length)
1815
return ieee754.read(this, offset, false, 52, 8)
1816
}
1817
1818
function checkInt (buf, value, offset, ext, max, min) {
1819
if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
1820
if (value > max || value < min) throw new RangeError('value is out of bounds')
1821
if (offset + ext > buf.length) throw new RangeError('index out of range')
1822
}
1823
1824
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1825
value = +value
1826
offset = offset | 0
1827
byteLength = byteLength | 0
1828
if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
1829
1830
var mul = 1
1831
var i = 0
1832
this[offset] = value & 0xFF
1833
while (++i < byteLength && (mul *= 0x100)) {
1834
this[offset + i] = (value / mul) & 0xFF
1835
}
1836
1837
return offset + byteLength
1838
}
1839
1840
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1841
value = +value
1842
offset = offset | 0
1843
byteLength = byteLength | 0
1844
if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
1845
1846
var i = byteLength - 1
1847
var mul = 1
1848
this[offset + i] = value & 0xFF
1849
while (--i >= 0 && (mul *= 0x100)) {
1850
this[offset + i] = (value / mul) & 0xFF
1851
}
1852
1853
return offset + byteLength
1854
}
1855
1856
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1857
value = +value
1858
offset = offset | 0
1859
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1860
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1861
this[offset] = (value & 0xff)
1862
return offset + 1
1863
}
1864
1865
function objectWriteUInt16 (buf, value, offset, littleEndian) {
1866
if (value < 0) value = 0xffff + value + 1
1867
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
1868
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
1869
(littleEndian ? i : 1 - i) * 8
1870
}
1871
}
1872
1873
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1874
value = +value
1875
offset = offset | 0
1876
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1877
if (Buffer.TYPED_ARRAY_SUPPORT) {
1878
this[offset] = (value & 0xff)
1879
this[offset + 1] = (value >>> 8)
1880
} else {
1881
objectWriteUInt16(this, value, offset, true)
1882
}
1883
return offset + 2
1884
}
1885
1886
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1887
value = +value
1888
offset = offset | 0
1889
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1890
if (Buffer.TYPED_ARRAY_SUPPORT) {
1891
this[offset] = (value >>> 8)
1892
this[offset + 1] = (value & 0xff)
1893
} else {
1894
objectWriteUInt16(this, value, offset, false)
1895
}
1896
return offset + 2
1897
}
1898
1899
function objectWriteUInt32 (buf, value, offset, littleEndian) {
1900
if (value < 0) value = 0xffffffff + value + 1
1901
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
1902
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
1903
}
1904
}
1905
1906
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1907
value = +value
1908
offset = offset | 0
1909
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1910
if (Buffer.TYPED_ARRAY_SUPPORT) {
1911
this[offset + 3] = (value >>> 24)
1912
this[offset + 2] = (value >>> 16)
1913
this[offset + 1] = (value >>> 8)
1914
this[offset] = (value & 0xff)
1915
} else {
1916
objectWriteUInt32(this, value, offset, true)
1917
}
1918
return offset + 4
1919
}
1920
1921
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1922
value = +value
1923
offset = offset | 0
1924
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1925
if (Buffer.TYPED_ARRAY_SUPPORT) {
1926
this[offset] = (value >>> 24)
1927
this[offset + 1] = (value >>> 16)
1928
this[offset + 2] = (value >>> 8)
1929
this[offset + 3] = (value & 0xff)
1930
} else {
1931
objectWriteUInt32(this, value, offset, false)
1932
}
1933
return offset + 4
1934
}
1935
1936
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1937
value = +value
1938
offset = offset | 0
1939
if (!noAssert) {
1940
var limit = Math.pow(2, 8 * byteLength - 1)
1941
1942
checkInt(this, value, offset, byteLength, limit - 1, -limit)
1943
}
1944
1945
var i = 0
1946
var mul = 1
1947
var sub = value < 0 ? 1 : 0
1948
this[offset] = value & 0xFF
1949
while (++i < byteLength && (mul *= 0x100)) {
1950
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1951
}
1952
1953
return offset + byteLength
1954
}
1955
1956
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1957
value = +value
1958
offset = offset | 0
1959
if (!noAssert) {
1960
var limit = Math.pow(2, 8 * byteLength - 1)
1961
1962
checkInt(this, value, offset, byteLength, limit - 1, -limit)
1963
}
1964
1965
var i = byteLength - 1
1966
var mul = 1
1967
var sub = value < 0 ? 1 : 0
1968
this[offset + i] = value & 0xFF
1969
while (--i >= 0 && (mul *= 0x100)) {
1970
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1971
}
1972
1973
return offset + byteLength
1974
}
1975
1976
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
1977
value = +value
1978
offset = offset | 0
1979
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
1980
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1981
if (value < 0) value = 0xff + value + 1
1982
this[offset] = (value & 0xff)
1983
return offset + 1
1984
}
1985
1986
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
1987
value = +value
1988
offset = offset | 0
1989
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
1990
if (Buffer.TYPED_ARRAY_SUPPORT) {
1991
this[offset] = (value & 0xff)
1992
this[offset + 1] = (value >>> 8)
1993
} else {
1994
objectWriteUInt16(this, value, offset, true)
1995
}
1996
return offset + 2
1997
}
1998
1999
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
2000
value = +value
2001
offset = offset | 0
2002
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
2003
if (Buffer.TYPED_ARRAY_SUPPORT) {
2004
this[offset] = (value >>> 8)
2005
this[offset + 1] = (value & 0xff)
2006
} else {
2007
objectWriteUInt16(this, value, offset, false)
2008
}
2009
return offset + 2
2010
}
2011
2012
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
2013
value = +value
2014
offset = offset | 0
2015
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
2016
if (Buffer.TYPED_ARRAY_SUPPORT) {
2017
this[offset] = (value & 0xff)
2018
this[offset + 1] = (value >>> 8)
2019
this[offset + 2] = (value >>> 16)
2020
this[offset + 3] = (value >>> 24)
2021
} else {
2022
objectWriteUInt32(this, value, offset, true)
2023
}
2024
return offset + 4
2025
}
2026
2027
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
2028
value = +value
2029
offset = offset | 0
2030
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
2031
if (value < 0) value = 0xffffffff + value + 1
2032
if (Buffer.TYPED_ARRAY_SUPPORT) {
2033
this[offset] = (value >>> 24)
2034
this[offset + 1] = (value >>> 16)
2035
this[offset + 2] = (value >>> 8)
2036
this[offset + 3] = (value & 0xff)
2037
} else {
2038
objectWriteUInt32(this, value, offset, false)
2039
}
2040
return offset + 4
2041
}
2042
2043
function checkIEEE754 (buf, value, offset, ext, max, min) {
2044
if (value > max || value < min) throw new RangeError('value is out of bounds')
2045
if (offset + ext > buf.length) throw new RangeError('index out of range')
2046
if (offset < 0) throw new RangeError('index out of range')
2047
}
2048
2049
function writeFloat (buf, value, offset, littleEndian, noAssert) {
2050
if (!noAssert) {
2051
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
2052
}
2053
ieee754.write(buf, value, offset, littleEndian, 23, 4)
2054
return offset + 4
2055
}
2056
2057
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
2058
return writeFloat(this, value, offset, true, noAssert)
2059
}
2060
2061
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
2062
return writeFloat(this, value, offset, false, noAssert)
2063
}
2064
2065
function writeDouble (buf, value, offset, littleEndian, noAssert) {
2066
if (!noAssert) {
2067
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
2068
}
2069
ieee754.write(buf, value, offset, littleEndian, 52, 8)
2070
return offset + 8
2071
}
2072
2073
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
2074
return writeDouble(this, value, offset, true, noAssert)
2075
}
2076
2077
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
2078
return writeDouble(this, value, offset, false, noAssert)
2079
}
2080
2081
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
2082
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
2083
if (!start) start = 0
2084
if (!end && end !== 0) end = this.length
2085
if (targetStart >= target.length) targetStart = target.length
2086
if (!targetStart) targetStart = 0
2087
if (end > 0 && end < start) end = start
2088
2089
// Copy 0 bytes; we're done
2090
if (end === start) return 0
2091
if (target.length === 0 || this.length === 0) return 0
2092
2093
// Fatal error conditions
2094
if (targetStart < 0) {
2095
throw new RangeError('targetStart out of bounds')
2096
}
2097
if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
2098
if (end < 0) throw new RangeError('sourceEnd out of bounds')
2099
2100
// Are we oob?
2101
if (end > this.length) end = this.length
2102
if (target.length - targetStart < end - start) {
2103
end = target.length - targetStart + start
2104
}
2105
2106
var len = end - start
2107
var i
2108
2109
if (this === target && start < targetStart && targetStart < end) {
2110
// descending copy from end
2111
for (i = len - 1; i >= 0; i--) {
2112
target[i + targetStart] = this[i + start]
2113
}
2114
} else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
2115
// ascending copy from start
2116
for (i = 0; i < len; i++) {
2117
target[i + targetStart] = this[i + start]
2118
}
2119
} else {
2120
target._set(this.subarray(start, start + len), targetStart)
2121
}
2122
2123
return len
2124
}
2125
2126
// fill(value, start=0, end=buffer.length)
2127
Buffer.prototype.fill = function fill (value, start, end) {
2128
if (!value) value = 0
2129
if (!start) start = 0
2130
if (!end) end = this.length
2131
2132
if (end < start) throw new RangeError('end < start')
2133
2134
// Fill 0 bytes; we're done
2135
if (end === start) return
2136
if (this.length === 0) return
2137
2138
if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
2139
if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
2140
2141
var i
2142
if (typeof value === 'number') {
2143
for (i = start; i < end; i++) {
2144
this[i] = value
2145
}
2146
} else {
2147
var bytes = utf8ToBytes(value.toString())
2148
var len = bytes.length
2149
for (i = start; i < end; i++) {
2150
this[i] = bytes[i % len]
2151
}
2152
}
2153
2154
return this
2155
}
2156
2157
/**
2158
* Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
2159
* Added in Node 0.12. Only available in browsers that support ArrayBuffer.
2160
*/
2161
Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
2162
if (typeof Uint8Array !== 'undefined') {
2163
if (Buffer.TYPED_ARRAY_SUPPORT) {
2164
return (new Buffer(this)).buffer
2165
} else {
2166
var buf = new Uint8Array(this.length)
2167
for (var i = 0, len = buf.length; i < len; i += 1) {
2168
buf[i] = this[i]
2169
}
2170
return buf.buffer
2171
}
2172
} else {
2173
throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
2174
}
2175
}
2176
2177
// HELPER FUNCTIONS
2178
// ================
2179
2180
var BP = Buffer.prototype
2181
2182
/**
2183
* Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
2184
*/
2185
Buffer._augment = function _augment (arr) {
2186
arr.constructor = Buffer
2187
arr._isBuffer = true
2188
2189
// save reference to original Uint8Array set method before overwriting
2190
arr._set = arr.set
2191
2192
// deprecated
2193
arr.get = BP.get
2194
arr.set = BP.set
2195
2196
arr.write = BP.write
2197
arr.toString = BP.toString
2198
arr.toLocaleString = BP.toString
2199
arr.toJSON = BP.toJSON
2200
arr.equals = BP.equals
2201
arr.compare = BP.compare
2202
arr.indexOf = BP.indexOf
2203
arr.copy = BP.copy
2204
arr.slice = BP.slice
2205
arr.readUIntLE = BP.readUIntLE
2206
arr.readUIntBE = BP.readUIntBE
2207
arr.readUInt8 = BP.readUInt8
2208
arr.readUInt16LE = BP.readUInt16LE
2209
arr.readUInt16BE = BP.readUInt16BE
2210
arr.readUInt32LE = BP.readUInt32LE
2211
arr.readUInt32BE = BP.readUInt32BE
2212
arr.readIntLE = BP.readIntLE
2213
arr.readIntBE = BP.readIntBE
2214
arr.readInt8 = BP.readInt8
2215
arr.readInt16LE = BP.readInt16LE
2216
arr.readInt16BE = BP.readInt16BE
2217
arr.readInt32LE = BP.readInt32LE
2218
arr.readInt32BE = BP.readInt32BE
2219
arr.readFloatLE = BP.readFloatLE
2220
arr.readFloatBE = BP.readFloatBE
2221
arr.readDoubleLE = BP.readDoubleLE
2222
arr.readDoubleBE = BP.readDoubleBE
2223
arr.writeUInt8 = BP.writeUInt8
2224
arr.writeUIntLE = BP.writeUIntLE
2225
arr.writeUIntBE = BP.writeUIntBE
2226
arr.writeUInt16LE = BP.writeUInt16LE
2227
arr.writeUInt16BE = BP.writeUInt16BE
2228
arr.writeUInt32LE = BP.writeUInt32LE
2229
arr.writeUInt32BE = BP.writeUInt32BE
2230
arr.writeIntLE = BP.writeIntLE
2231
arr.writeIntBE = BP.writeIntBE
2232
arr.writeInt8 = BP.writeInt8
2233
arr.writeInt16LE = BP.writeInt16LE
2234
arr.writeInt16BE = BP.writeInt16BE
2235
arr.writeInt32LE = BP.writeInt32LE
2236
arr.writeInt32BE = BP.writeInt32BE
2237
arr.writeFloatLE = BP.writeFloatLE
2238
arr.writeFloatBE = BP.writeFloatBE
2239
arr.writeDoubleLE = BP.writeDoubleLE
2240
arr.writeDoubleBE = BP.writeDoubleBE
2241
arr.fill = BP.fill
2242
arr.inspect = BP.inspect
2243
arr.toArrayBuffer = BP.toArrayBuffer
2244
2245
return arr
2246
}
2247
2248
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
2249
2250
function base64clean (str) {
2251
// Node strips out invalid characters like \n and \t from the string, base64-js does not
2252
str = stringtrim(str).replace(INVALID_BASE64_RE, '')
2253
// Node converts strings with length < 2 to ''
2254
if (str.length < 2) return ''
2255
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
2256
while (str.length % 4 !== 0) {
2257
str = str + '='
2258
}
2259
return str
2260
}
2261
2262
function stringtrim (str) {
2263
if (str.trim) return str.trim()
2264
return str.replace(/^\s+|\s+$/g, '')
2265
}
2266
2267
function toHex (n) {
2268
if (n < 16) return '0' + n.toString(16)
2269
return n.toString(16)
2270
}
2271
2272
function utf8ToBytes (string, units) {
2273
units = units || Infinity
2274
var codePoint
2275
var length = string.length
2276
var leadSurrogate = null
2277
var bytes = []
2278
2279
for (var i = 0; i < length; i++) {
2280
codePoint = string.charCodeAt(i)
2281
2282
// is surrogate component
2283
if (codePoint > 0xD7FF && codePoint < 0xE000) {
2284
// last char was a lead
2285
if (!leadSurrogate) {
2286
// no lead yet
2287
if (codePoint > 0xDBFF) {
2288
// unexpected trail
2289
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2290
continue
2291
} else if (i + 1 === length) {
2292
// unpaired lead
2293
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2294
continue
2295
}
2296
2297
// valid lead
2298
leadSurrogate = codePoint
2299
2300
continue
2301
}
2302
2303
// 2 leads in a row
2304
if (codePoint < 0xDC00) {
2305
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2306
leadSurrogate = codePoint
2307
continue
2308
}
2309
2310
// valid surrogate pair
2311
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
2312
} else if (leadSurrogate) {
2313
// valid bmp char, but last char was a lead
2314
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2315
}
2316
2317
leadSurrogate = null
2318
2319
// encode utf8
2320
if (codePoint < 0x80) {
2321
if ((units -= 1) < 0) break
2322
bytes.push(codePoint)
2323
} else if (codePoint < 0x800) {
2324
if ((units -= 2) < 0) break
2325
bytes.push(
2326
codePoint >> 0x6 | 0xC0,
2327
codePoint & 0x3F | 0x80
2328
)
2329
} else if (codePoint < 0x10000) {
2330
if ((units -= 3) < 0) break
2331
bytes.push(
2332
codePoint >> 0xC | 0xE0,
2333
codePoint >> 0x6 & 0x3F | 0x80,
2334
codePoint & 0x3F | 0x80
2335
)
2336
} else if (codePoint < 0x110000) {
2337
if ((units -= 4) < 0) break
2338
bytes.push(
2339
codePoint >> 0x12 | 0xF0,
2340
codePoint >> 0xC & 0x3F | 0x80,
2341
codePoint >> 0x6 & 0x3F | 0x80,
2342
codePoint & 0x3F | 0x80
2343
)
2344
} else {
2345
throw new Error('Invalid code point')
2346
}
2347
}
2348
2349
return bytes
2350
}
2351
2352
function asciiToBytes (str) {
2353
var byteArray = []
2354
for (var i = 0; i < str.length; i++) {
2355
// Node's code seems to be doing this and not & 0x7F..
2356
byteArray.push(str.charCodeAt(i) & 0xFF)
2357
}
2358
return byteArray
2359
}
2360
2361
function utf16leToBytes (str, units) {
2362
var c, hi, lo
2363
var byteArray = []
2364
for (var i = 0; i < str.length; i++) {
2365
if ((units -= 2) < 0) break
2366
2367
c = str.charCodeAt(i)
2368
hi = c >> 8
2369
lo = c % 256
2370
byteArray.push(lo)
2371
byteArray.push(hi)
2372
}
2373
2374
return byteArray
2375
}
2376
2377
function base64ToBytes (str) {
2378
return base64.toByteArray(base64clean(str))
2379
}
2380
2381
function blitBuffer (src, dst, offset, length) {
2382
for (var i = 0; i < length; i++) {
2383
if ((i + offset >= dst.length) || (i >= src.length)) break
2384
dst[i + offset] = src[i]
2385
}
2386
return i
2387
}
2388
2389
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7).Buffer, (function() { return this; }())))
2390
2391
/***/ },
2392
/* 8 */
2393
/***/ function(module, exports, __webpack_require__) {
2394
2395
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
2396
2397
;(function (exports) {
2398
'use strict';
2399
2400
var Arr = (typeof Uint8Array !== 'undefined')
2401
? Uint8Array
2402
: Array
2403
2404
var PLUS = '+'.charCodeAt(0)
2405
var SLASH = '/'.charCodeAt(0)
2406
var NUMBER = '0'.charCodeAt(0)
2407
var LOWER = 'a'.charCodeAt(0)
2408
var UPPER = 'A'.charCodeAt(0)
2409
var PLUS_URL_SAFE = '-'.charCodeAt(0)
2410
var SLASH_URL_SAFE = '_'.charCodeAt(0)
2411
2412
function decode (elt) {
2413
var code = elt.charCodeAt(0)
2414
if (code === PLUS ||
2415
code === PLUS_URL_SAFE)
2416
return 62 // '+'
2417
if (code === SLASH ||
2418
code === SLASH_URL_SAFE)
2419
return 63 // '/'
2420
if (code < NUMBER)
2421
return -1 //no match
2422
if (code < NUMBER + 10)
2423
return code - NUMBER + 26 + 26
2424
if (code < UPPER + 26)
2425
return code - UPPER
2426
if (code < LOWER + 26)
2427
return code - LOWER + 26
2428
}
2429
2430
function b64ToByteArray (b64) {
2431
var i, j, l, tmp, placeHolders, arr
2432
2433
if (b64.length % 4 > 0) {
2434
throw new Error('Invalid string. Length must be a multiple of 4')
2435
}
2436
2437
// the number of equal signs (place holders)
2438
// if there are two placeholders, than the two characters before it
2439
// represent one byte
2440
// if there is only one, then the three characters before it represent 2 bytes
2441
// this is just a cheap hack to not do indexOf twice
2442
var len = b64.length
2443
placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
2444
2445
// base64 is 4/3 + up to two characters of the original data
2446
arr = new Arr(b64.length * 3 / 4 - placeHolders)
2447
2448
// if there are placeholders, only get up to the last complete 4 chars
2449
l = placeHolders > 0 ? b64.length - 4 : b64.length
2450
2451
var L = 0
2452
2453
function push (v) {
2454
arr[L++] = v
2455
}
2456
2457
for (i = 0, j = 0; i < l; i += 4, j += 3) {
2458
tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
2459
push((tmp & 0xFF0000) >> 16)
2460
push((tmp & 0xFF00) >> 8)
2461
push(tmp & 0xFF)
2462
}
2463
2464
if (placeHolders === 2) {
2465
tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
2466
push(tmp & 0xFF)
2467
} else if (placeHolders === 1) {
2468
tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
2469
push((tmp >> 8) & 0xFF)
2470
push(tmp & 0xFF)
2471
}
2472
2473
return arr
2474
}
2475
2476
function uint8ToBase64 (uint8) {
2477
var i,
2478
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
2479
output = "",
2480
temp, length
2481
2482
function encode (num) {
2483
return lookup.charAt(num)
2484
}
2485
2486
function tripletToBase64 (num) {
2487
return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
2488
}
2489
2490
// go through the array every three bytes, we'll deal with trailing stuff later
2491
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
2492
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
2493
output += tripletToBase64(temp)
2494
}
2495
2496
// pad the end with zeros, but make sure to not forget the extra bytes
2497
switch (extraBytes) {
2498
case 1:
2499
temp = uint8[uint8.length - 1]
2500
output += encode(temp >> 2)
2501
output += encode((temp << 4) & 0x3F)
2502
output += '=='
2503
break
2504
case 2:
2505
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
2506
output += encode(temp >> 10)
2507
output += encode((temp >> 4) & 0x3F)
2508
output += encode((temp << 2) & 0x3F)
2509
output += '='
2510
break
2511
}
2512
2513
return output
2514
}
2515
2516
exports.toByteArray = b64ToByteArray
2517
exports.fromByteArray = uint8ToBase64
2518
}( false ? (this.base64js = {}) : exports))
2519
2520
2521
/***/ },
2522
/* 9 */
2523
/***/ function(module, exports) {
2524
2525
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
2526
var e, m
2527
var eLen = nBytes * 8 - mLen - 1
2528
var eMax = (1 << eLen) - 1
2529
var eBias = eMax >> 1
2530
var nBits = -7
2531
var i = isLE ? (nBytes - 1) : 0
2532
var d = isLE ? -1 : 1
2533
var s = buffer[offset + i]
2534
2535
i += d
2536
2537
e = s & ((1 << (-nBits)) - 1)
2538
s >>= (-nBits)
2539
nBits += eLen
2540
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
2541
2542
m = e & ((1 << (-nBits)) - 1)
2543
e >>= (-nBits)
2544
nBits += mLen
2545
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
2546
2547
if (e === 0) {
2548
e = 1 - eBias
2549
} else if (e === eMax) {
2550
return m ? NaN : ((s ? -1 : 1) * Infinity)
2551
} else {
2552
m = m + Math.pow(2, mLen)
2553
e = e - eBias
2554
}
2555
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
2556
}
2557
2558
exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
2559
var e, m, c
2560
var eLen = nBytes * 8 - mLen - 1
2561
var eMax = (1 << eLen) - 1
2562
var eBias = eMax >> 1
2563
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
2564
var i = isLE ? 0 : (nBytes - 1)
2565
var d = isLE ? 1 : -1
2566
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
2567
2568
value = Math.abs(value)
2569
2570
if (isNaN(value) || value === Infinity) {
2571
m = isNaN(value) ? 1 : 0
2572
e = eMax
2573
} else {
2574
e = Math.floor(Math.log(value) / Math.LN2)
2575
if (value * (c = Math.pow(2, -e)) < 1) {
2576
e--
2577
c *= 2
2578
}
2579
if (e + eBias >= 1) {
2580
value += rt / c
2581
} else {
2582
value += rt * Math.pow(2, 1 - eBias)
2583
}
2584
if (value * c >= 2) {
2585
e++
2586
c /= 2
2587
}
2588
2589
if (e + eBias >= eMax) {
2590
m = 0
2591
e = eMax
2592
} else if (e + eBias >= 1) {
2593
m = (value * c - 1) * Math.pow(2, mLen)
2594
e = e + eBias
2595
} else {
2596
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
2597
e = 0
2598
}
2599
}
2600
2601
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
2602
2603
e = (e << mLen) | m
2604
eLen += mLen
2605
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
2606
2607
buffer[offset + i - d] |= s * 128
2608
}
2609
2610
2611
/***/ },
2612
/* 10 */
2613
/***/ function(module, exports) {
2614
2615
var toString = {}.toString;
2616
2617
module.exports = Array.isArray || function (arr) {
2618
return toString.call(arr) == '[object Array]';
2619
};
2620
2621
2622
/***/ },
2623
/* 11 */
2624
/***/ function(module, exports, __webpack_require__) {
2625
2626
'use strict';
2627
2628
Object.defineProperty(exports, "__esModule", {
2629
value: true
2630
});
2631
2632
var _objectInspect = __webpack_require__(12);
2633
2634
var _objectInspect2 = _interopRequireDefault(_objectInspect);
2635
2636
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2637
2638
var formatString = function formatString(string, args) {
2639
var index = 0;
2640
return string.replace(/%s/g, function () {
2641
return (0, _objectInspect2.default)(args[index++]);
2642
});
2643
};
2644
2645
var assert = function assert(condition, createMessage) {
2646
for (var _len = arguments.length, extraArgs = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2647
extraArgs[_key - 2] = arguments[_key];
2648
}
2649
2650
if (condition) return;
2651
2652
var message = typeof createMessage === 'string' ? formatString(createMessage, extraArgs) : createMessage(extraArgs);
2653
2654
throw new Error(message);
2655
};
2656
2657
exports.default = assert;
2658
2659
/***/ },
2660
/* 12 */
2661
/***/ function(module, exports) {
2662
2663
var hasMap = typeof Map === 'function' && Map.prototype;
2664
var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
2665
var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
2666
var mapForEach = hasMap && Map.prototype.forEach;
2667
var hasSet = typeof Set === 'function' && Set.prototype;
2668
var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
2669
var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
2670
var setForEach = hasSet && Set.prototype.forEach;
2671
var booleanValueOf = Boolean.prototype.valueOf;
2672
2673
module.exports = function inspect_ (obj, opts, depth, seen) {
2674
if (!opts) opts = {};
2675
2676
var maxDepth = opts.depth === undefined ? 5 : opts.depth;
2677
if (depth === undefined) depth = 0;
2678
if (depth >= maxDepth && maxDepth > 0 && obj && typeof obj === 'object') {
2679
return '[Object]';
2680
}
2681
2682
if (seen === undefined) seen = [];
2683
else if (indexOf(seen, obj) >= 0) {
2684
return '[Circular]';
2685
}
2686
2687
function inspect (value, from) {
2688
if (from) {
2689
seen = seen.slice();
2690
seen.push(from);
2691
}
2692
return inspect_(value, opts, depth + 1, seen);
2693
}
2694
2695
if (typeof obj === 'string') {
2696
return inspectString(obj);
2697
}
2698
else if (typeof obj === 'function') {
2699
var name = nameOf(obj);
2700
return '[Function' + (name ? ': ' + name : '') + ']';
2701
}
2702
else if (obj === null) {
2703
return 'null';
2704
}
2705
else if (isSymbol(obj)) {
2706
var symString = Symbol.prototype.toString.call(obj);
2707
return typeof obj === 'object' ? 'Object(' + symString + ')' : symString;
2708
}
2709
else if (isElement(obj)) {
2710
var s = '<' + String(obj.nodeName).toLowerCase();
2711
var attrs = obj.attributes || [];
2712
for (var i = 0; i < attrs.length; i++) {
2713
s += ' ' + attrs[i].name + '="' + quote(attrs[i].value) + '"';
2714
}
2715
s += '>';
2716
if (obj.childNodes && obj.childNodes.length) s += '...';
2717
s += '</' + String(obj.nodeName).toLowerCase() + '>';
2718
return s;
2719
}
2720
else if (isArray(obj)) {
2721
if (obj.length === 0) return '[]';
2722
var xs = Array(obj.length);
2723
for (var i = 0; i < obj.length; i++) {
2724
xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
2725
}
2726
return '[ ' + xs.join(', ') + ' ]';
2727
}
2728
else if (isError(obj)) {
2729
var parts = [];
2730
for (var key in obj) {
2731
if (!has(obj, key)) continue;
2732
2733
if (/[^\w$]/.test(key)) {
2734
parts.push(inspect(key) + ': ' + inspect(obj[key]));
2735
}
2736
else {
2737
parts.push(key + ': ' + inspect(obj[key]));
2738
}
2739
}
2740
if (parts.length === 0) return '[' + obj + ']';
2741
return '{ [' + obj + '] ' + parts.join(', ') + ' }';
2742
}
2743
else if (typeof obj === 'object' && typeof obj.inspect === 'function') {
2744
return obj.inspect();
2745
}
2746
else if (isMap(obj)) {
2747
var parts = [];
2748
mapForEach.call(obj, function (value, key) {
2749
parts.push(inspect(key, obj) + ' => ' + inspect(value, obj));
2750
});
2751
return 'Map (' + mapSize.call(obj) + ') {' + parts.join(', ') + '}';
2752
}
2753
else if (isSet(obj)) {
2754
var parts = [];
2755
setForEach.call(obj, function (value ) {
2756
parts.push(inspect(value, obj));
2757
});
2758
return 'Set (' + setSize.call(obj) + ') {' + parts.join(', ') + '}';
2759
}
2760
else if (typeof obj !== 'object') {
2761
return String(obj);
2762
}
2763
else if (isNumber(obj)) {
2764
return 'Object(' + Number(obj) + ')';
2765
}
2766
else if (isBoolean(obj)) {
2767
return 'Object(' + booleanValueOf.call(obj) + ')';
2768
}
2769
else if (isString(obj)) {
2770
return 'Object(' + inspect(String(obj)) + ')';
2771
}
2772
else if (!isDate(obj) && !isRegExp(obj)) {
2773
var xs = [], keys = [];
2774
for (var key in obj) {
2775
if (has(obj, key)) keys.push(key);
2776
}
2777
keys.sort();
2778
for (var i = 0; i < keys.length; i++) {
2779
var key = keys[i];
2780
if (/[^\w$]/.test(key)) {
2781
xs.push(inspect(key) + ': ' + inspect(obj[key], obj));
2782
}
2783
else xs.push(key + ': ' + inspect(obj[key], obj));
2784
}
2785
if (xs.length === 0) return '{}';
2786
return '{ ' + xs.join(', ') + ' }';
2787
}
2788
else return String(obj);
2789
};
2790
2791
function quote (s) {
2792
return String(s).replace(/"/g, '&quot;');
2793
}
2794
2795
function isArray (obj) { return toStr(obj) === '[object Array]' }
2796
function isDate (obj) { return toStr(obj) === '[object Date]' }
2797
function isRegExp (obj) { return toStr(obj) === '[object RegExp]' }
2798
function isError (obj) { return toStr(obj) === '[object Error]' }
2799
function isSymbol (obj) { return toStr(obj) === '[object Symbol]' }
2800
function isString (obj) { return toStr(obj) === '[object String]' }
2801
function isNumber (obj) { return toStr(obj) === '[object Number]' }
2802
function isBoolean (obj) { return toStr(obj) === '[object Boolean]' }
2803
2804
var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; };
2805
function has (obj, key) {
2806
return hasOwn.call(obj, key);
2807
}
2808
2809
function toStr (obj) {
2810
return Object.prototype.toString.call(obj);
2811
}
2812
2813
function nameOf (f) {
2814
if (f.name) return f.name;
2815
var m = f.toString().match(/^function\s*([\w$]+)/);
2816
if (m) return m[1];
2817
}
2818
2819
function indexOf (xs, x) {
2820
if (xs.indexOf) return xs.indexOf(x);
2821
for (var i = 0, l = xs.length; i < l; i++) {
2822
if (xs[i] === x) return i;
2823
}
2824
return -1;
2825
}
2826
2827
function isMap (x) {
2828
if (!mapSize) {
2829
return false;
2830
}
2831
try {
2832
mapSize.call(x);
2833
return true;
2834
} catch (e) {}
2835
return false;
2836
}
2837
2838
function isSet (x) {
2839
if (!setSize) {
2840
return false;
2841
}
2842
try {
2843
setSize.call(x);
2844
return true;
2845
} catch (e) {}
2846
return false;
2847
}
2848
2849
function isElement (x) {
2850
if (!x || typeof x !== 'object') return false;
2851
if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
2852
return true;
2853
}
2854
return typeof x.nodeName === 'string'
2855
&& typeof x.getAttribute === 'function'
2856
;
2857
}
2858
2859
function inspectString (str) {
2860
var s = str.replace(/(['\\])/g, '\\$1').replace(/[\x00-\x1f]/g, lowbyte);
2861
return "'" + s + "'";
2862
2863
function lowbyte (c) {
2864
var n = c.charCodeAt(0);
2865
var x = { 8: 'b', 9: 't', 10: 'n', 12: 'f', 13: 'r' }[n];
2866
if (x) return '\\' + x;
2867
return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16);
2868
}
2869
}
2870
2871
2872
/***/ },
2873
/* 13 */
2874
/***/ function(module, exports, __webpack_require__) {
2875
2876
'use strict';
2877
2878
Object.defineProperty(exports, "__esModule", {
2879
value: true
2880
});
2881
exports.spyOn = exports.createSpy = exports.restoreSpies = exports.isSpy = undefined;
2882
2883
var _defineProperties = __webpack_require__(14);
2884
2885
var _assert = __webpack_require__(11);
2886
2887
var _assert2 = _interopRequireDefault(_assert);
2888
2889
var _TestUtils = __webpack_require__(18);
2890
2891
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2892
2893
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } /*eslint-disable prefer-rest-params, no-underscore-dangle*/
2894
2895
2896
var noop = function noop() {};
2897
2898
var supportsConfigurableFnLength = _defineProperties.supportsDescriptors && Object.getOwnPropertyDescriptor(function () {}, 'length').configurable;
2899
2900
var isSpy = exports.isSpy = function isSpy(object) {
2901
return object && object.__isSpy === true;
2902
};
2903
2904
var spies = [];
2905
2906
var restoreSpies = exports.restoreSpies = function restoreSpies() {
2907
for (var i = spies.length - 1; i >= 0; i--) {
2908
spies[i].restore();
2909
}spies = [];
2910
};
2911
2912
var createSpy = exports.createSpy = function createSpy(fn) {
2913
var restore = arguments.length <= 1 || arguments[1] === undefined ? noop : arguments[1];
2914
2915
if (fn == null) fn = noop;
2916
2917
(0, _assert2.default)((0, _TestUtils.isFunction)(fn), 'createSpy needs a function');
2918
2919
var targetFn = void 0,
2920
thrownValue = void 0,
2921
returnValue = void 0,
2922
spy = void 0;
2923
2924
function spyLogic() {
2925
spy.calls.push({
2926
context: this,
2927
arguments: Array.prototype.slice.call(arguments, 0)
2928
});
2929
2930
if (targetFn) return targetFn.apply(this, arguments);
2931
2932
if (thrownValue) throw thrownValue;
2933
2934
return returnValue;
2935
}
2936
2937
if (supportsConfigurableFnLength) {
2938
spy = Object.defineProperty(spyLogic, 'length', { value: fn.length, writable: false, enumerable: false, configurable: true });
2939
} else {
2940
spy = new Function('spy', 'return function(' + // eslint-disable-line no-new-func
2941
[].concat(_toConsumableArray(Array(fn.length))).map(function (_, i) {
2942
return '_' + i;
2943
}).join(',') + ') {\n return spy.apply(this, arguments)\n }')(spyLogic);
2944
}
2945
2946
spy.calls = [];
2947
2948
spy.andCall = function (otherFn) {
2949
targetFn = otherFn;
2950
return spy;
2951
};
2952
2953
spy.andCallThrough = function () {
2954
return spy.andCall(fn);
2955
};
2956
2957
spy.andThrow = function (value) {
2958
thrownValue = value;
2959
return spy;
2960
};
2961
2962
spy.andReturn = function (value) {
2963
returnValue = value;
2964
return spy;
2965
};
2966
2967
spy.getLastCall = function () {
2968
return spy.calls[spy.calls.length - 1];
2969
};
2970
2971
spy.reset = function () {
2972
spy.calls = [];
2973
};
2974
2975
spy.restore = spy.destroy = restore;
2976
2977
spy.__isSpy = true;
2978
2979
spies.push(spy);
2980
2981
return spy;
2982
};
2983
2984
var spyOn = exports.spyOn = function spyOn(object, methodName) {
2985
var original = object[methodName];
2986
2987
if (!isSpy(original)) {
2988
(0, _assert2.default)((0, _TestUtils.isFunction)(original), 'Cannot spyOn the %s property; it is not a function', methodName);
2989
2990
object[methodName] = createSpy(original, function () {
2991
object[methodName] = original;
2992
});
2993
}
2994
2995
return object[methodName];
2996
};
2997
2998
/***/ },
2999
/* 14 */
3000
/***/ function(module, exports, __webpack_require__) {
3001
3002
'use strict';
3003
3004
var keys = __webpack_require__(15);
3005
var foreach = __webpack_require__(17);
3006
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
3007
3008
var toStr = Object.prototype.toString;
3009
3010
var isFunction = function (fn) {
3011
return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
3012
};
3013
3014
var arePropertyDescriptorsSupported = function () {
3015
var obj = {};
3016
try {
3017
Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
3018
/* eslint-disable no-unused-vars, no-restricted-syntax */
3019
for (var _ in obj) { return false; }
3020
/* eslint-enable no-unused-vars, no-restricted-syntax */
3021
return obj.x === obj;
3022
} catch (e) { /* this is IE 8. */
3023
return false;
3024
}
3025
};
3026
var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();
3027
3028
var defineProperty = function (object, name, value, predicate) {
3029
if (name in object && (!isFunction(predicate) || !predicate())) {
3030
return;
3031
}
3032
if (supportsDescriptors) {
3033
Object.defineProperty(object, name, {
3034
configurable: true,
3035
enumerable: false,
3036
value: value,
3037
writable: true
3038
});
3039
} else {
3040
object[name] = value;
3041
}
3042
};
3043
3044
var defineProperties = function (object, map) {
3045
var predicates = arguments.length > 2 ? arguments[2] : {};
3046
var props = keys(map);
3047
if (hasSymbols) {
3048
props = props.concat(Object.getOwnPropertySymbols(map));
3049
}
3050
foreach(props, function (name) {
3051
defineProperty(object, name, map[name], predicates[name]);
3052
});
3053
};
3054
3055
defineProperties.supportsDescriptors = !!supportsDescriptors;
3056
3057
module.exports = defineProperties;
3058
3059
3060
/***/ },
3061
/* 15 */
3062
/***/ function(module, exports, __webpack_require__) {
3063
3064
'use strict';
3065
3066
// modified from https://github.com/es-shims/es5-shim
3067
var has = Object.prototype.hasOwnProperty;
3068
var toStr = Object.prototype.toString;
3069
var slice = Array.prototype.slice;
3070
var isArgs = __webpack_require__(16);
3071
var hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString');
3072
var hasProtoEnumBug = function () {}.propertyIsEnumerable('prototype');
3073
var dontEnums = [
3074
'toString',
3075
'toLocaleString',
3076
'valueOf',
3077
'hasOwnProperty',
3078
'isPrototypeOf',
3079
'propertyIsEnumerable',
3080
'constructor'
3081
];
3082
var equalsConstructorPrototype = function (o) {
3083
var ctor = o.constructor;
3084
return ctor && ctor.prototype === o;
3085
};
3086
var blacklistedKeys = {
3087
$console: true,
3088
$frame: true,
3089
$frameElement: true,
3090
$frames: true,
3091
$parent: true,
3092
$self: true,
3093
$webkitIndexedDB: true,
3094
$webkitStorageInfo: true,
3095
$window: true
3096
};
3097
var hasAutomationEqualityBug = (function () {
3098
/* global window */
3099
if (typeof window === 'undefined') { return false; }
3100
for (var k in window) {
3101
try {
3102
if (!blacklistedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
3103
try {
3104
equalsConstructorPrototype(window[k]);
3105
} catch (e) {
3106
return true;
3107
}
3108
}
3109
} catch (e) {
3110
return true;
3111
}
3112
}
3113
return false;
3114
}());
3115
var equalsConstructorPrototypeIfNotBuggy = function (o) {
3116
/* global window */
3117
if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
3118
return equalsConstructorPrototype(o);
3119
}
3120
try {
3121
return equalsConstructorPrototype(o);
3122
} catch (e) {
3123
return false;
3124
}
3125
};
3126
3127
var keysShim = function keys(object) {
3128
var isObject = object !== null && typeof object === 'object';
3129
var isFunction = toStr.call(object) === '[object Function]';
3130
var isArguments = isArgs(object);
3131
var isString = isObject && toStr.call(object) === '[object String]';
3132
var theKeys = [];
3133
3134
if (!isObject && !isFunction && !isArguments) {
3135
throw new TypeError('Object.keys called on a non-object');
3136
}
3137
3138
var skipProto = hasProtoEnumBug && isFunction;
3139
if (isString && object.length > 0 && !has.call(object, 0)) {
3140
for (var i = 0; i < object.length; ++i) {
3141
theKeys.push(String(i));
3142
}
3143
}
3144
3145
if (isArguments && object.length > 0) {
3146
for (var j = 0; j < object.length; ++j) {
3147
theKeys.push(String(j));
3148
}
3149
} else {
3150
for (var name in object) {
3151
if (!(skipProto && name === 'prototype') && has.call(object, name)) {
3152
theKeys.push(String(name));
3153
}
3154
}
3155
}
3156
3157
if (hasDontEnumBug) {
3158
var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
3159
3160
for (var k = 0; k < dontEnums.length; ++k) {
3161
if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
3162
theKeys.push(dontEnums[k]);
3163
}
3164
}
3165
}
3166
return theKeys;
3167
};
3168
3169
keysShim.shim = function shimObjectKeys() {
3170
if (Object.keys) {
3171
var keysWorksWithArguments = (function () {
3172
// Safari 5.0 bug
3173
return (Object.keys(arguments) || '').length === 2;
3174
}(1, 2));
3175
if (!keysWorksWithArguments) {
3176
var originalKeys = Object.keys;
3177
Object.keys = function keys(object) {
3178
if (isArgs(object)) {
3179
return originalKeys(slice.call(object));
3180
} else {
3181
return originalKeys(object);
3182
}
3183
};
3184
}
3185
} else {
3186
Object.keys = keysShim;
3187
}
3188
return Object.keys || keysShim;
3189
};
3190
3191
module.exports = keysShim;
3192
3193
3194
/***/ },
3195
/* 16 */
3196
/***/ function(module, exports) {
3197
3198
'use strict';
3199
3200
var toStr = Object.prototype.toString;
3201
3202
module.exports = function isArguments(value) {
3203
var str = toStr.call(value);
3204
var isArgs = str === '[object Arguments]';
3205
if (!isArgs) {
3206
isArgs = str !== '[object Array]' &&
3207
value !== null &&
3208
typeof value === 'object' &&
3209
typeof value.length === 'number' &&
3210
value.length >= 0 &&
3211
toStr.call(value.callee) === '[object Function]';
3212
}
3213
return isArgs;
3214
};
3215
3216
3217
/***/ },
3218
/* 17 */
3219
/***/ function(module, exports) {
3220
3221
3222
var hasOwn = Object.prototype.hasOwnProperty;
3223
var toString = Object.prototype.toString;
3224
3225
module.exports = function forEach (obj, fn, ctx) {
3226
if (toString.call(fn) !== '[object Function]') {
3227
throw new TypeError('iterator must be a function');
3228
}
3229
var l = obj.length;
3230
if (l === +l) {
3231
for (var i = 0; i < l; i++) {
3232
fn.call(ctx, obj[i], i, obj);
3233
}
3234
} else {
3235
for (var k in obj) {
3236
if (hasOwn.call(obj, k)) {
3237
fn.call(ctx, obj[k], k, obj);
3238
}
3239
}
3240
}
3241
};
3242
3243
3244
3245
/***/ },
3246
/* 18 */
3247
/***/ function(module, exports, __webpack_require__) {
3248
3249
'use strict';
3250
3251
Object.defineProperty(exports, "__esModule", {
3252
value: true
3253
});
3254
exports.stringContains = exports.objectContains = exports.arrayContains = exports.functionThrows = exports.isA = exports.isObject = exports.isArray = exports.isFunction = exports.isEqual = exports.whyNotEqual = undefined;
3255
3256
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
3257
3258
var _isRegex = __webpack_require__(19);
3259
3260
var _isRegex2 = _interopRequireDefault(_isRegex);
3261
3262
var _why = __webpack_require__(20);
3263
3264
var _why2 = _interopRequireDefault(_why);
3265
3266
var _objectKeys = __webpack_require__(15);
3267
3268
var _objectKeys2 = _interopRequireDefault(_objectKeys);
3269
3270
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3271
3272
/**
3273
* Returns the reason why the given arguments are not *conceptually*
3274
* equal, if any; the empty string otherwise.
3275
*/
3276
var whyNotEqual = exports.whyNotEqual = function whyNotEqual(a, b) {
3277
return a == b ? '' : (0, _why2.default)(a, b);
3278
};
3279
3280
/**
3281
* Returns true if the given arguments are *conceptually* equal.
3282
*/
3283
var isEqual = exports.isEqual = function isEqual(a, b) {
3284
return whyNotEqual(a, b) === '';
3285
};
3286
3287
/**
3288
* Returns true if the given object is a function.
3289
*/
3290
var isFunction = exports.isFunction = function isFunction(object) {
3291
return typeof object === 'function';
3292
};
3293
3294
/**
3295
* Returns true if the given object is an array.
3296
*/
3297
var isArray = exports.isArray = function isArray(object) {
3298
return Array.isArray(object);
3299
};
3300
3301
/**
3302
* Returns true if the given object is an object.
3303
*/
3304
var isObject = exports.isObject = function isObject(object) {
3305
return object && !isArray(object) && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object';
3306
};
3307
3308
/**
3309
* Returns true if the given object is an instanceof value
3310
* or its typeof is the given value.
3311
*/
3312
var isA = exports.isA = function isA(object, value) {
3313
if (isFunction(value)) return object instanceof value;
3314
3315
if (value === 'array') return Array.isArray(object);
3316
3317
return (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === value;
3318
};
3319
3320
/**
3321
* Returns true if the given function throws the given value
3322
* when invoked. The value may be:
3323
*
3324
* - undefined, to merely assert there was a throw
3325
* - a constructor function, for comparing using instanceof
3326
* - a regular expression, to compare with the error message
3327
* - a string, to find in the error message
3328
*/
3329
var functionThrows = exports.functionThrows = function functionThrows(fn, context, args, value) {
3330
try {
3331
fn.apply(context, args);
3332
} catch (error) {
3333
if (value == null) return true;
3334
3335
if (isFunction(value) && error instanceof value) return true;
3336
3337
var message = error.message || error;
3338
3339
if (typeof message === 'string') {
3340
if ((0, _isRegex2.default)(value) && value.test(error.message)) return true;
3341
3342
if (typeof value === 'string' && message.indexOf(value) !== -1) return true;
3343
}
3344
}
3345
3346
return false;
3347
};
3348
3349
/**
3350
* Returns true if the given array contains the value, false
3351
* otherwise. The compareValues function must return false to
3352
* indicate a non-match.
3353
*/
3354
var arrayContains = exports.arrayContains = function arrayContains(array, value, compareValues) {
3355
return array.some(function (item) {
3356
return compareValues(item, value) !== false;
3357
});
3358
};
3359
3360
var ownEnumerableKeys = function ownEnumerableKeys(object) {
3361
if ((typeof Reflect === 'undefined' ? 'undefined' : _typeof(Reflect)) === 'object' && typeof Reflect.ownKeys === 'function') {
3362
return Reflect.ownKeys(object).filter(function (key) {
3363
return Object.getOwnPropertyDescriptor(object, key).enumerable;
3364
});
3365
}
3366
3367
if (typeof Object.getOwnPropertySymbols === 'function') {
3368
return Object.getOwnPropertySymbols(object).filter(function (key) {
3369
return Object.getOwnPropertyDescriptor(object, key).enumerable;
3370
}).concat((0, _objectKeys2.default)(object));
3371
}
3372
3373
return (0, _objectKeys2.default)(object);
3374
};
3375
3376
/**
3377
* Returns true if the given object contains the value, false
3378
* otherwise. The compareValues function must return false to
3379
* indicate a non-match.
3380
*/
3381
var objectContains = exports.objectContains = function objectContains(object, value, compareValues) {
3382
return ownEnumerableKeys(value).every(function (k) {
3383
if (isObject(object[k]) && isObject(value[k])) return objectContains(object[k], value[k], compareValues);
3384
3385
return compareValues(object[k], value[k]);
3386
});
3387
};
3388
3389
/**
3390
* Returns true if the given string contains the value, false otherwise.
3391
*/
3392
var stringContains = exports.stringContains = function stringContains(string, value) {
3393
return string.indexOf(value) !== -1;
3394
};
3395
3396
/***/ },
3397
/* 19 */
3398
/***/ function(module, exports) {
3399
3400
'use strict';
3401
3402
var regexExec = RegExp.prototype.exec;
3403
var tryRegexExec = function tryRegexExec(value) {
3404
try {
3405
regexExec.call(value);
3406
return true;
3407
} catch (e) {
3408
return false;
3409
}
3410
};
3411
var toStr = Object.prototype.toString;
3412
var regexClass = '[object RegExp]';
3413
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
3414
3415
module.exports = function isRegex(value) {
3416
if (typeof value !== 'object') { return false; }
3417
return hasToStringTag ? tryRegexExec(value) : toStr.call(value) === regexClass;
3418
};
3419
3420
3421
/***/ },
3422
/* 20 */
3423
/***/ function(module, exports, __webpack_require__) {
3424
3425
'use strict';
3426
3427
var ObjectPrototype = Object.prototype;
3428
var toStr = ObjectPrototype.toString;
3429
var booleanValue = Boolean.prototype.valueOf;
3430
var has = __webpack_require__(2);
3431
var isArrowFunction = __webpack_require__(21);
3432
var isBoolean = __webpack_require__(23);
3433
var isDate = __webpack_require__(24);
3434
var isGenerator = __webpack_require__(25);
3435
var isNumber = __webpack_require__(26);
3436
var isRegex = __webpack_require__(19);
3437
var isString = __webpack_require__(27);
3438
var isSymbol = __webpack_require__(28);
3439
var isCallable = __webpack_require__(22);
3440
3441
var isProto = Object.prototype.isPrototypeOf;
3442
3443
var foo = function foo() {};
3444
var functionsHaveNames = foo.name === 'foo';
3445
3446
var symbolValue = typeof Symbol === 'function' ? Symbol.prototype.valueOf : null;
3447
var symbolIterator = __webpack_require__(29)();
3448
3449
var collectionsForEach = __webpack_require__(30)();
3450
3451
var getPrototypeOf = Object.getPrototypeOf;
3452
if (!getPrototypeOf) {
3453
/* eslint-disable no-proto */
3454
if (typeof 'test'.__proto__ === 'object') {
3455
getPrototypeOf = function (obj) {
3456
return obj.__proto__;
3457
};
3458
} else {
3459
getPrototypeOf = function (obj) {
3460
var constructor = obj.constructor,
3461
oldConstructor;
3462
if (has(obj, 'constructor')) {
3463
oldConstructor = constructor;
3464
if (!(delete obj.constructor)) { // reset constructor
3465
return null; // can't delete obj.constructor, return null
3466
}
3467
constructor = obj.constructor; // get real constructor
3468
obj.constructor = oldConstructor; // restore constructor
3469
}
3470
return constructor ? constructor.prototype : ObjectPrototype; // needed for IE
3471
};
3472
}
3473
/* eslint-enable no-proto */
3474
}
3475
3476
var isArray = Array.isArray || function (value) {
3477
return toStr.call(value) === '[object Array]';
3478
};
3479
3480
var normalizeFnWhitespace = function normalizeFnWhitespace(fnStr) {
3481
// this is needed in IE 9, at least, which has inconsistencies here.
3482
return fnStr.replace(/^function ?\(/, 'function (').replace('){', ') {');
3483
};
3484
3485
var tryMapSetEntries = function tryMapSetEntries(collection) {
3486
var foundEntries = [];
3487
try {
3488
collectionsForEach.Map.call(collection, function (key, value) {
3489
foundEntries.push([key, value]);
3490
});
3491
} catch (notMap) {
3492
try {
3493
collectionsForEach.Set.call(collection, function (value) {
3494
foundEntries.push([value]);
3495
});
3496
} catch (notSet) {
3497
return false;
3498
}
3499
}
3500
return foundEntries;
3501
};
3502
3503
module.exports = function whyNotEqual(value, other) {
3504
if (value === other) { return ''; }
3505
if (value == null || other == null) {
3506
return value === other ? '' : String(value) + ' !== ' + String(other);
3507
}
3508
3509
var valToStr = toStr.call(value);
3510
var otherToStr = toStr.call(other);
3511
if (valToStr !== otherToStr) {
3512
return 'toStringTag is not the same: ' + valToStr + ' !== ' + otherToStr;
3513
}
3514
3515
var valIsBool = isBoolean(value);
3516
var otherIsBool = isBoolean(other);
3517
if (valIsBool || otherIsBool) {
3518
if (!valIsBool) { return 'first argument is not a boolean; second argument is'; }
3519
if (!otherIsBool) { return 'second argument is not a boolean; first argument is'; }
3520
var valBoolVal = booleanValue.call(value);
3521
var otherBoolVal = booleanValue.call(other);
3522
if (valBoolVal === otherBoolVal) { return ''; }
3523
return 'primitive value of boolean arguments do not match: ' + valBoolVal + ' !== ' + otherBoolVal;
3524
}
3525
3526
var valIsNumber = isNumber(value);
3527
var otherIsNumber = isNumber(value);
3528
if (valIsNumber || otherIsNumber) {
3529
if (!valIsNumber) { return 'first argument is not a number; second argument is'; }
3530
if (!otherIsNumber) { return 'second argument is not a number; first argument is'; }
3531
var valNum = Number(value);
3532
var otherNum = Number(other);
3533
if (valNum === otherNum) { return ''; }
3534
var valIsNaN = isNaN(value);
3535
var otherIsNaN = isNaN(other);
3536
if (valIsNaN && !otherIsNaN) {
3537
return 'first argument is NaN; second is not';
3538
} else if (!valIsNaN && otherIsNaN) {
3539
return 'second argument is NaN; first is not';
3540
} else if (valIsNaN && otherIsNaN) {
3541
return '';
3542
}
3543
return 'numbers are different: ' + value + ' !== ' + other;
3544
}
3545
3546
var valIsString = isString(value);
3547
var otherIsString = isString(other);
3548
if (valIsString || otherIsString) {
3549
if (!valIsString) { return 'second argument is string; first is not'; }
3550
if (!otherIsString) { return 'first argument is string; second is not'; }
3551
var stringVal = String(value);
3552
var otherVal = String(other);
3553
if (stringVal === otherVal) { return ''; }
3554
return 'string values are different: "' + stringVal + '" !== "' + otherVal + '"';
3555
}
3556
3557
var valIsDate = isDate(value);
3558
var otherIsDate = isDate(other);
3559
if (valIsDate || otherIsDate) {
3560
if (!valIsDate) { return 'second argument is Date, first is not'; }
3561
if (!otherIsDate) { return 'first argument is Date, second is not'; }
3562
var valTime = +value;
3563
var otherTime = +other;
3564
if (valTime === otherTime) { return ''; }
3565
return 'Dates have different time values: ' + valTime + ' !== ' + otherTime;
3566
}
3567
3568
var valIsRegex = isRegex(value);
3569
var otherIsRegex = isRegex(other);
3570
if (valIsRegex || otherIsRegex) {
3571
if (!valIsRegex) { return 'second argument is RegExp, first is not'; }
3572
if (!otherIsRegex) { return 'first argument is RegExp, second is not'; }
3573
var regexStringVal = String(value);
3574
var regexStringOther = String(other);
3575
if (regexStringVal === regexStringOther) { return ''; }
3576
return 'regular expressions differ: ' + regexStringVal + ' !== ' + regexStringOther;
3577
}
3578
3579
var valIsArray = isArray(value);
3580
var otherIsArray = isArray(other);
3581
if (valIsArray || otherIsArray) {
3582
if (!valIsArray) { return 'second argument is an Array, first is not'; }
3583
if (!otherIsArray) { return 'first argument is an Array, second is not'; }
3584
if (value.length !== other.length) {
3585
return 'arrays have different length: ' + value.length + ' !== ' + other.length;
3586
}
3587
if (String(value) !== String(other)) { return 'stringified Arrays differ'; }
3588
3589
var index = value.length - 1;
3590
var equal = '';
3591
var valHasIndex, otherHasIndex;
3592
while (equal === '' && index >= 0) {
3593
valHasIndex = has(value, index);
3594
otherHasIndex = has(other, index);
3595
if (!valHasIndex && otherHasIndex) { return 'second argument has index ' + index + '; first does not'; }
3596
if (valHasIndex && !otherHasIndex) { return 'first argument has index ' + index + '; second does not'; }
3597
equal = whyNotEqual(value[index], other[index]);
3598
index -= 1;
3599
}
3600
return equal;
3601
}
3602
3603
var valueIsSym = isSymbol(value);
3604
var otherIsSym = isSymbol(other);
3605
if (valueIsSym !== otherIsSym) {
3606
if (valueIsSym) { return 'first argument is Symbol; second is not'; }
3607
return 'second argument is Symbol; first is not';
3608
}
3609
if (valueIsSym && otherIsSym) {
3610
return symbolValue.call(value) === symbolValue.call(other) ? '' : 'first Symbol value !== second Symbol value';
3611
}
3612
3613
var valueIsGen = isGenerator(value);
3614
var otherIsGen = isGenerator(other);
3615
if (valueIsGen !== otherIsGen) {
3616
if (valueIsGen) { return 'first argument is a Generator; second is not'; }
3617
return 'second argument is a Generator; first is not';
3618
}
3619
3620
var valueIsArrow = isArrowFunction(value);
3621
var otherIsArrow = isArrowFunction(other);
3622
if (valueIsArrow !== otherIsArrow) {
3623
if (valueIsArrow) { return 'first argument is an Arrow function; second is not'; }
3624
return 'second argument is an Arrow function; first is not';
3625
}
3626
3627
if (isCallable(value) || isCallable(other)) {
3628
if (functionsHaveNames && whyNotEqual(value.name, other.name) !== '') {
3629
return 'Function names differ: "' + value.name + '" !== "' + other.name + '"';
3630
}
3631
if (whyNotEqual(value.length, other.length) !== '') {
3632
return 'Function lengths differ: ' + value.length + ' !== ' + other.length;
3633
}
3634
3635
var valueStr = normalizeFnWhitespace(String(value));
3636
var otherStr = normalizeFnWhitespace(String(other));
3637
if (whyNotEqual(valueStr, otherStr) === '') { return ''; }
3638
3639
if (!valueIsGen && !valueIsArrow) {
3640
return whyNotEqual(valueStr.replace(/\)\s*\{/, '){'), otherStr.replace(/\)\s*\{/, '){')) === '' ? '' : 'Function string representations differ';
3641
}
3642
return whyNotEqual(valueStr, otherStr) === '' ? '' : 'Function string representations differ';
3643
}
3644
3645
if (typeof value === 'object' || typeof other === 'object') {
3646
if (typeof value !== typeof other) { return 'arguments have a different typeof: ' + typeof value + ' !== ' + typeof other; }
3647
if (isProto.call(value, other)) { return 'first argument is the [[Prototype]] of the second'; }
3648
if (isProto.call(other, value)) { return 'second argument is the [[Prototype]] of the first'; }
3649
if (getPrototypeOf(value) !== getPrototypeOf(other)) { return 'arguments have a different [[Prototype]]'; }
3650
3651
if (symbolIterator) {
3652
var valueIteratorFn = value[symbolIterator];
3653
var valueIsIterable = isCallable(valueIteratorFn);
3654
var otherIteratorFn = other[symbolIterator];
3655
var otherIsIterable = isCallable(otherIteratorFn);
3656
if (valueIsIterable !== otherIsIterable) {
3657
if (valueIsIterable) { return 'first argument is iterable; second is not'; }
3658
return 'second argument is iterable; first is not';
3659
}
3660
if (valueIsIterable && otherIsIterable) {
3661
var valueIterator = valueIteratorFn.call(value);
3662
var otherIterator = otherIteratorFn.call(other);
3663
var valueNext, otherNext, nextWhy;
3664
do {
3665
valueNext = valueIterator.next();
3666
otherNext = otherIterator.next();
3667
if (!valueNext.done && !otherNext.done) {
3668
nextWhy = whyNotEqual(valueNext, otherNext);
3669
if (nextWhy !== '') {
3670
return 'iteration results are not equal: ' + nextWhy;
3671
}
3672
}
3673
} while (!valueNext.done && !otherNext.done);
3674
if (valueNext.done && !otherNext.done) { return 'first argument finished iterating before second'; }
3675
if (!valueNext.done && otherNext.done) { return 'second argument finished iterating before first'; }
3676
return '';
3677
}
3678
} else if (collectionsForEach.Map || collectionsForEach.Set) {
3679
var valueEntries = tryMapSetEntries(value);
3680
var otherEntries = tryMapSetEntries(other);
3681
var valueEntriesIsArray = isArray(valueEntries);
3682
var otherEntriesIsArray = isArray(otherEntries);
3683
if (valueEntriesIsArray && !otherEntriesIsArray) { return 'first argument has Collection entries, second does not'; }
3684
if (!valueEntriesIsArray && otherEntriesIsArray) { return 'second argument has Collection entries, first does not'; }
3685
if (valueEntriesIsArray && otherEntriesIsArray) {
3686
var entriesWhy = whyNotEqual(valueEntries, otherEntries);
3687
return entriesWhy === '' ? '' : 'Collection entries differ: ' + entriesWhy;
3688
}
3689
}
3690
3691
var key, valueKeyIsRecursive, otherKeyIsRecursive, keyWhy;
3692
for (key in value) {
3693
if (has(value, key)) {
3694
if (!has(other, key)) { return 'first argument has key "' + key + '"; second does not'; }
3695
valueKeyIsRecursive = !!value[key] && value[key][key] === value;
3696
otherKeyIsRecursive = !!other[key] && other[key][key] === other;
3697
if (valueKeyIsRecursive !== otherKeyIsRecursive) {
3698
if (valueKeyIsRecursive) { return 'first argument has a circular reference at key "' + key + '"; second does not'; }
3699
return 'second argument has a circular reference at key "' + key + '"; first does not';
3700
}
3701
if (!valueKeyIsRecursive && !otherKeyIsRecursive) {
3702
keyWhy = whyNotEqual(value[key], other[key]);
3703
if (keyWhy !== '') {
3704
return 'value at key "' + key + '" differs: ' + keyWhy;
3705
}
3706
}
3707
}
3708
}
3709
for (key in other) {
3710
if (has(other, key) && !has(value, key)) {
3711
return 'second argument has key "' + key + '"; first does not';
3712
}
3713
}
3714
return '';
3715
}
3716
3717
return false;
3718
};
3719
3720
3721
/***/ },
3722
/* 21 */
3723
/***/ function(module, exports, __webpack_require__) {
3724
3725
'use strict';
3726
3727
var isCallable = __webpack_require__(22);
3728
var fnToStr = Function.prototype.toString;
3729
var isNonArrowFnRegex = /^\s*function/;
3730
var isArrowFnWithParensRegex = /^\([^\)]*\) *=>/;
3731
var isArrowFnWithoutParensRegex = /^[^=]*=>/;
3732
3733
module.exports = function isArrowFunction(fn) {
3734
if (!isCallable(fn)) { return false; }
3735
var fnStr = fnToStr.call(fn);
3736
return fnStr.length > 0 &&
3737
!isNonArrowFnRegex.test(fnStr) &&
3738
(isArrowFnWithParensRegex.test(fnStr) || isArrowFnWithoutParensRegex.test(fnStr));
3739
};
3740
3741
3742
/***/ },
3743
/* 22 */
3744
/***/ function(module, exports) {
3745
3746
'use strict';
3747
3748
var fnToStr = Function.prototype.toString;
3749
3750
var constructorRegex = /^\s*class /;
3751
var isES6ClassFn = function isES6ClassFn(value) {
3752
try {
3753
var fnStr = fnToStr.call(value);
3754
var singleStripped = fnStr.replace(/\/\/.*\n/g, '');
3755
var multiStripped = singleStripped.replace(/\/\*[.\s\S]*\*\//g, '');
3756
var spaceStripped = multiStripped.replace(/\n/mg, ' ').replace(/ {2}/g, ' ');
3757
return constructorRegex.test(spaceStripped);
3758
} catch (e) {
3759
return false; // not a function
3760
}
3761
};
3762
3763
var tryFunctionObject = function tryFunctionObject(value) {
3764
try {
3765
if (isES6ClassFn(value)) { return false; }
3766
fnToStr.call(value);
3767
return true;
3768
} catch (e) {
3769
return false;
3770
}
3771
};
3772
var toStr = Object.prototype.toString;
3773
var fnClass = '[object Function]';
3774
var genClass = '[object GeneratorFunction]';
3775
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
3776
3777
module.exports = function isCallable(value) {
3778
if (!value) { return false; }
3779
if (typeof value !== 'function' && typeof value !== 'object') { return false; }
3780
if (hasToStringTag) { return tryFunctionObject(value); }
3781
if (isES6ClassFn(value)) { return false; }
3782
var strClass = toStr.call(value);
3783
return strClass === fnClass || strClass === genClass;
3784
};
3785
3786
3787
/***/ },
3788
/* 23 */
3789
/***/ function(module, exports) {
3790
3791
'use strict';
3792
3793
var boolToStr = Boolean.prototype.toString;
3794
3795
var tryBooleanObject = function tryBooleanObject(value) {
3796
try {
3797
boolToStr.call(value);
3798
return true;
3799
} catch (e) {
3800
return false;
3801
}
3802
};
3803
var toStr = Object.prototype.toString;
3804
var boolClass = '[object Boolean]';
3805
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
3806
3807
module.exports = function isBoolean(value) {
3808
if (typeof value === 'boolean') { return true; }
3809
if (typeof value !== 'object') { return false; }
3810
return hasToStringTag ? tryBooleanObject(value) : toStr.call(value) === boolClass;
3811
};
3812
3813
3814
/***/ },
3815
/* 24 */
3816
/***/ function(module, exports) {
3817
3818
'use strict';
3819
3820
var getDay = Date.prototype.getDay;
3821
var tryDateObject = function tryDateObject(value) {
3822
try {
3823
getDay.call(value);
3824
return true;
3825
} catch (e) {
3826
return false;
3827
}
3828
};
3829
3830
var toStr = Object.prototype.toString;
3831
var dateClass = '[object Date]';
3832
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
3833
3834
module.exports = function isDateObject(value) {
3835
if (typeof value !== 'object' || value === null) { return false; }
3836
return hasToStringTag ? tryDateObject(value) : toStr.call(value) === dateClass;
3837
};
3838
3839
3840
/***/ },
3841
/* 25 */
3842
/***/ function(module, exports) {
3843
3844
'use strict';
3845
3846
var toStr = Object.prototype.toString;
3847
var fnToStr = Function.prototype.toString;
3848
var isFnRegex = /^\s*function\*/;
3849
3850
module.exports = function isGeneratorFunction(fn) {
3851
if (typeof fn !== 'function') { return false; }
3852
var fnStr = toStr.call(fn);
3853
return (fnStr === '[object Function]' || fnStr === '[object GeneratorFunction]') && isFnRegex.test(fnToStr.call(fn));
3854
};
3855
3856
3857
3858
/***/ },
3859
/* 26 */
3860
/***/ function(module, exports) {
3861
3862
'use strict';
3863
3864
var numToStr = Number.prototype.toString;
3865
var tryNumberObject = function tryNumberObject(value) {
3866
try {
3867
numToStr.call(value);
3868
return true;
3869
} catch (e) {
3870
return false;
3871
}
3872
};
3873
var toStr = Object.prototype.toString;
3874
var numClass = '[object Number]';
3875
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
3876
3877
module.exports = function isNumberObject(value) {
3878
if (typeof value === 'number') { return true; }
3879
if (typeof value !== 'object') { return false; }
3880
return hasToStringTag ? tryNumberObject(value) : toStr.call(value) === numClass;
3881
};
3882
3883
3884
/***/ },
3885
/* 27 */
3886
/***/ function(module, exports) {
3887
3888
'use strict';
3889
3890
var strValue = String.prototype.valueOf;
3891
var tryStringObject = function tryStringObject(value) {
3892
try {
3893
strValue.call(value);
3894
return true;
3895
} catch (e) {
3896
return false;
3897
}
3898
};
3899
var toStr = Object.prototype.toString;
3900
var strClass = '[object String]';
3901
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
3902
3903
module.exports = function isString(value) {
3904
if (typeof value === 'string') { return true; }
3905
if (typeof value !== 'object') { return false; }
3906
return hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass;
3907
};
3908
3909
3910
/***/ },
3911
/* 28 */
3912
/***/ function(module, exports) {
3913
3914
'use strict';
3915
3916
var toStr = Object.prototype.toString;
3917
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
3918
3919
if (hasSymbols) {
3920
var symToStr = Symbol.prototype.toString;
3921
var symStringRegex = /^Symbol\(.*\)$/;
3922
var isSymbolObject = function isSymbolObject(value) {
3923
if (typeof value.valueOf() !== 'symbol') { return false; }
3924
return symStringRegex.test(symToStr.call(value));
3925
};
3926
module.exports = function isSymbol(value) {
3927
if (typeof value === 'symbol') { return true; }
3928
if (toStr.call(value) !== '[object Symbol]') { return false; }
3929
try {
3930
return isSymbolObject(value);
3931
} catch (e) {
3932
return false;
3933
}
3934
};
3935
} else {
3936
module.exports = function isSymbol(value) {
3937
// this environment does not support Symbols.
3938
return false;
3939
};
3940
}
3941
3942
3943
/***/ },
3944
/* 29 */
3945
/***/ function(module, exports, __webpack_require__) {
3946
3947
'use strict';
3948
3949
var isSymbol = __webpack_require__(28);
3950
3951
module.exports = function getSymbolIterator() {
3952
var symbolIterator = typeof Symbol === 'function' && isSymbol(Symbol.iterator) ? Symbol.iterator : null;
3953
3954
if (typeof Object.getOwnPropertyNames === 'function' && typeof Map === 'function' && typeof Map.prototype.entries === 'function') {
3955
Object.getOwnPropertyNames(Map.prototype).forEach(function (name) {
3956
if (name !== 'entries' && name !== 'size' && Map.prototype[name] === Map.prototype.entries) {
3957
symbolIterator = name;
3958
}
3959
});
3960
}
3961
3962
return symbolIterator;
3963
};
3964
3965
3966
/***/ },
3967
/* 30 */
3968
/***/ function(module, exports) {
3969
3970
'use strict';
3971
3972
module.exports = function () {
3973
var mapForEach = (function () {
3974
if (typeof Map !== 'function') { return null; }
3975
try {
3976
Map.prototype.forEach.call({}, function () {});
3977
} catch (e) {
3978
return Map.prototype.forEach;
3979
}
3980
return null;
3981
}());
3982
3983
var setForEach = (function () {
3984
if (typeof Set !== 'function') { return null; }
3985
try {
3986
Set.prototype.forEach.call({}, function () {});
3987
} catch (e) {
3988
return Set.prototype.forEach;
3989
}
3990
return null;
3991
}());
3992
3993
return { Map: mapForEach, Set: setForEach };
3994
};
3995
3996
3997
/***/ },
3998
/* 31 */
3999
/***/ function(module, exports, __webpack_require__) {
4000
4001
'use strict';
4002
4003
Object.defineProperty(exports, "__esModule", {
4004
value: true
4005
});
4006
4007
var _Expectation = __webpack_require__(1);
4008
4009
var _Expectation2 = _interopRequireDefault(_Expectation);
4010
4011
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
4012
4013
var Extensions = [];
4014
4015
function extend(extension) {
4016
if (Extensions.indexOf(extension) === -1) {
4017
Extensions.push(extension);
4018
4019
for (var p in extension) {
4020
if (extension.hasOwnProperty(p)) _Expectation2.default.prototype[p] = extension[p];
4021
}
4022
}
4023
}
4024
4025
exports.default = extend;
4026
4027
/***/ }
4028
/******/ ])
4029
});
4030
;
4031