1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Qs = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
2 | 'use strict';
|
3 |
|
4 | var replace = String.prototype.replace;
|
5 | var percentTwenties = /%20/g;
|
6 |
|
7 | var Format = {
|
8 | RFC1738: 'RFC1738',
|
9 | RFC3986: 'RFC3986'
|
10 | };
|
11 |
|
12 | module.exports = {
|
13 | 'default': Format.RFC3986,
|
14 | formatters: {
|
15 | RFC1738: function (value) {
|
16 | return replace.call(value, percentTwenties, '+');
|
17 | },
|
18 | RFC3986: function (value) {
|
19 | return String(value);
|
20 | }
|
21 | },
|
22 | RFC1738: Format.RFC1738,
|
23 | RFC3986: Format.RFC3986
|
24 | };
|
25 |
|
26 | },{}],2:[function(require,module,exports){
|
27 | 'use strict';
|
28 |
|
29 | var stringify = require('./stringify');
|
30 | var parse = require('./parse');
|
31 | var formats = require('./formats');
|
32 |
|
33 | module.exports = {
|
34 | formats: formats,
|
35 | parse: parse,
|
36 | stringify: stringify
|
37 | };
|
38 |
|
39 | },{"./formats":1,"./parse":3,"./stringify":4}],3:[function(require,module,exports){
|
40 | 'use strict';
|
41 |
|
42 | var utils = require('./utils');
|
43 |
|
44 | var has = Object.prototype.hasOwnProperty;
|
45 | var isArray = Array.isArray;
|
46 |
|
47 | var defaults = {
|
48 | allowDots: false,
|
49 | allowPrototypes: false,
|
50 | allowSparse: false,
|
51 | arrayLimit: 20,
|
52 | charset: 'utf-8',
|
53 | charsetSentinel: false,
|
54 | comma: false,
|
55 | decoder: utils.decode,
|
56 | delimiter: '&',
|
57 | depth: 5,
|
58 | ignoreQueryPrefix: false,
|
59 | interpretNumericEntities: false,
|
60 | parameterLimit: 1000,
|
61 | parseArrays: true,
|
62 | plainObjects: false,
|
63 | strictNullHandling: false
|
64 | };
|
65 |
|
66 | var interpretNumericEntities = function (str) {
|
67 | return str.replace(/&#(\d+);/g, function ($0, numberStr) {
|
68 | return String.fromCharCode(parseInt(numberStr, 10));
|
69 | });
|
70 | };
|
71 |
|
72 | var parseArrayValue = function (val, options) {
|
73 | if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
|
74 | return val.split(',');
|
75 | }
|
76 |
|
77 | return val;
|
78 | };
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 | var isoSentinel = 'utf8=%26%2310003%3B';
|
86 |
|
87 |
|
88 | var charsetSentinel = 'utf8=%E2%9C%93';
|
89 |
|
90 | var parseValues = function parseQueryStringValues(str, options) {
|
91 | var obj = {};
|
92 | var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
|
93 | var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
|
94 | var parts = cleanStr.split(options.delimiter, limit);
|
95 | var skipIndex = -1;
|
96 | var i;
|
97 |
|
98 | var charset = options.charset;
|
99 | if (options.charsetSentinel) {
|
100 | for (i = 0; i < parts.length; ++i) {
|
101 | if (parts[i].indexOf('utf8=') === 0) {
|
102 | if (parts[i] === charsetSentinel) {
|
103 | charset = 'utf-8';
|
104 | } else if (parts[i] === isoSentinel) {
|
105 | charset = 'iso-8859-1';
|
106 | }
|
107 | skipIndex = i;
|
108 | i = parts.length;
|
109 | }
|
110 | }
|
111 | }
|
112 |
|
113 | for (i = 0; i < parts.length; ++i) {
|
114 | if (i === skipIndex) {
|
115 | continue;
|
116 | }
|
117 | var part = parts[i];
|
118 |
|
119 | var bracketEqualsPos = part.indexOf(']=');
|
120 | var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
|
121 |
|
122 | var key, val;
|
123 | if (pos === -1) {
|
124 | key = options.decoder(part, defaults.decoder, charset, 'key');
|
125 | val = options.strictNullHandling ? null : '';
|
126 | } else {
|
127 | key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key');
|
128 | val = utils.maybeMap(
|
129 | parseArrayValue(part.slice(pos + 1), options),
|
130 | function (encodedVal) {
|
131 | return options.decoder(encodedVal, defaults.decoder, charset, 'value');
|
132 | }
|
133 | );
|
134 | }
|
135 |
|
136 | if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
|
137 | val = interpretNumericEntities(val);
|
138 | }
|
139 |
|
140 | if (part.indexOf('[]=') > -1) {
|
141 | val = isArray(val) ? [val] : val;
|
142 | }
|
143 |
|
144 | if (has.call(obj, key)) {
|
145 | obj[key] = utils.combine(obj[key], val);
|
146 | } else {
|
147 | obj[key] = val;
|
148 | }
|
149 | }
|
150 |
|
151 | return obj;
|
152 | };
|
153 |
|
154 | var parseObject = function (chain, val, options, valuesParsed) {
|
155 | var leaf = valuesParsed ? val : parseArrayValue(val, options);
|
156 |
|
157 | for (var i = chain.length - 1; i >= 0; --i) {
|
158 | var obj;
|
159 | var root = chain[i];
|
160 |
|
161 | if (root === '[]' && options.parseArrays) {
|
162 | obj = [].concat(leaf);
|
163 | } else {
|
164 | obj = options.plainObjects ? Object.create(null) : {};
|
165 | var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
|
166 | var index = parseInt(cleanRoot, 10);
|
167 | if (!options.parseArrays && cleanRoot === '') {
|
168 | obj = { 0: leaf };
|
169 | } else if (
|
170 | !isNaN(index)
|
171 | && root !== cleanRoot
|
172 | && String(index) === cleanRoot
|
173 | && index >= 0
|
174 | && (options.parseArrays && index <= options.arrayLimit)
|
175 | ) {
|
176 | obj = [];
|
177 | obj[index] = leaf;
|
178 | } else {
|
179 | obj[cleanRoot] = leaf;
|
180 | }
|
181 | }
|
182 |
|
183 | leaf = obj;
|
184 | }
|
185 |
|
186 | return leaf;
|
187 | };
|
188 |
|
189 | var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
|
190 | if (!givenKey) {
|
191 | return;
|
192 | }
|
193 |
|
194 |
|
195 | var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
|
196 |
|
197 |
|
198 |
|
199 | var brackets = /(\[[^[\]]*])/;
|
200 | var child = /(\[[^[\]]*])/g;
|
201 |
|
202 |
|
203 |
|
204 | var segment = options.depth > 0 && brackets.exec(key);
|
205 | var parent = segment ? key.slice(0, segment.index) : key;
|
206 |
|
207 |
|
208 |
|
209 | var keys = [];
|
210 | if (parent) {
|
211 |
|
212 | if (!options.plainObjects && has.call(Object.prototype, parent)) {
|
213 | if (!options.allowPrototypes) {
|
214 | return;
|
215 | }
|
216 | }
|
217 |
|
218 | keys.push(parent);
|
219 | }
|
220 |
|
221 |
|
222 |
|
223 | var i = 0;
|
224 | while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
|
225 | i += 1;
|
226 | if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
|
227 | if (!options.allowPrototypes) {
|
228 | return;
|
229 | }
|
230 | }
|
231 | keys.push(segment[1]);
|
232 | }
|
233 |
|
234 |
|
235 |
|
236 | if (segment) {
|
237 | keys.push('[' + key.slice(segment.index) + ']');
|
238 | }
|
239 |
|
240 | return parseObject(keys, val, options, valuesParsed);
|
241 | };
|
242 |
|
243 | var normalizeParseOptions = function normalizeParseOptions(opts) {
|
244 | if (!opts) {
|
245 | return defaults;
|
246 | }
|
247 |
|
248 | if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
|
249 | throw new TypeError('Decoder has to be a function.');
|
250 | }
|
251 |
|
252 | if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
253 | throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
|
254 | }
|
255 | var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
|
256 |
|
257 | return {
|
258 | allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
|
259 | allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
|
260 | allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,
|
261 | arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
|
262 | charset: charset,
|
263 | charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
|
264 | comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
|
265 | decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
|
266 | delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
|
267 |
|
268 | depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth,
|
269 | ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
|
270 | interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
|
271 | parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
|
272 | parseArrays: opts.parseArrays !== false,
|
273 | plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
|
274 | strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
|
275 | };
|
276 | };
|
277 |
|
278 | module.exports = function (str, opts) {
|
279 | var options = normalizeParseOptions(opts);
|
280 |
|
281 | if (str === '' || str === null || typeof str === 'undefined') {
|
282 | return options.plainObjects ? Object.create(null) : {};
|
283 | }
|
284 |
|
285 | var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
|
286 | var obj = options.plainObjects ? Object.create(null) : {};
|
287 |
|
288 |
|
289 |
|
290 | var keys = Object.keys(tempObj);
|
291 | for (var i = 0; i < keys.length; ++i) {
|
292 | var key = keys[i];
|
293 | var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
|
294 | obj = utils.merge(obj, newObj, options);
|
295 | }
|
296 |
|
297 | if (options.allowSparse === true) {
|
298 | return obj;
|
299 | }
|
300 |
|
301 | return utils.compact(obj);
|
302 | };
|
303 |
|
304 | },{"./utils":5}],4:[function(require,module,exports){
|
305 | 'use strict';
|
306 |
|
307 | var getSideChannel = require('side-channel');
|
308 | var utils = require('./utils');
|
309 | var formats = require('./formats');
|
310 | var has = Object.prototype.hasOwnProperty;
|
311 |
|
312 | var arrayPrefixGenerators = {
|
313 | brackets: function brackets(prefix) {
|
314 | return prefix + '[]';
|
315 | },
|
316 | comma: 'comma',
|
317 | indices: function indices(prefix, key) {
|
318 | return prefix + '[' + key + ']';
|
319 | },
|
320 | repeat: function repeat(prefix) {
|
321 | return prefix;
|
322 | }
|
323 | };
|
324 |
|
325 | var isArray = Array.isArray;
|
326 | var push = Array.prototype.push;
|
327 | var pushToArray = function (arr, valueOrArray) {
|
328 | push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
|
329 | };
|
330 |
|
331 | var toISO = Date.prototype.toISOString;
|
332 |
|
333 | var defaultFormat = formats['default'];
|
334 | var defaults = {
|
335 | addQueryPrefix: false,
|
336 | allowDots: false,
|
337 | charset: 'utf-8',
|
338 | charsetSentinel: false,
|
339 | delimiter: '&',
|
340 | encode: true,
|
341 | encoder: utils.encode,
|
342 | encodeValuesOnly: false,
|
343 | format: defaultFormat,
|
344 | formatter: formats.formatters[defaultFormat],
|
345 |
|
346 | indices: false,
|
347 | serializeDate: function serializeDate(date) {
|
348 | return toISO.call(date);
|
349 | },
|
350 | skipNulls: false,
|
351 | strictNullHandling: false
|
352 | };
|
353 |
|
354 | var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
|
355 | return typeof v === 'string'
|
356 | || typeof v === 'number'
|
357 | || typeof v === 'boolean'
|
358 | || typeof v === 'symbol'
|
359 | || typeof v === 'bigint';
|
360 | };
|
361 |
|
362 | var stringify = function stringify(
|
363 | object,
|
364 | prefix,
|
365 | generateArrayPrefix,
|
366 | strictNullHandling,
|
367 | skipNulls,
|
368 | encoder,
|
369 | filter,
|
370 | sort,
|
371 | allowDots,
|
372 | serializeDate,
|
373 | format,
|
374 | formatter,
|
375 | encodeValuesOnly,
|
376 | charset,
|
377 | sideChannel
|
378 | ) {
|
379 | var obj = object;
|
380 |
|
381 | if (sideChannel.has(object)) {
|
382 | throw new RangeError('Cyclic object value');
|
383 | }
|
384 |
|
385 | if (typeof filter === 'function') {
|
386 | obj = filter(prefix, obj);
|
387 | } else if (obj instanceof Date) {
|
388 | obj = serializeDate(obj);
|
389 | } else if (generateArrayPrefix === 'comma' && isArray(obj)) {
|
390 | obj = utils.maybeMap(obj, function (value) {
|
391 | if (value instanceof Date) {
|
392 | return serializeDate(value);
|
393 | }
|
394 | return value;
|
395 | });
|
396 | }
|
397 |
|
398 | if (obj === null) {
|
399 | if (strictNullHandling) {
|
400 | return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix;
|
401 | }
|
402 |
|
403 | obj = '';
|
404 | }
|
405 |
|
406 | if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
|
407 | if (encoder) {
|
408 | var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key', format);
|
409 | return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];
|
410 | }
|
411 | return [formatter(prefix) + '=' + formatter(String(obj))];
|
412 | }
|
413 |
|
414 | var values = [];
|
415 |
|
416 | if (typeof obj === 'undefined') {
|
417 | return values;
|
418 | }
|
419 |
|
420 | var objKeys;
|
421 | if (generateArrayPrefix === 'comma' && isArray(obj)) {
|
422 |
|
423 | objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : undefined }];
|
424 | } else if (isArray(filter)) {
|
425 | objKeys = filter;
|
426 | } else {
|
427 | var keys = Object.keys(obj);
|
428 | objKeys = sort ? keys.sort(sort) : keys;
|
429 | }
|
430 |
|
431 | for (var i = 0; i < objKeys.length; ++i) {
|
432 | var key = objKeys[i];
|
433 | var value = typeof key === 'object' && key.value !== undefined ? key.value : obj[key];
|
434 |
|
435 | if (skipNulls && value === null) {
|
436 | continue;
|
437 | }
|
438 |
|
439 | var keyPrefix = isArray(obj)
|
440 | ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix
|
441 | : prefix + (allowDots ? '.' + key : '[' + key + ']');
|
442 |
|
443 | sideChannel.set(object, true);
|
444 | pushToArray(values, stringify(
|
445 | value,
|
446 | keyPrefix,
|
447 | generateArrayPrefix,
|
448 | strictNullHandling,
|
449 | skipNulls,
|
450 | encoder,
|
451 | filter,
|
452 | sort,
|
453 | allowDots,
|
454 | serializeDate,
|
455 | format,
|
456 | formatter,
|
457 | encodeValuesOnly,
|
458 | charset,
|
459 | sideChannel
|
460 | ));
|
461 | }
|
462 |
|
463 | return values;
|
464 | };
|
465 |
|
466 | var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
|
467 | if (!opts) {
|
468 | return defaults;
|
469 | }
|
470 |
|
471 | if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
|
472 | throw new TypeError('Encoder has to be a function.');
|
473 | }
|
474 |
|
475 | var charset = opts.charset || defaults.charset;
|
476 | if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
477 | throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
|
478 | }
|
479 |
|
480 | var format = formats['default'];
|
481 | if (typeof opts.format !== 'undefined') {
|
482 | if (!has.call(formats.formatters, opts.format)) {
|
483 | throw new TypeError('Unknown format option provided.');
|
484 | }
|
485 | format = opts.format;
|
486 | }
|
487 | var formatter = formats.formatters[format];
|
488 |
|
489 | var filter = defaults.filter;
|
490 | if (typeof opts.filter === 'function' || isArray(opts.filter)) {
|
491 | filter = opts.filter;
|
492 | }
|
493 |
|
494 | return {
|
495 | addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
|
496 | allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
|
497 | charset: charset,
|
498 | charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
|
499 | delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
|
500 | encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
|
501 | encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
|
502 | encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
|
503 | filter: filter,
|
504 | format: format,
|
505 | formatter: formatter,
|
506 | serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,
|
507 | skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,
|
508 | sort: typeof opts.sort === 'function' ? opts.sort : null,
|
509 | strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
|
510 | };
|
511 | };
|
512 |
|
513 | module.exports = function (object, opts) {
|
514 | var obj = object;
|
515 | var options = normalizeStringifyOptions(opts);
|
516 |
|
517 | var objKeys;
|
518 | var filter;
|
519 |
|
520 | if (typeof options.filter === 'function') {
|
521 | filter = options.filter;
|
522 | obj = filter('', obj);
|
523 | } else if (isArray(options.filter)) {
|
524 | filter = options.filter;
|
525 | objKeys = filter;
|
526 | }
|
527 |
|
528 | var keys = [];
|
529 |
|
530 | if (typeof obj !== 'object' || obj === null) {
|
531 | return '';
|
532 | }
|
533 |
|
534 | var arrayFormat;
|
535 | if (opts && opts.arrayFormat in arrayPrefixGenerators) {
|
536 | arrayFormat = opts.arrayFormat;
|
537 | } else if (opts && 'indices' in opts) {
|
538 | arrayFormat = opts.indices ? 'indices' : 'repeat';
|
539 | } else {
|
540 | arrayFormat = 'indices';
|
541 | }
|
542 |
|
543 | var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
|
544 |
|
545 | if (!objKeys) {
|
546 | objKeys = Object.keys(obj);
|
547 | }
|
548 |
|
549 | if (options.sort) {
|
550 | objKeys.sort(options.sort);
|
551 | }
|
552 |
|
553 | var sideChannel = getSideChannel();
|
554 | for (var i = 0; i < objKeys.length; ++i) {
|
555 | var key = objKeys[i];
|
556 |
|
557 | if (options.skipNulls && obj[key] === null) {
|
558 | continue;
|
559 | }
|
560 | pushToArray(keys, stringify(
|
561 | obj[key],
|
562 | key,
|
563 | generateArrayPrefix,
|
564 | options.strictNullHandling,
|
565 | options.skipNulls,
|
566 | options.encode ? options.encoder : null,
|
567 | options.filter,
|
568 | options.sort,
|
569 | options.allowDots,
|
570 | options.serializeDate,
|
571 | options.format,
|
572 | options.formatter,
|
573 | options.encodeValuesOnly,
|
574 | options.charset,
|
575 | sideChannel
|
576 | ));
|
577 | }
|
578 |
|
579 | var joined = keys.join(options.delimiter);
|
580 | var prefix = options.addQueryPrefix === true ? '?' : '';
|
581 |
|
582 | if (options.charsetSentinel) {
|
583 | if (options.charset === 'iso-8859-1') {
|
584 |
|
585 | prefix += 'utf8=%26%2310003%3B&';
|
586 | } else {
|
587 |
|
588 | prefix += 'utf8=%E2%9C%93&';
|
589 | }
|
590 | }
|
591 |
|
592 | return joined.length > 0 ? prefix + joined : '';
|
593 | };
|
594 |
|
595 | },{"./formats":1,"./utils":5,"side-channel":16}],5:[function(require,module,exports){
|
596 | 'use strict';
|
597 |
|
598 | var formats = require('./formats');
|
599 |
|
600 | var has = Object.prototype.hasOwnProperty;
|
601 | var isArray = Array.isArray;
|
602 |
|
603 | var hexTable = (function () {
|
604 | var array = [];
|
605 | for (var i = 0; i < 256; ++i) {
|
606 | array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
607 | }
|
608 |
|
609 | return array;
|
610 | }());
|
611 |
|
612 | var compactQueue = function compactQueue(queue) {
|
613 | while (queue.length > 1) {
|
614 | var item = queue.pop();
|
615 | var obj = item.obj[item.prop];
|
616 |
|
617 | if (isArray(obj)) {
|
618 | var compacted = [];
|
619 |
|
620 | for (var j = 0; j < obj.length; ++j) {
|
621 | if (typeof obj[j] !== 'undefined') {
|
622 | compacted.push(obj[j]);
|
623 | }
|
624 | }
|
625 |
|
626 | item.obj[item.prop] = compacted;
|
627 | }
|
628 | }
|
629 | };
|
630 |
|
631 | var arrayToObject = function arrayToObject(source, options) {
|
632 | var obj = options && options.plainObjects ? Object.create(null) : {};
|
633 | for (var i = 0; i < source.length; ++i) {
|
634 | if (typeof source[i] !== 'undefined') {
|
635 | obj[i] = source[i];
|
636 | }
|
637 | }
|
638 |
|
639 | return obj;
|
640 | };
|
641 |
|
642 | var merge = function merge(target, source, options) {
|
643 |
|
644 | if (!source) {
|
645 | return target;
|
646 | }
|
647 |
|
648 | if (typeof source !== 'object') {
|
649 | if (isArray(target)) {
|
650 | target.push(source);
|
651 | } else if (target && typeof target === 'object') {
|
652 | if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
|
653 | target[source] = true;
|
654 | }
|
655 | } else {
|
656 | return [target, source];
|
657 | }
|
658 |
|
659 | return target;
|
660 | }
|
661 |
|
662 | if (!target || typeof target !== 'object') {
|
663 | return [target].concat(source);
|
664 | }
|
665 |
|
666 | var mergeTarget = target;
|
667 | if (isArray(target) && !isArray(source)) {
|
668 | mergeTarget = arrayToObject(target, options);
|
669 | }
|
670 |
|
671 | if (isArray(target) && isArray(source)) {
|
672 | source.forEach(function (item, i) {
|
673 | if (has.call(target, i)) {
|
674 | var targetItem = target[i];
|
675 | if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
676 | target[i] = merge(targetItem, item, options);
|
677 | } else {
|
678 | target.push(item);
|
679 | }
|
680 | } else {
|
681 | target[i] = item;
|
682 | }
|
683 | });
|
684 | return target;
|
685 | }
|
686 |
|
687 | return Object.keys(source).reduce(function (acc, key) {
|
688 | var value = source[key];
|
689 |
|
690 | if (has.call(acc, key)) {
|
691 | acc[key] = merge(acc[key], value, options);
|
692 | } else {
|
693 | acc[key] = value;
|
694 | }
|
695 | return acc;
|
696 | }, mergeTarget);
|
697 | };
|
698 |
|
699 | var assign = function assignSingleSource(target, source) {
|
700 | return Object.keys(source).reduce(function (acc, key) {
|
701 | acc[key] = source[key];
|
702 | return acc;
|
703 | }, target);
|
704 | };
|
705 |
|
706 | var decode = function (str, decoder, charset) {
|
707 | var strWithoutPlus = str.replace(/\+/g, ' ');
|
708 | if (charset === 'iso-8859-1') {
|
709 |
|
710 | return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
711 | }
|
712 |
|
713 | try {
|
714 | return decodeURIComponent(strWithoutPlus);
|
715 | } catch (e) {
|
716 | return strWithoutPlus;
|
717 | }
|
718 | };
|
719 |
|
720 | var encode = function encode(str, defaultEncoder, charset, kind, format) {
|
721 |
|
722 |
|
723 | if (str.length === 0) {
|
724 | return str;
|
725 | }
|
726 |
|
727 | var string = str;
|
728 | if (typeof str === 'symbol') {
|
729 | string = Symbol.prototype.toString.call(str);
|
730 | } else if (typeof str !== 'string') {
|
731 | string = String(str);
|
732 | }
|
733 |
|
734 | if (charset === 'iso-8859-1') {
|
735 | return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
736 | return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
737 | });
|
738 | }
|
739 |
|
740 | var out = '';
|
741 | for (var i = 0; i < string.length; ++i) {
|
742 | var c = string.charCodeAt(i);
|
743 |
|
744 | if (
|
745 | c === 0x2D
|
746 | || c === 0x2E
|
747 | || c === 0x5F
|
748 | || c === 0x7E
|
749 | || (c >= 0x30 && c <= 0x39)
|
750 | || (c >= 0x41 && c <= 0x5A)
|
751 | || (c >= 0x61 && c <= 0x7A)
|
752 | || (format === formats.RFC1738 && (c === 0x28 || c === 0x29))
|
753 | ) {
|
754 | out += string.charAt(i);
|
755 | continue;
|
756 | }
|
757 |
|
758 | if (c < 0x80) {
|
759 | out = out + hexTable[c];
|
760 | continue;
|
761 | }
|
762 |
|
763 | if (c < 0x800) {
|
764 | out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
|
765 | continue;
|
766 | }
|
767 |
|
768 | if (c < 0xD800 || c >= 0xE000) {
|
769 | out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
|
770 | continue;
|
771 | }
|
772 |
|
773 | i += 1;
|
774 | c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
|
775 | out += hexTable[0xF0 | (c >> 18)]
|
776 | + hexTable[0x80 | ((c >> 12) & 0x3F)]
|
777 | + hexTable[0x80 | ((c >> 6) & 0x3F)]
|
778 | + hexTable[0x80 | (c & 0x3F)];
|
779 | }
|
780 |
|
781 | return out;
|
782 | };
|
783 |
|
784 | var compact = function compact(value) {
|
785 | var queue = [{ obj: { o: value }, prop: 'o' }];
|
786 | var refs = [];
|
787 |
|
788 | for (var i = 0; i < queue.length; ++i) {
|
789 | var item = queue[i];
|
790 | var obj = item.obj[item.prop];
|
791 |
|
792 | var keys = Object.keys(obj);
|
793 | for (var j = 0; j < keys.length; ++j) {
|
794 | var key = keys[j];
|
795 | var val = obj[key];
|
796 | if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
797 | queue.push({ obj: obj, prop: key });
|
798 | refs.push(val);
|
799 | }
|
800 | }
|
801 | }
|
802 |
|
803 | compactQueue(queue);
|
804 |
|
805 | return value;
|
806 | };
|
807 |
|
808 | var isRegExp = function isRegExp(obj) {
|
809 | return Object.prototype.toString.call(obj) === '[object RegExp]';
|
810 | };
|
811 |
|
812 | var isBuffer = function isBuffer(obj) {
|
813 | if (!obj || typeof obj !== 'object') {
|
814 | return false;
|
815 | }
|
816 |
|
817 | return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
818 | };
|
819 |
|
820 | var combine = function combine(a, b) {
|
821 | return [].concat(a, b);
|
822 | };
|
823 |
|
824 | var maybeMap = function maybeMap(val, fn) {
|
825 | if (isArray(val)) {
|
826 | var mapped = [];
|
827 | for (var i = 0; i < val.length; i += 1) {
|
828 | mapped.push(fn(val[i]));
|
829 | }
|
830 | return mapped;
|
831 | }
|
832 | return fn(val);
|
833 | };
|
834 |
|
835 | module.exports = {
|
836 | arrayToObject: arrayToObject,
|
837 | assign: assign,
|
838 | combine: combine,
|
839 | compact: compact,
|
840 | decode: decode,
|
841 | encode: encode,
|
842 | isBuffer: isBuffer,
|
843 | isRegExp: isRegExp,
|
844 | maybeMap: maybeMap,
|
845 | merge: merge
|
846 | };
|
847 |
|
848 | },{"./formats":1}],6:[function(require,module,exports){
|
849 |
|
850 | },{}],7:[function(require,module,exports){
|
851 | 'use strict';
|
852 |
|
853 | var GetIntrinsic = require('get-intrinsic');
|
854 |
|
855 | var callBind = require('./');
|
856 |
|
857 | var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
|
858 |
|
859 | module.exports = function callBoundIntrinsic(name, allowMissing) {
|
860 | var intrinsic = GetIntrinsic(name, !!allowMissing);
|
861 | if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
|
862 | return callBind(intrinsic);
|
863 | }
|
864 | return intrinsic;
|
865 | };
|
866 |
|
867 | },{"./":8,"get-intrinsic":11}],8:[function(require,module,exports){
|
868 | 'use strict';
|
869 |
|
870 | var bind = require('function-bind');
|
871 | var GetIntrinsic = require('get-intrinsic');
|
872 |
|
873 | var $apply = GetIntrinsic('%Function.prototype.apply%');
|
874 | var $call = GetIntrinsic('%Function.prototype.call%');
|
875 | var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
|
876 |
|
877 | var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
|
878 | var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
|
879 | var $max = GetIntrinsic('%Math.max%');
|
880 |
|
881 | if ($defineProperty) {
|
882 | try {
|
883 | $defineProperty({}, 'a', { value: 1 });
|
884 | } catch (e) {
|
885 |
|
886 | $defineProperty = null;
|
887 | }
|
888 | }
|
889 |
|
890 | module.exports = function callBind(originalFunction) {
|
891 | var func = $reflectApply(bind, $call, arguments);
|
892 | if ($gOPD && $defineProperty) {
|
893 | var desc = $gOPD(func, 'length');
|
894 | if (desc.configurable) {
|
895 |
|
896 | $defineProperty(
|
897 | func,
|
898 | 'length',
|
899 | { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) }
|
900 | );
|
901 | }
|
902 | }
|
903 | return func;
|
904 | };
|
905 |
|
906 | var applyBind = function applyBind() {
|
907 | return $reflectApply(bind, $apply, arguments);
|
908 | };
|
909 |
|
910 | if ($defineProperty) {
|
911 | $defineProperty(module.exports, 'apply', { value: applyBind });
|
912 | } else {
|
913 | module.exports.apply = applyBind;
|
914 | }
|
915 |
|
916 | },{"function-bind":10,"get-intrinsic":11}],9:[function(require,module,exports){
|
917 | 'use strict';
|
918 |
|
919 |
|
920 |
|
921 | var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
|
922 | var slice = Array.prototype.slice;
|
923 | var toStr = Object.prototype.toString;
|
924 | var funcType = '[object Function]';
|
925 |
|
926 | module.exports = function bind(that) {
|
927 | var target = this;
|
928 | if (typeof target !== 'function' || toStr.call(target) !== funcType) {
|
929 | throw new TypeError(ERROR_MESSAGE + target);
|
930 | }
|
931 | var args = slice.call(arguments, 1);
|
932 |
|
933 | var bound;
|
934 | var binder = function () {
|
935 | if (this instanceof bound) {
|
936 | var result = target.apply(
|
937 | this,
|
938 | args.concat(slice.call(arguments))
|
939 | );
|
940 | if (Object(result) === result) {
|
941 | return result;
|
942 | }
|
943 | return this;
|
944 | } else {
|
945 | return target.apply(
|
946 | that,
|
947 | args.concat(slice.call(arguments))
|
948 | );
|
949 | }
|
950 | };
|
951 |
|
952 | var boundLength = Math.max(0, target.length - args.length);
|
953 | var boundArgs = [];
|
954 | for (var i = 0; i < boundLength; i++) {
|
955 | boundArgs.push('$' + i);
|
956 | }
|
957 |
|
958 | bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
|
959 |
|
960 | if (target.prototype) {
|
961 | var Empty = function Empty() {};
|
962 | Empty.prototype = target.prototype;
|
963 | bound.prototype = new Empty();
|
964 | Empty.prototype = null;
|
965 | }
|
966 |
|
967 | return bound;
|
968 | };
|
969 |
|
970 | },{}],10:[function(require,module,exports){
|
971 | 'use strict';
|
972 |
|
973 | var implementation = require('./implementation');
|
974 |
|
975 | module.exports = Function.prototype.bind || implementation;
|
976 |
|
977 | },{"./implementation":9}],11:[function(require,module,exports){
|
978 | 'use strict';
|
979 |
|
980 | var undefined;
|
981 |
|
982 | var $SyntaxError = SyntaxError;
|
983 | var $Function = Function;
|
984 | var $TypeError = TypeError;
|
985 |
|
986 |
|
987 | var getEvalledConstructor = function (expressionSyntax) {
|
988 | try {
|
989 | return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
|
990 | } catch (e) {}
|
991 | };
|
992 |
|
993 | var $gOPD = Object.getOwnPropertyDescriptor;
|
994 | if ($gOPD) {
|
995 | try {
|
996 | $gOPD({}, '');
|
997 | } catch (e) {
|
998 | $gOPD = null;
|
999 | }
|
1000 | }
|
1001 |
|
1002 | var throwTypeError = function () {
|
1003 | throw new $TypeError();
|
1004 | };
|
1005 | var ThrowTypeError = $gOPD
|
1006 | ? (function () {
|
1007 | try {
|
1008 |
|
1009 | arguments.callee;
|
1010 | return throwTypeError;
|
1011 | } catch (calleeThrows) {
|
1012 | try {
|
1013 |
|
1014 | return $gOPD(arguments, 'callee').get;
|
1015 | } catch (gOPDthrows) {
|
1016 | return throwTypeError;
|
1017 | }
|
1018 | }
|
1019 | }())
|
1020 | : throwTypeError;
|
1021 |
|
1022 | var hasSymbols = require('has-symbols')();
|
1023 |
|
1024 | var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; };
|
1025 |
|
1026 | var needsEval = {};
|
1027 |
|
1028 | var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
|
1029 |
|
1030 | var INTRINSICS = {
|
1031 | '%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError,
|
1032 | '%Array%': Array,
|
1033 | '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
|
1034 | '%ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined,
|
1035 | '%AsyncFromSyncIteratorPrototype%': undefined,
|
1036 | '%AsyncFunction%': needsEval,
|
1037 | '%AsyncGenerator%': needsEval,
|
1038 | '%AsyncGeneratorFunction%': needsEval,
|
1039 | '%AsyncIteratorPrototype%': needsEval,
|
1040 | '%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
|
1041 | '%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt,
|
1042 | '%Boolean%': Boolean,
|
1043 | '%DataView%': typeof DataView === 'undefined' ? undefined : DataView,
|
1044 | '%Date%': Date,
|
1045 | '%decodeURI%': decodeURI,
|
1046 | '%decodeURIComponent%': decodeURIComponent,
|
1047 | '%encodeURI%': encodeURI,
|
1048 | '%encodeURIComponent%': encodeURIComponent,
|
1049 | '%Error%': Error,
|
1050 | '%eval%': eval,
|
1051 | '%EvalError%': EvalError,
|
1052 | '%Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,
|
1053 | '%Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,
|
1054 | '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined : FinalizationRegistry,
|
1055 | '%Function%': $Function,
|
1056 | '%GeneratorFunction%': needsEval,
|
1057 | '%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,
|
1058 | '%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,
|
1059 | '%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
|
1060 | '%isFinite%': isFinite,
|
1061 | '%isNaN%': isNaN,
|
1062 | '%IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
|
1063 | '%JSON%': typeof JSON === 'object' ? JSON : undefined,
|
1064 | '%Map%': typeof Map === 'undefined' ? undefined : Map,
|
1065 | '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
|
1066 | '%Math%': Math,
|
1067 | '%Number%': Number,
|
1068 | '%Object%': Object,
|
1069 | '%parseFloat%': parseFloat,
|
1070 | '%parseInt%': parseInt,
|
1071 | '%Promise%': typeof Promise === 'undefined' ? undefined : Promise,
|
1072 | '%Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,
|
1073 | '%RangeError%': RangeError,
|
1074 | '%ReferenceError%': ReferenceError,
|
1075 | '%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
|
1076 | '%RegExp%': RegExp,
|
1077 | '%Set%': typeof Set === 'undefined' ? undefined : Set,
|
1078 | '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()),
|
1079 | '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
|
1080 | '%String%': String,
|
1081 | '%StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined,
|
1082 | '%Symbol%': hasSymbols ? Symbol : undefined,
|
1083 | '%SyntaxError%': $SyntaxError,
|
1084 | '%ThrowTypeError%': ThrowTypeError,
|
1085 | '%TypedArray%': TypedArray,
|
1086 | '%TypeError%': $TypeError,
|
1087 | '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,
|
1088 | '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,
|
1089 | '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,
|
1090 | '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,
|
1091 | '%URIError%': URIError,
|
1092 | '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
|
1093 | '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef,
|
1094 | '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet
|
1095 | };
|
1096 |
|
1097 | var doEval = function doEval(name) {
|
1098 | var value;
|
1099 | if (name === '%AsyncFunction%') {
|
1100 | value = getEvalledConstructor('async function () {}');
|
1101 | } else if (name === '%GeneratorFunction%') {
|
1102 | value = getEvalledConstructor('function* () {}');
|
1103 | } else if (name === '%AsyncGeneratorFunction%') {
|
1104 | value = getEvalledConstructor('async function* () {}');
|
1105 | } else if (name === '%AsyncGenerator%') {
|
1106 | var fn = doEval('%AsyncGeneratorFunction%');
|
1107 | if (fn) {
|
1108 | value = fn.prototype;
|
1109 | }
|
1110 | } else if (name === '%AsyncIteratorPrototype%') {
|
1111 | var gen = doEval('%AsyncGenerator%');
|
1112 | if (gen) {
|
1113 | value = getProto(gen.prototype);
|
1114 | }
|
1115 | }
|
1116 |
|
1117 | INTRINSICS[name] = value;
|
1118 |
|
1119 | return value;
|
1120 | };
|
1121 |
|
1122 | var LEGACY_ALIASES = {
|
1123 | '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
|
1124 | '%ArrayPrototype%': ['Array', 'prototype'],
|
1125 | '%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
|
1126 | '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
|
1127 | '%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
|
1128 | '%ArrayProto_values%': ['Array', 'prototype', 'values'],
|
1129 | '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
|
1130 | '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
|
1131 | '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
|
1132 | '%BooleanPrototype%': ['Boolean', 'prototype'],
|
1133 | '%DataViewPrototype%': ['DataView', 'prototype'],
|
1134 | '%DatePrototype%': ['Date', 'prototype'],
|
1135 | '%ErrorPrototype%': ['Error', 'prototype'],
|
1136 | '%EvalErrorPrototype%': ['EvalError', 'prototype'],
|
1137 | '%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
|
1138 | '%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
|
1139 | '%FunctionPrototype%': ['Function', 'prototype'],
|
1140 | '%Generator%': ['GeneratorFunction', 'prototype'],
|
1141 | '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
|
1142 | '%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
|
1143 | '%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
|
1144 | '%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
|
1145 | '%JSONParse%': ['JSON', 'parse'],
|
1146 | '%JSONStringify%': ['JSON', 'stringify'],
|
1147 | '%MapPrototype%': ['Map', 'prototype'],
|
1148 | '%NumberPrototype%': ['Number', 'prototype'],
|
1149 | '%ObjectPrototype%': ['Object', 'prototype'],
|
1150 | '%ObjProto_toString%': ['Object', 'prototype', 'toString'],
|
1151 | '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
|
1152 | '%PromisePrototype%': ['Promise', 'prototype'],
|
1153 | '%PromiseProto_then%': ['Promise', 'prototype', 'then'],
|
1154 | '%Promise_all%': ['Promise', 'all'],
|
1155 | '%Promise_reject%': ['Promise', 'reject'],
|
1156 | '%Promise_resolve%': ['Promise', 'resolve'],
|
1157 | '%RangeErrorPrototype%': ['RangeError', 'prototype'],
|
1158 | '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
|
1159 | '%RegExpPrototype%': ['RegExp', 'prototype'],
|
1160 | '%SetPrototype%': ['Set', 'prototype'],
|
1161 | '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
|
1162 | '%StringPrototype%': ['String', 'prototype'],
|
1163 | '%SymbolPrototype%': ['Symbol', 'prototype'],
|
1164 | '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
|
1165 | '%TypedArrayPrototype%': ['TypedArray', 'prototype'],
|
1166 | '%TypeErrorPrototype%': ['TypeError', 'prototype'],
|
1167 | '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
|
1168 | '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
|
1169 | '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
|
1170 | '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
|
1171 | '%URIErrorPrototype%': ['URIError', 'prototype'],
|
1172 | '%WeakMapPrototype%': ['WeakMap', 'prototype'],
|
1173 | '%WeakSetPrototype%': ['WeakSet', 'prototype']
|
1174 | };
|
1175 |
|
1176 | var bind = require('function-bind');
|
1177 | var hasOwn = require('has');
|
1178 | var $concat = bind.call(Function.call, Array.prototype.concat);
|
1179 | var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
|
1180 | var $replace = bind.call(Function.call, String.prototype.replace);
|
1181 | var $strSlice = bind.call(Function.call, String.prototype.slice);
|
1182 |
|
1183 |
|
1184 | var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
1185 | var reEscapeChar = /\\(\\)?/g;
|
1186 | var stringToPath = function stringToPath(string) {
|
1187 | var first = $strSlice(string, 0, 1);
|
1188 | var last = $strSlice(string, -1);
|
1189 | if (first === '%' && last !== '%') {
|
1190 | throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
|
1191 | } else if (last === '%' && first !== '%') {
|
1192 | throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
|
1193 | }
|
1194 | var result = [];
|
1195 | $replace(string, rePropName, function (match, number, quote, subString) {
|
1196 | result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
|
1197 | });
|
1198 | return result;
|
1199 | };
|
1200 |
|
1201 |
|
1202 | var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
|
1203 | var intrinsicName = name;
|
1204 | var alias;
|
1205 | if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
|
1206 | alias = LEGACY_ALIASES[intrinsicName];
|
1207 | intrinsicName = '%' + alias[0] + '%';
|
1208 | }
|
1209 |
|
1210 | if (hasOwn(INTRINSICS, intrinsicName)) {
|
1211 | var value = INTRINSICS[intrinsicName];
|
1212 | if (value === needsEval) {
|
1213 | value = doEval(intrinsicName);
|
1214 | }
|
1215 | if (typeof value === 'undefined' && !allowMissing) {
|
1216 | throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
|
1217 | }
|
1218 |
|
1219 | return {
|
1220 | alias: alias,
|
1221 | name: intrinsicName,
|
1222 | value: value
|
1223 | };
|
1224 | }
|
1225 |
|
1226 | throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
|
1227 | };
|
1228 |
|
1229 | module.exports = function GetIntrinsic(name, allowMissing) {
|
1230 | if (typeof name !== 'string' || name.length === 0) {
|
1231 | throw new $TypeError('intrinsic name must be a non-empty string');
|
1232 | }
|
1233 | if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
|
1234 | throw new $TypeError('"allowMissing" argument must be a boolean');
|
1235 | }
|
1236 |
|
1237 | var parts = stringToPath(name);
|
1238 | var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
|
1239 |
|
1240 | var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
|
1241 | var intrinsicRealName = intrinsic.name;
|
1242 | var value = intrinsic.value;
|
1243 | var skipFurtherCaching = false;
|
1244 |
|
1245 | var alias = intrinsic.alias;
|
1246 | if (alias) {
|
1247 | intrinsicBaseName = alias[0];
|
1248 | $spliceApply(parts, $concat([0, 1], alias));
|
1249 | }
|
1250 |
|
1251 | for (var i = 1, isOwn = true; i < parts.length; i += 1) {
|
1252 | var part = parts[i];
|
1253 | var first = $strSlice(part, 0, 1);
|
1254 | var last = $strSlice(part, -1);
|
1255 | if (
|
1256 | (
|
1257 | (first === '"' || first === "'" || first === '`')
|
1258 | || (last === '"' || last === "'" || last === '`')
|
1259 | )
|
1260 | && first !== last
|
1261 | ) {
|
1262 | throw new $SyntaxError('property names with quotes must have matching quotes');
|
1263 | }
|
1264 | if (part === 'constructor' || !isOwn) {
|
1265 | skipFurtherCaching = true;
|
1266 | }
|
1267 |
|
1268 | intrinsicBaseName += '.' + part;
|
1269 | intrinsicRealName = '%' + intrinsicBaseName + '%';
|
1270 |
|
1271 | if (hasOwn(INTRINSICS, intrinsicRealName)) {
|
1272 | value = INTRINSICS[intrinsicRealName];
|
1273 | } else if (value != null) {
|
1274 | if (!(part in value)) {
|
1275 | if (!allowMissing) {
|
1276 | throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
|
1277 | }
|
1278 | return void undefined;
|
1279 | }
|
1280 | if ($gOPD && (i + 1) >= parts.length) {
|
1281 | var desc = $gOPD(value, part);
|
1282 | isOwn = !!desc;
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 |
|
1288 |
|
1289 |
|
1290 |
|
1291 | if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
|
1292 | value = desc.get;
|
1293 | } else {
|
1294 | value = value[part];
|
1295 | }
|
1296 | } else {
|
1297 | isOwn = hasOwn(value, part);
|
1298 | value = value[part];
|
1299 | }
|
1300 |
|
1301 | if (isOwn && !skipFurtherCaching) {
|
1302 | INTRINSICS[intrinsicRealName] = value;
|
1303 | }
|
1304 | }
|
1305 | }
|
1306 | return value;
|
1307 | };
|
1308 |
|
1309 | },{"function-bind":10,"has":14,"has-symbols":12}],12:[function(require,module,exports){
|
1310 | 'use strict';
|
1311 |
|
1312 | var origSymbol = typeof Symbol !== 'undefined' && Symbol;
|
1313 | var hasSymbolSham = require('./shams');
|
1314 |
|
1315 | module.exports = function hasNativeSymbols() {
|
1316 | if (typeof origSymbol !== 'function') { return false; }
|
1317 | if (typeof Symbol !== 'function') { return false; }
|
1318 | if (typeof origSymbol('foo') !== 'symbol') { return false; }
|
1319 | if (typeof Symbol('bar') !== 'symbol') { return false; }
|
1320 |
|
1321 | return hasSymbolSham();
|
1322 | };
|
1323 |
|
1324 | },{"./shams":13}],13:[function(require,module,exports){
|
1325 | 'use strict';
|
1326 |
|
1327 |
|
1328 | module.exports = function hasSymbols() {
|
1329 | if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
|
1330 | if (typeof Symbol.iterator === 'symbol') { return true; }
|
1331 |
|
1332 | var obj = {};
|
1333 | var sym = Symbol('test');
|
1334 | var symObj = Object(sym);
|
1335 | if (typeof sym === 'string') { return false; }
|
1336 |
|
1337 | if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
|
1338 | if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
|
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 |
|
1345 |
|
1346 |
|
1347 |
|
1348 | var symVal = 42;
|
1349 | obj[sym] = symVal;
|
1350 | for (sym in obj) { return false; }
|
1351 | if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
|
1352 |
|
1353 | if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
|
1354 |
|
1355 | var syms = Object.getOwnPropertySymbols(obj);
|
1356 | if (syms.length !== 1 || syms[0] !== sym) { return false; }
|
1357 |
|
1358 | if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
|
1359 |
|
1360 | if (typeof Object.getOwnPropertyDescriptor === 'function') {
|
1361 | var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
|
1362 | if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
|
1363 | }
|
1364 |
|
1365 | return true;
|
1366 | };
|
1367 |
|
1368 | },{}],14:[function(require,module,exports){
|
1369 | 'use strict';
|
1370 |
|
1371 | var bind = require('function-bind');
|
1372 |
|
1373 | module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
|
1374 |
|
1375 | },{"function-bind":10}],15:[function(require,module,exports){
|
1376 | var hasMap = typeof Map === 'function' && Map.prototype;
|
1377 | var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, 'size') : null;
|
1378 | var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === 'function' ? mapSizeDescriptor.get : null;
|
1379 | var mapForEach = hasMap && Map.prototype.forEach;
|
1380 | var hasSet = typeof Set === 'function' && Set.prototype;
|
1381 | var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, 'size') : null;
|
1382 | var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === 'function' ? setSizeDescriptor.get : null;
|
1383 | var setForEach = hasSet && Set.prototype.forEach;
|
1384 | var hasWeakMap = typeof WeakMap === 'function' && WeakMap.prototype;
|
1385 | var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
|
1386 | var hasWeakSet = typeof WeakSet === 'function' && WeakSet.prototype;
|
1387 | var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
|
1388 | var booleanValueOf = Boolean.prototype.valueOf;
|
1389 | var objectToString = Object.prototype.toString;
|
1390 | var functionToString = Function.prototype.toString;
|
1391 | var match = String.prototype.match;
|
1392 | var bigIntValueOf = typeof BigInt === 'function' ? BigInt.prototype.valueOf : null;
|
1393 | var gOPS = Object.getOwnPropertySymbols;
|
1394 | var symToString = typeof Symbol === 'function' ? Symbol.prototype.toString : null;
|
1395 | var isEnumerable = Object.prototype.propertyIsEnumerable;
|
1396 |
|
1397 | var inspectCustom = require('./util.inspect').custom;
|
1398 | var inspectSymbol = inspectCustom && isSymbol(inspectCustom) ? inspectCustom : null;
|
1399 |
|
1400 | module.exports = function inspect_(obj, options, depth, seen) {
|
1401 | var opts = options || {};
|
1402 |
|
1403 | if (has(opts, 'quoteStyle') && (opts.quoteStyle !== 'single' && opts.quoteStyle !== 'double')) {
|
1404 | throw new TypeError('option "quoteStyle" must be "single" or "double"');
|
1405 | }
|
1406 | if (
|
1407 | has(opts, 'maxStringLength') && (typeof opts.maxStringLength === 'number'
|
1408 | ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity
|
1409 | : opts.maxStringLength !== null
|
1410 | )
|
1411 | ) {
|
1412 | throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
|
1413 | }
|
1414 | var customInspect = has(opts, 'customInspect') ? opts.customInspect : true;
|
1415 | if (typeof customInspect !== 'boolean') {
|
1416 | throw new TypeError('option "customInspect", if provided, must be `true` or `false`');
|
1417 | }
|
1418 |
|
1419 | if (
|
1420 | has(opts, 'indent')
|
1421 | && opts.indent !== null
|
1422 | && opts.indent !== '\t'
|
1423 | && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)
|
1424 | ) {
|
1425 | throw new TypeError('options "indent" must be "\\t", an integer > 0, or `null`');
|
1426 | }
|
1427 |
|
1428 | if (typeof obj === 'undefined') {
|
1429 | return 'undefined';
|
1430 | }
|
1431 | if (obj === null) {
|
1432 | return 'null';
|
1433 | }
|
1434 | if (typeof obj === 'boolean') {
|
1435 | return obj ? 'true' : 'false';
|
1436 | }
|
1437 |
|
1438 | if (typeof obj === 'string') {
|
1439 | return inspectString(obj, opts);
|
1440 | }
|
1441 | if (typeof obj === 'number') {
|
1442 | if (obj === 0) {
|
1443 | return Infinity / obj > 0 ? '0' : '-0';
|
1444 | }
|
1445 | return String(obj);
|
1446 | }
|
1447 | if (typeof obj === 'bigint') {
|
1448 | return String(obj) + 'n';
|
1449 | }
|
1450 |
|
1451 | var maxDepth = typeof opts.depth === 'undefined' ? 5 : opts.depth;
|
1452 | if (typeof depth === 'undefined') { depth = 0; }
|
1453 | if (depth >= maxDepth && maxDepth > 0 && typeof obj === 'object') {
|
1454 | return isArray(obj) ? '[Array]' : '[Object]';
|
1455 | }
|
1456 |
|
1457 | var indent = getIndent(opts, depth);
|
1458 |
|
1459 | if (typeof seen === 'undefined') {
|
1460 | seen = [];
|
1461 | } else if (indexOf(seen, obj) >= 0) {
|
1462 | return '[Circular]';
|
1463 | }
|
1464 |
|
1465 | function inspect(value, from, noIndent) {
|
1466 | if (from) {
|
1467 | seen = seen.slice();
|
1468 | seen.push(from);
|
1469 | }
|
1470 | if (noIndent) {
|
1471 | var newOpts = {
|
1472 | depth: opts.depth
|
1473 | };
|
1474 | if (has(opts, 'quoteStyle')) {
|
1475 | newOpts.quoteStyle = opts.quoteStyle;
|
1476 | }
|
1477 | return inspect_(value, newOpts, depth + 1, seen);
|
1478 | }
|
1479 | return inspect_(value, opts, depth + 1, seen);
|
1480 | }
|
1481 |
|
1482 | if (typeof obj === 'function') {
|
1483 | var name = nameOf(obj);
|
1484 | var keys = arrObjKeys(obj, inspect);
|
1485 | return '[Function' + (name ? ': ' + name : ' (anonymous)') + ']' + (keys.length > 0 ? ' { ' + keys.join(', ') + ' }' : '');
|
1486 | }
|
1487 | if (isSymbol(obj)) {
|
1488 | var symString = symToString.call(obj);
|
1489 | return typeof obj === 'object' ? markBoxed(symString) : symString;
|
1490 | }
|
1491 | if (isElement(obj)) {
|
1492 | var s = '<' + String(obj.nodeName).toLowerCase();
|
1493 | var attrs = obj.attributes || [];
|
1494 | for (var i = 0; i < attrs.length; i++) {
|
1495 | s += ' ' + attrs[i].name + '=' + wrapQuotes(quote(attrs[i].value), 'double', opts);
|
1496 | }
|
1497 | s += '>';
|
1498 | if (obj.childNodes && obj.childNodes.length) { s += '...'; }
|
1499 | s += '</' + String(obj.nodeName).toLowerCase() + '>';
|
1500 | return s;
|
1501 | }
|
1502 | if (isArray(obj)) {
|
1503 | if (obj.length === 0) { return '[]'; }
|
1504 | var xs = arrObjKeys(obj, inspect);
|
1505 | if (indent && !singleLineValues(xs)) {
|
1506 | return '[' + indentedJoin(xs, indent) + ']';
|
1507 | }
|
1508 | return '[ ' + xs.join(', ') + ' ]';
|
1509 | }
|
1510 | if (isError(obj)) {
|
1511 | var parts = arrObjKeys(obj, inspect);
|
1512 | if (parts.length === 0) { return '[' + String(obj) + ']'; }
|
1513 | return '{ [' + String(obj) + '] ' + parts.join(', ') + ' }';
|
1514 | }
|
1515 | if (typeof obj === 'object' && customInspect) {
|
1516 | if (inspectSymbol && typeof obj[inspectSymbol] === 'function') {
|
1517 | return obj[inspectSymbol]();
|
1518 | } else if (typeof obj.inspect === 'function') {
|
1519 | return obj.inspect();
|
1520 | }
|
1521 | }
|
1522 | if (isMap(obj)) {
|
1523 | var mapParts = [];
|
1524 | mapForEach.call(obj, function (value, key) {
|
1525 | mapParts.push(inspect(key, obj, true) + ' => ' + inspect(value, obj));
|
1526 | });
|
1527 | return collectionOf('Map', mapSize.call(obj), mapParts, indent);
|
1528 | }
|
1529 | if (isSet(obj)) {
|
1530 | var setParts = [];
|
1531 | setForEach.call(obj, function (value) {
|
1532 | setParts.push(inspect(value, obj));
|
1533 | });
|
1534 | return collectionOf('Set', setSize.call(obj), setParts, indent);
|
1535 | }
|
1536 | if (isWeakMap(obj)) {
|
1537 | return weakCollectionOf('WeakMap');
|
1538 | }
|
1539 | if (isWeakSet(obj)) {
|
1540 | return weakCollectionOf('WeakSet');
|
1541 | }
|
1542 | if (isNumber(obj)) {
|
1543 | return markBoxed(inspect(Number(obj)));
|
1544 | }
|
1545 | if (isBigInt(obj)) {
|
1546 | return markBoxed(inspect(bigIntValueOf.call(obj)));
|
1547 | }
|
1548 | if (isBoolean(obj)) {
|
1549 | return markBoxed(booleanValueOf.call(obj));
|
1550 | }
|
1551 | if (isString(obj)) {
|
1552 | return markBoxed(inspect(String(obj)));
|
1553 | }
|
1554 | if (!isDate(obj) && !isRegExp(obj)) {
|
1555 | var ys = arrObjKeys(obj, inspect);
|
1556 | if (ys.length === 0) { return '{}'; }
|
1557 | if (indent) {
|
1558 | return '{' + indentedJoin(ys, indent) + '}';
|
1559 | }
|
1560 | return '{ ' + ys.join(', ') + ' }';
|
1561 | }
|
1562 | return String(obj);
|
1563 | };
|
1564 |
|
1565 | function wrapQuotes(s, defaultStyle, opts) {
|
1566 | var quoteChar = (opts.quoteStyle || defaultStyle) === 'double' ? '"' : "'";
|
1567 | return quoteChar + s + quoteChar;
|
1568 | }
|
1569 |
|
1570 | function quote(s) {
|
1571 | return String(s).replace(/"/g, '"');
|
1572 | }
|
1573 |
|
1574 | function isArray(obj) { return toStr(obj) === '[object Array]'; }
|
1575 | function isDate(obj) { return toStr(obj) === '[object Date]'; }
|
1576 | function isRegExp(obj) { return toStr(obj) === '[object RegExp]'; }
|
1577 | function isError(obj) { return toStr(obj) === '[object Error]'; }
|
1578 | function isSymbol(obj) { return toStr(obj) === '[object Symbol]'; }
|
1579 | function isString(obj) { return toStr(obj) === '[object String]'; }
|
1580 | function isNumber(obj) { return toStr(obj) === '[object Number]'; }
|
1581 | function isBigInt(obj) { return toStr(obj) === '[object BigInt]'; }
|
1582 | function isBoolean(obj) { return toStr(obj) === '[object Boolean]'; }
|
1583 |
|
1584 | var hasOwn = Object.prototype.hasOwnProperty || function (key) { return key in this; };
|
1585 | function has(obj, key) {
|
1586 | return hasOwn.call(obj, key);
|
1587 | }
|
1588 |
|
1589 | function toStr(obj) {
|
1590 | return objectToString.call(obj);
|
1591 | }
|
1592 |
|
1593 | function nameOf(f) {
|
1594 | if (f.name) { return f.name; }
|
1595 | var m = match.call(functionToString.call(f), /^function\s*([\w$]+)/);
|
1596 | if (m) { return m[1]; }
|
1597 | return null;
|
1598 | }
|
1599 |
|
1600 | function indexOf(xs, x) {
|
1601 | if (xs.indexOf) { return xs.indexOf(x); }
|
1602 | for (var i = 0, l = xs.length; i < l; i++) {
|
1603 | if (xs[i] === x) { return i; }
|
1604 | }
|
1605 | return -1;
|
1606 | }
|
1607 |
|
1608 | function isMap(x) {
|
1609 | if (!mapSize || !x || typeof x !== 'object') {
|
1610 | return false;
|
1611 | }
|
1612 | try {
|
1613 | mapSize.call(x);
|
1614 | try {
|
1615 | setSize.call(x);
|
1616 | } catch (s) {
|
1617 | return true;
|
1618 | }
|
1619 | return x instanceof Map;
|
1620 | } catch (e) {}
|
1621 | return false;
|
1622 | }
|
1623 |
|
1624 | function isWeakMap(x) {
|
1625 | if (!weakMapHas || !x || typeof x !== 'object') {
|
1626 | return false;
|
1627 | }
|
1628 | try {
|
1629 | weakMapHas.call(x, weakMapHas);
|
1630 | try {
|
1631 | weakSetHas.call(x, weakSetHas);
|
1632 | } catch (s) {
|
1633 | return true;
|
1634 | }
|
1635 | return x instanceof WeakMap;
|
1636 | } catch (e) {}
|
1637 | return false;
|
1638 | }
|
1639 |
|
1640 | function isSet(x) {
|
1641 | if (!setSize || !x || typeof x !== 'object') {
|
1642 | return false;
|
1643 | }
|
1644 | try {
|
1645 | setSize.call(x);
|
1646 | try {
|
1647 | mapSize.call(x);
|
1648 | } catch (m) {
|
1649 | return true;
|
1650 | }
|
1651 | return x instanceof Set;
|
1652 | } catch (e) {}
|
1653 | return false;
|
1654 | }
|
1655 |
|
1656 | function isWeakSet(x) {
|
1657 | if (!weakSetHas || !x || typeof x !== 'object') {
|
1658 | return false;
|
1659 | }
|
1660 | try {
|
1661 | weakSetHas.call(x, weakSetHas);
|
1662 | try {
|
1663 | weakMapHas.call(x, weakMapHas);
|
1664 | } catch (s) {
|
1665 | return true;
|
1666 | }
|
1667 | return x instanceof WeakSet;
|
1668 | } catch (e) {}
|
1669 | return false;
|
1670 | }
|
1671 |
|
1672 | function isElement(x) {
|
1673 | if (!x || typeof x !== 'object') { return false; }
|
1674 | if (typeof HTMLElement !== 'undefined' && x instanceof HTMLElement) {
|
1675 | return true;
|
1676 | }
|
1677 | return typeof x.nodeName === 'string' && typeof x.getAttribute === 'function';
|
1678 | }
|
1679 |
|
1680 | function inspectString(str, opts) {
|
1681 | if (str.length > opts.maxStringLength) {
|
1682 | var remaining = str.length - opts.maxStringLength;
|
1683 | var trailer = '... ' + remaining + ' more character' + (remaining > 1 ? 's' : '');
|
1684 | return inspectString(str.slice(0, opts.maxStringLength), opts) + trailer;
|
1685 | }
|
1686 |
|
1687 | var s = str.replace(/(['\\])/g, '\\$1').replace(/[\x00-\x1f]/g, lowbyte);
|
1688 | return wrapQuotes(s, 'single', opts);
|
1689 | }
|
1690 |
|
1691 | function lowbyte(c) {
|
1692 | var n = c.charCodeAt(0);
|
1693 | var x = {
|
1694 | 8: 'b',
|
1695 | 9: 't',
|
1696 | 10: 'n',
|
1697 | 12: 'f',
|
1698 | 13: 'r'
|
1699 | }[n];
|
1700 | if (x) { return '\\' + x; }
|
1701 | return '\\x' + (n < 0x10 ? '0' : '') + n.toString(16).toUpperCase();
|
1702 | }
|
1703 |
|
1704 | function markBoxed(str) {
|
1705 | return 'Object(' + str + ')';
|
1706 | }
|
1707 |
|
1708 | function weakCollectionOf(type) {
|
1709 | return type + ' { ? }';
|
1710 | }
|
1711 |
|
1712 | function collectionOf(type, size, entries, indent) {
|
1713 | var joinedEntries = indent ? indentedJoin(entries, indent) : entries.join(', ');
|
1714 | return type + ' (' + size + ') {' + joinedEntries + '}';
|
1715 | }
|
1716 |
|
1717 | function singleLineValues(xs) {
|
1718 | for (var i = 0; i < xs.length; i++) {
|
1719 | if (indexOf(xs[i], '\n') >= 0) {
|
1720 | return false;
|
1721 | }
|
1722 | }
|
1723 | return true;
|
1724 | }
|
1725 |
|
1726 | function getIndent(opts, depth) {
|
1727 | var baseIndent;
|
1728 | if (opts.indent === '\t') {
|
1729 | baseIndent = '\t';
|
1730 | } else if (typeof opts.indent === 'number' && opts.indent > 0) {
|
1731 | baseIndent = Array(opts.indent + 1).join(' ');
|
1732 | } else {
|
1733 | return null;
|
1734 | }
|
1735 | return {
|
1736 | base: baseIndent,
|
1737 | prev: Array(depth + 1).join(baseIndent)
|
1738 | };
|
1739 | }
|
1740 |
|
1741 | function indentedJoin(xs, indent) {
|
1742 | if (xs.length === 0) { return ''; }
|
1743 | var lineJoiner = '\n' + indent.prev + indent.base;
|
1744 | return lineJoiner + xs.join(',' + lineJoiner) + '\n' + indent.prev;
|
1745 | }
|
1746 |
|
1747 | function arrObjKeys(obj, inspect) {
|
1748 | var isArr = isArray(obj);
|
1749 | var xs = [];
|
1750 | if (isArr) {
|
1751 | xs.length = obj.length;
|
1752 | for (var i = 0; i < obj.length; i++) {
|
1753 | xs[i] = has(obj, i) ? inspect(obj[i], obj) : '';
|
1754 | }
|
1755 | }
|
1756 | for (var key in obj) {
|
1757 | if (!has(obj, key)) { continue; }
|
1758 | if (isArr && String(Number(key)) === key && key < obj.length) { continue; }
|
1759 | if ((/[^\w$]/).test(key)) {
|
1760 | xs.push(inspect(key, obj) + ': ' + inspect(obj[key], obj));
|
1761 | } else {
|
1762 | xs.push(key + ': ' + inspect(obj[key], obj));
|
1763 | }
|
1764 | }
|
1765 | if (typeof gOPS === 'function') {
|
1766 | var syms = gOPS(obj);
|
1767 | for (var j = 0; j < syms.length; j++) {
|
1768 | if (isEnumerable.call(obj, syms[j])) {
|
1769 | xs.push('[' + inspect(syms[j]) + ']: ' + inspect(obj[syms[j]], obj));
|
1770 | }
|
1771 | }
|
1772 | }
|
1773 | return xs;
|
1774 | }
|
1775 |
|
1776 | },{"./util.inspect":6}],16:[function(require,module,exports){
|
1777 | 'use strict';
|
1778 |
|
1779 | var GetIntrinsic = require('get-intrinsic');
|
1780 | var callBound = require('call-bind/callBound');
|
1781 | var inspect = require('object-inspect');
|
1782 |
|
1783 | var $TypeError = GetIntrinsic('%TypeError%');
|
1784 | var $WeakMap = GetIntrinsic('%WeakMap%', true);
|
1785 | var $Map = GetIntrinsic('%Map%', true);
|
1786 |
|
1787 | var $weakMapGet = callBound('WeakMap.prototype.get', true);
|
1788 | var $weakMapSet = callBound('WeakMap.prototype.set', true);
|
1789 | var $weakMapHas = callBound('WeakMap.prototype.has', true);
|
1790 | var $mapGet = callBound('Map.prototype.get', true);
|
1791 | var $mapSet = callBound('Map.prototype.set', true);
|
1792 | var $mapHas = callBound('Map.prototype.has', true);
|
1793 |
|
1794 |
|
1795 |
|
1796 |
|
1797 |
|
1798 |
|
1799 |
|
1800 |
|
1801 |
|
1802 | var listGetNode = function (list, key) {
|
1803 | for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
|
1804 | if (curr.key === key) {
|
1805 | prev.next = curr.next;
|
1806 | curr.next = list.next;
|
1807 | list.next = curr;
|
1808 | return curr;
|
1809 | }
|
1810 | }
|
1811 | };
|
1812 |
|
1813 | var listGet = function (objects, key) {
|
1814 | var node = listGetNode(objects, key);
|
1815 | return node && node.value;
|
1816 | };
|
1817 | var listSet = function (objects, key, value) {
|
1818 | var node = listGetNode(objects, key);
|
1819 | if (node) {
|
1820 | node.value = value;
|
1821 | } else {
|
1822 |
|
1823 | objects.next = {
|
1824 | key: key,
|
1825 | next: objects.next,
|
1826 | value: value
|
1827 | };
|
1828 | }
|
1829 | };
|
1830 | var listHas = function (objects, key) {
|
1831 | return !!listGetNode(objects, key);
|
1832 | };
|
1833 |
|
1834 | module.exports = function getSideChannel() {
|
1835 | var $wm;
|
1836 | var $m;
|
1837 | var $o;
|
1838 | var channel = {
|
1839 | assert: function (key) {
|
1840 | if (!channel.has(key)) {
|
1841 | throw new $TypeError('Side channel does not contain ' + inspect(key));
|
1842 | }
|
1843 | },
|
1844 | get: function (key) {
|
1845 | if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
1846 | if ($wm) {
|
1847 | return $weakMapGet($wm, key);
|
1848 | }
|
1849 | } else if ($Map) {
|
1850 | if ($m) {
|
1851 | return $mapGet($m, key);
|
1852 | }
|
1853 | } else {
|
1854 | if ($o) {
|
1855 | return listGet($o, key);
|
1856 | }
|
1857 | }
|
1858 | },
|
1859 | has: function (key) {
|
1860 | if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
1861 | if ($wm) {
|
1862 | return $weakMapHas($wm, key);
|
1863 | }
|
1864 | } else if ($Map) {
|
1865 | if ($m) {
|
1866 | return $mapHas($m, key);
|
1867 | }
|
1868 | } else {
|
1869 | if ($o) {
|
1870 | return listHas($o, key);
|
1871 | }
|
1872 | }
|
1873 | return false;
|
1874 | },
|
1875 | set: function (key, value) {
|
1876 | if ($WeakMap && key && (typeof key === 'object' || typeof key === 'function')) {
|
1877 | if (!$wm) {
|
1878 | $wm = new $WeakMap();
|
1879 | }
|
1880 | $weakMapSet($wm, key, value);
|
1881 | } else if ($Map) {
|
1882 | if (!$m) {
|
1883 | $m = new $Map();
|
1884 | }
|
1885 | $mapSet($m, key, value);
|
1886 | } else {
|
1887 | if (!$o) {
|
1888 | |
1889 |
|
1890 |
|
1891 |
|
1892 |
|
1893 | $o = { key: {}, next: null };
|
1894 | }
|
1895 | listSet($o, key, value);
|
1896 | }
|
1897 | }
|
1898 | };
|
1899 | return channel;
|
1900 | };
|
1901 |
|
1902 | },{"call-bind/callBound":7,"get-intrinsic":11,"object-inspect":15}]},{},[2])(2)
|
1903 | });
|