qs.js 61 KB

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