储能智慧云小程序
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

index.js 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  1. module.exports = (function() {
  2. var __MODS__ = {};
  3. var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
  4. var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
  5. var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
  6. var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
  7. __DEFINE__(1729044221118, function(require, module, exports) {
  8. var stringify = require('./stringify');
  9. var parse = require('./parse');
  10. var formats = require('./formats');
  11. module.exports = {
  12. formats: formats,
  13. parse: parse,
  14. stringify: stringify
  15. };
  16. }, function(modId) {var map = {"./stringify":1729044221119,"./parse":1729044221122,"./formats":1729044221121}; return __REQUIRE__(map[modId], modId); })
  17. __DEFINE__(1729044221119, function(require, module, exports) {
  18. var getSideChannel = require('side-channel');
  19. var utils = require('./utils');
  20. var formats = require('./formats');
  21. var has = Object.prototype.hasOwnProperty;
  22. var arrayPrefixGenerators = {
  23. brackets: function brackets(prefix) {
  24. return prefix + '[]';
  25. },
  26. comma: 'comma',
  27. indices: function indices(prefix, key) {
  28. return prefix + '[' + key + ']';
  29. },
  30. repeat: function repeat(prefix) {
  31. return prefix;
  32. }
  33. };
  34. var isArray = Array.isArray;
  35. var push = Array.prototype.push;
  36. var pushToArray = function (arr, valueOrArray) {
  37. push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
  38. };
  39. var toISO = Date.prototype.toISOString;
  40. var defaultFormat = formats['default'];
  41. var defaults = {
  42. addQueryPrefix: false,
  43. allowDots: false,
  44. allowEmptyArrays: false,
  45. arrayFormat: 'indices',
  46. charset: 'utf-8',
  47. charsetSentinel: false,
  48. delimiter: '&',
  49. encode: true,
  50. encodeDotInKeys: false,
  51. encoder: utils.encode,
  52. encodeValuesOnly: false,
  53. format: defaultFormat,
  54. formatter: formats.formatters[defaultFormat],
  55. // deprecated
  56. indices: false,
  57. serializeDate: function serializeDate(date) {
  58. return toISO.call(date);
  59. },
  60. skipNulls: false,
  61. strictNullHandling: false
  62. };
  63. var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
  64. return typeof v === 'string'
  65. || typeof v === 'number'
  66. || typeof v === 'boolean'
  67. || typeof v === 'symbol'
  68. || typeof v === 'bigint';
  69. };
  70. var sentinel = {};
  71. var stringify = function stringify(
  72. object,
  73. prefix,
  74. generateArrayPrefix,
  75. commaRoundTrip,
  76. allowEmptyArrays,
  77. strictNullHandling,
  78. skipNulls,
  79. encodeDotInKeys,
  80. encoder,
  81. filter,
  82. sort,
  83. allowDots,
  84. serializeDate,
  85. format,
  86. formatter,
  87. encodeValuesOnly,
  88. charset,
  89. sideChannel
  90. ) {
  91. var obj = object;
  92. var tmpSc = sideChannel;
  93. var step = 0;
  94. var findFlag = false;
  95. while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) {
  96. // Where object last appeared in the ref tree
  97. var pos = tmpSc.get(object);
  98. step += 1;
  99. if (typeof pos !== 'undefined') {
  100. if (pos === step) {
  101. throw new RangeError('Cyclic object value');
  102. } else {
  103. findFlag = true; // Break while
  104. }
  105. }
  106. if (typeof tmpSc.get(sentinel) === 'undefined') {
  107. step = 0;
  108. }
  109. }
  110. if (typeof filter === 'function') {
  111. obj = filter(prefix, obj);
  112. } else if (obj instanceof Date) {
  113. obj = serializeDate(obj);
  114. } else if (generateArrayPrefix === 'comma' && isArray(obj)) {
  115. obj = utils.maybeMap(obj, function (value) {
  116. if (value instanceof Date) {
  117. return serializeDate(value);
  118. }
  119. return value;
  120. });
  121. }
  122. if (obj === null) {
  123. if (strictNullHandling) {
  124. return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix;
  125. }
  126. obj = '';
  127. }
  128. if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
  129. if (encoder) {
  130. var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key', format);
  131. return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))];
  132. }
  133. return [formatter(prefix) + '=' + formatter(String(obj))];
  134. }
  135. var values = [];
  136. if (typeof obj === 'undefined') {
  137. return values;
  138. }
  139. var objKeys;
  140. if (generateArrayPrefix === 'comma' && isArray(obj)) {
  141. // we need to join elements in
  142. if (encodeValuesOnly && encoder) {
  143. obj = utils.maybeMap(obj, encoder);
  144. }
  145. objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }];
  146. } else if (isArray(filter)) {
  147. objKeys = filter;
  148. } else {
  149. var keys = Object.keys(obj);
  150. objKeys = sort ? keys.sort(sort) : keys;
  151. }
  152. var encodedPrefix = encodeDotInKeys ? prefix.replace(/\./g, '%2E') : prefix;
  153. var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? encodedPrefix + '[]' : encodedPrefix;
  154. if (allowEmptyArrays && isArray(obj) && obj.length === 0) {
  155. return adjustedPrefix + '[]';
  156. }
  157. for (var j = 0; j < objKeys.length; ++j) {
  158. var key = objKeys[j];
  159. var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
  160. if (skipNulls && value === null) {
  161. continue;
  162. }
  163. var encodedKey = allowDots && encodeDotInKeys ? key.replace(/\./g, '%2E') : key;
  164. var keyPrefix = isArray(obj)
  165. ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, encodedKey) : adjustedPrefix
  166. : adjustedPrefix + (allowDots ? '.' + encodedKey : '[' + encodedKey + ']');
  167. sideChannel.set(object, step);
  168. var valueSideChannel = getSideChannel();
  169. valueSideChannel.set(sentinel, sideChannel);
  170. pushToArray(values, stringify(
  171. value,
  172. keyPrefix,
  173. generateArrayPrefix,
  174. commaRoundTrip,
  175. allowEmptyArrays,
  176. strictNullHandling,
  177. skipNulls,
  178. encodeDotInKeys,
  179. generateArrayPrefix === 'comma' && encodeValuesOnly && isArray(obj) ? null : encoder,
  180. filter,
  181. sort,
  182. allowDots,
  183. serializeDate,
  184. format,
  185. formatter,
  186. encodeValuesOnly,
  187. charset,
  188. valueSideChannel
  189. ));
  190. }
  191. return values;
  192. };
  193. var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
  194. if (!opts) {
  195. return defaults;
  196. }
  197. if (typeof opts.allowEmptyArrays !== 'undefined' && typeof opts.allowEmptyArrays !== 'boolean') {
  198. throw new TypeError('`allowEmptyArrays` option can only be `true` or `false`, when provided');
  199. }
  200. if (typeof opts.encodeDotInKeys !== 'undefined' && typeof opts.encodeDotInKeys !== 'boolean') {
  201. throw new TypeError('`encodeDotInKeys` option can only be `true` or `false`, when provided');
  202. }
  203. if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
  204. throw new TypeError('Encoder has to be a function.');
  205. }
  206. var charset = opts.charset || defaults.charset;
  207. if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
  208. throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
  209. }
  210. var format = formats['default'];
  211. if (typeof opts.format !== 'undefined') {
  212. if (!has.call(formats.formatters, opts.format)) {
  213. throw new TypeError('Unknown format option provided.');
  214. }
  215. format = opts.format;
  216. }
  217. var formatter = formats.formatters[format];
  218. var filter = defaults.filter;
  219. if (typeof opts.filter === 'function' || isArray(opts.filter)) {
  220. filter = opts.filter;
  221. }
  222. var arrayFormat;
  223. if (opts.arrayFormat in arrayPrefixGenerators) {
  224. arrayFormat = opts.arrayFormat;
  225. } else if ('indices' in opts) {
  226. arrayFormat = opts.indices ? 'indices' : 'repeat';
  227. } else {
  228. arrayFormat = defaults.arrayFormat;
  229. }
  230. if ('commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') {
  231. throw new TypeError('`commaRoundTrip` must be a boolean, or absent');
  232. }
  233. var allowDots = typeof opts.allowDots === 'undefined' ? opts.encodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots;
  234. return {
  235. addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
  236. allowDots: allowDots,
  237. allowEmptyArrays: typeof opts.allowEmptyArrays === 'boolean' ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays,
  238. arrayFormat: arrayFormat,
  239. charset: charset,
  240. charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
  241. commaRoundTrip: opts.commaRoundTrip,
  242. delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
  243. encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
  244. encodeDotInKeys: typeof opts.encodeDotInKeys === 'boolean' ? opts.encodeDotInKeys : defaults.encodeDotInKeys,
  245. encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
  246. encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
  247. filter: filter,
  248. format: format,
  249. formatter: formatter,
  250. serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,
  251. skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,
  252. sort: typeof opts.sort === 'function' ? opts.sort : null,
  253. strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
  254. };
  255. };
  256. module.exports = function (object, opts) {
  257. var obj = object;
  258. var options = normalizeStringifyOptions(opts);
  259. var objKeys;
  260. var filter;
  261. if (typeof options.filter === 'function') {
  262. filter = options.filter;
  263. obj = filter('', obj);
  264. } else if (isArray(options.filter)) {
  265. filter = options.filter;
  266. objKeys = filter;
  267. }
  268. var keys = [];
  269. if (typeof obj !== 'object' || obj === null) {
  270. return '';
  271. }
  272. var generateArrayPrefix = arrayPrefixGenerators[options.arrayFormat];
  273. var commaRoundTrip = generateArrayPrefix === 'comma' && options.commaRoundTrip;
  274. if (!objKeys) {
  275. objKeys = Object.keys(obj);
  276. }
  277. if (options.sort) {
  278. objKeys.sort(options.sort);
  279. }
  280. var sideChannel = getSideChannel();
  281. for (var i = 0; i < objKeys.length; ++i) {
  282. var key = objKeys[i];
  283. if (options.skipNulls && obj[key] === null) {
  284. continue;
  285. }
  286. pushToArray(keys, stringify(
  287. obj[key],
  288. key,
  289. generateArrayPrefix,
  290. commaRoundTrip,
  291. options.allowEmptyArrays,
  292. options.strictNullHandling,
  293. options.skipNulls,
  294. options.encodeDotInKeys,
  295. options.encode ? options.encoder : null,
  296. options.filter,
  297. options.sort,
  298. options.allowDots,
  299. options.serializeDate,
  300. options.format,
  301. options.formatter,
  302. options.encodeValuesOnly,
  303. options.charset,
  304. sideChannel
  305. ));
  306. }
  307. var joined = keys.join(options.delimiter);
  308. var prefix = options.addQueryPrefix === true ? '?' : '';
  309. if (options.charsetSentinel) {
  310. if (options.charset === 'iso-8859-1') {
  311. // encodeURIComponent('&#10003;'), the "numeric entity" representation of a checkmark
  312. prefix += 'utf8=%26%2310003%3B&';
  313. } else {
  314. // encodeURIComponent('✓')
  315. prefix += 'utf8=%E2%9C%93&';
  316. }
  317. }
  318. return joined.length > 0 ? prefix + joined : '';
  319. };
  320. }, function(modId) { var map = {"./utils":1729044221120,"./formats":1729044221121}; return __REQUIRE__(map[modId], modId); })
  321. __DEFINE__(1729044221120, function(require, module, exports) {
  322. var formats = require('./formats');
  323. var has = Object.prototype.hasOwnProperty;
  324. var isArray = Array.isArray;
  325. var hexTable = (function () {
  326. var array = [];
  327. for (var i = 0; i < 256; ++i) {
  328. array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
  329. }
  330. return array;
  331. }());
  332. var compactQueue = function compactQueue(queue) {
  333. while (queue.length > 1) {
  334. var item = queue.pop();
  335. var obj = item.obj[item.prop];
  336. if (isArray(obj)) {
  337. var compacted = [];
  338. for (var j = 0; j < obj.length; ++j) {
  339. if (typeof obj[j] !== 'undefined') {
  340. compacted.push(obj[j]);
  341. }
  342. }
  343. item.obj[item.prop] = compacted;
  344. }
  345. }
  346. };
  347. var arrayToObject = function arrayToObject(source, options) {
  348. var obj = options && options.plainObjects ? Object.create(null) : {};
  349. for (var i = 0; i < source.length; ++i) {
  350. if (typeof source[i] !== 'undefined') {
  351. obj[i] = source[i];
  352. }
  353. }
  354. return obj;
  355. };
  356. var merge = function merge(target, source, options) {
  357. /* eslint no-param-reassign: 0 */
  358. if (!source) {
  359. return target;
  360. }
  361. if (typeof source !== 'object') {
  362. if (isArray(target)) {
  363. target.push(source);
  364. } else if (target && typeof target === 'object') {
  365. if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
  366. target[source] = true;
  367. }
  368. } else {
  369. return [target, source];
  370. }
  371. return target;
  372. }
  373. if (!target || typeof target !== 'object') {
  374. return [target].concat(source);
  375. }
  376. var mergeTarget = target;
  377. if (isArray(target) && !isArray(source)) {
  378. mergeTarget = arrayToObject(target, options);
  379. }
  380. if (isArray(target) && isArray(source)) {
  381. source.forEach(function (item, i) {
  382. if (has.call(target, i)) {
  383. var targetItem = target[i];
  384. if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
  385. target[i] = merge(targetItem, item, options);
  386. } else {
  387. target.push(item);
  388. }
  389. } else {
  390. target[i] = item;
  391. }
  392. });
  393. return target;
  394. }
  395. return Object.keys(source).reduce(function (acc, key) {
  396. var value = source[key];
  397. if (has.call(acc, key)) {
  398. acc[key] = merge(acc[key], value, options);
  399. } else {
  400. acc[key] = value;
  401. }
  402. return acc;
  403. }, mergeTarget);
  404. };
  405. var assign = function assignSingleSource(target, source) {
  406. return Object.keys(source).reduce(function (acc, key) {
  407. acc[key] = source[key];
  408. return acc;
  409. }, target);
  410. };
  411. var decode = function (str, decoder, charset) {
  412. var strWithoutPlus = str.replace(/\+/g, ' ');
  413. if (charset === 'iso-8859-1') {
  414. // unescape never throws, no try...catch needed:
  415. return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
  416. }
  417. // utf-8
  418. try {
  419. return decodeURIComponent(strWithoutPlus);
  420. } catch (e) {
  421. return strWithoutPlus;
  422. }
  423. };
  424. var limit = 1024;
  425. /* eslint operator-linebreak: [2, "before"] */
  426. var encode = function encode(str, defaultEncoder, charset, kind, format) {
  427. // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
  428. // It has been adapted here for stricter adherence to RFC 3986
  429. if (str.length === 0) {
  430. return str;
  431. }
  432. var string = str;
  433. if (typeof str === 'symbol') {
  434. string = Symbol.prototype.toString.call(str);
  435. } else if (typeof str !== 'string') {
  436. string = String(str);
  437. }
  438. if (charset === 'iso-8859-1') {
  439. return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
  440. return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
  441. });
  442. }
  443. var out = '';
  444. for (var j = 0; j < string.length; j += limit) {
  445. var segment = string.length >= limit ? string.slice(j, j + limit) : string;
  446. var arr = [];
  447. for (var i = 0; i < segment.length; ++i) {
  448. var c = segment.charCodeAt(i);
  449. if (
  450. c === 0x2D // -
  451. || c === 0x2E // .
  452. || c === 0x5F // _
  453. || c === 0x7E // ~
  454. || (c >= 0x30 && c <= 0x39) // 0-9
  455. || (c >= 0x41 && c <= 0x5A) // a-z
  456. || (c >= 0x61 && c <= 0x7A) // A-Z
  457. || (format === formats.RFC1738 && (c === 0x28 || c === 0x29)) // ( )
  458. ) {
  459. arr[arr.length] = segment.charAt(i);
  460. continue;
  461. }
  462. if (c < 0x80) {
  463. arr[arr.length] = hexTable[c];
  464. continue;
  465. }
  466. if (c < 0x800) {
  467. arr[arr.length] = hexTable[0xC0 | (c >> 6)]
  468. + hexTable[0x80 | (c & 0x3F)];
  469. continue;
  470. }
  471. if (c < 0xD800 || c >= 0xE000) {
  472. arr[arr.length] = hexTable[0xE0 | (c >> 12)]
  473. + hexTable[0x80 | ((c >> 6) & 0x3F)]
  474. + hexTable[0x80 | (c & 0x3F)];
  475. continue;
  476. }
  477. i += 1;
  478. c = 0x10000 + (((c & 0x3FF) << 10) | (segment.charCodeAt(i) & 0x3FF));
  479. arr[arr.length] = hexTable[0xF0 | (c >> 18)]
  480. + hexTable[0x80 | ((c >> 12) & 0x3F)]
  481. + hexTable[0x80 | ((c >> 6) & 0x3F)]
  482. + hexTable[0x80 | (c & 0x3F)];
  483. }
  484. out += arr.join('');
  485. }
  486. return out;
  487. };
  488. var compact = function compact(value) {
  489. var queue = [{ obj: { o: value }, prop: 'o' }];
  490. var refs = [];
  491. for (var i = 0; i < queue.length; ++i) {
  492. var item = queue[i];
  493. var obj = item.obj[item.prop];
  494. var keys = Object.keys(obj);
  495. for (var j = 0; j < keys.length; ++j) {
  496. var key = keys[j];
  497. var val = obj[key];
  498. if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
  499. queue.push({ obj: obj, prop: key });
  500. refs.push(val);
  501. }
  502. }
  503. }
  504. compactQueue(queue);
  505. return value;
  506. };
  507. var isRegExp = function isRegExp(obj) {
  508. return Object.prototype.toString.call(obj) === '[object RegExp]';
  509. };
  510. var isBuffer = function isBuffer(obj) {
  511. if (!obj || typeof obj !== 'object') {
  512. return false;
  513. }
  514. return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
  515. };
  516. var combine = function combine(a, b) {
  517. return [].concat(a, b);
  518. };
  519. var maybeMap = function maybeMap(val, fn) {
  520. if (isArray(val)) {
  521. var mapped = [];
  522. for (var i = 0; i < val.length; i += 1) {
  523. mapped.push(fn(val[i]));
  524. }
  525. return mapped;
  526. }
  527. return fn(val);
  528. };
  529. module.exports = {
  530. arrayToObject: arrayToObject,
  531. assign: assign,
  532. combine: combine,
  533. compact: compact,
  534. decode: decode,
  535. encode: encode,
  536. isBuffer: isBuffer,
  537. isRegExp: isRegExp,
  538. maybeMap: maybeMap,
  539. merge: merge
  540. };
  541. }, function(modId) { var map = {"./formats":1729044221121}; return __REQUIRE__(map[modId], modId); })
  542. __DEFINE__(1729044221121, function(require, module, exports) {
  543. var replace = String.prototype.replace;
  544. var percentTwenties = /%20/g;
  545. var Format = {
  546. RFC1738: 'RFC1738',
  547. RFC3986: 'RFC3986'
  548. };
  549. module.exports = {
  550. 'default': Format.RFC3986,
  551. formatters: {
  552. RFC1738: function (value) {
  553. return replace.call(value, percentTwenties, '+');
  554. },
  555. RFC3986: function (value) {
  556. return String(value);
  557. }
  558. },
  559. RFC1738: Format.RFC1738,
  560. RFC3986: Format.RFC3986
  561. };
  562. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  563. __DEFINE__(1729044221122, function(require, module, exports) {
  564. var utils = require('./utils');
  565. var has = Object.prototype.hasOwnProperty;
  566. var isArray = Array.isArray;
  567. var defaults = {
  568. allowDots: false,
  569. allowEmptyArrays: false,
  570. allowPrototypes: false,
  571. allowSparse: false,
  572. arrayLimit: 20,
  573. charset: 'utf-8',
  574. charsetSentinel: false,
  575. comma: false,
  576. decodeDotInKeys: false,
  577. decoder: utils.decode,
  578. delimiter: '&',
  579. depth: 5,
  580. duplicates: 'combine',
  581. ignoreQueryPrefix: false,
  582. interpretNumericEntities: false,
  583. parameterLimit: 1000,
  584. parseArrays: true,
  585. plainObjects: false,
  586. strictNullHandling: false
  587. };
  588. var interpretNumericEntities = function (str) {
  589. return str.replace(/&#(\d+);/g, function ($0, numberStr) {
  590. return String.fromCharCode(parseInt(numberStr, 10));
  591. });
  592. };
  593. var parseArrayValue = function (val, options) {
  594. if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
  595. return val.split(',');
  596. }
  597. return val;
  598. };
  599. // This is what browsers will submit when the ✓ character occurs in an
  600. // application/x-www-form-urlencoded body and the encoding of the page containing
  601. // the form is iso-8859-1, or when the submitted form has an accept-charset
  602. // attribute of iso-8859-1. Presumably also with other charsets that do not contain
  603. // the ✓ character, such as us-ascii.
  604. var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('&#10003;')
  605. // These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
  606. var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
  607. var parseValues = function parseQueryStringValues(str, options) {
  608. var obj = { __proto__: null };
  609. var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
  610. cleanStr = cleanStr.replace(/%5B/gi, '[').replace(/%5D/gi, ']');
  611. var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
  612. var parts = cleanStr.split(options.delimiter, limit);
  613. var skipIndex = -1; // Keep track of where the utf8 sentinel was found
  614. var i;
  615. var charset = options.charset;
  616. if (options.charsetSentinel) {
  617. for (i = 0; i < parts.length; ++i) {
  618. if (parts[i].indexOf('utf8=') === 0) {
  619. if (parts[i] === charsetSentinel) {
  620. charset = 'utf-8';
  621. } else if (parts[i] === isoSentinel) {
  622. charset = 'iso-8859-1';
  623. }
  624. skipIndex = i;
  625. i = parts.length; // The eslint settings do not allow break;
  626. }
  627. }
  628. }
  629. for (i = 0; i < parts.length; ++i) {
  630. if (i === skipIndex) {
  631. continue;
  632. }
  633. var part = parts[i];
  634. var bracketEqualsPos = part.indexOf(']=');
  635. var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
  636. var key, val;
  637. if (pos === -1) {
  638. key = options.decoder(part, defaults.decoder, charset, 'key');
  639. val = options.strictNullHandling ? null : '';
  640. } else {
  641. key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key');
  642. val = utils.maybeMap(
  643. parseArrayValue(part.slice(pos + 1), options),
  644. function (encodedVal) {
  645. return options.decoder(encodedVal, defaults.decoder, charset, 'value');
  646. }
  647. );
  648. }
  649. if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
  650. val = interpretNumericEntities(val);
  651. }
  652. if (part.indexOf('[]=') > -1) {
  653. val = isArray(val) ? [val] : val;
  654. }
  655. var existing = has.call(obj, key);
  656. if (existing && options.duplicates === 'combine') {
  657. obj[key] = utils.combine(obj[key], val);
  658. } else if (!existing || options.duplicates === 'last') {
  659. obj[key] = val;
  660. }
  661. }
  662. return obj;
  663. };
  664. var parseObject = function (chain, val, options, valuesParsed) {
  665. var leaf = valuesParsed ? val : parseArrayValue(val, options);
  666. for (var i = chain.length - 1; i >= 0; --i) {
  667. var obj;
  668. var root = chain[i];
  669. if (root === '[]' && options.parseArrays) {
  670. obj = options.allowEmptyArrays && leaf === '' ? [] : [].concat(leaf);
  671. } else {
  672. obj = options.plainObjects ? Object.create(null) : {};
  673. var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
  674. var decodedRoot = options.decodeDotInKeys ? cleanRoot.replace(/%2E/g, '.') : cleanRoot;
  675. var index = parseInt(decodedRoot, 10);
  676. if (!options.parseArrays && decodedRoot === '') {
  677. obj = { 0: leaf };
  678. } else if (
  679. !isNaN(index)
  680. && root !== decodedRoot
  681. && String(index) === decodedRoot
  682. && index >= 0
  683. && (options.parseArrays && index <= options.arrayLimit)
  684. ) {
  685. obj = [];
  686. obj[index] = leaf;
  687. } else if (decodedRoot !== '__proto__') {
  688. obj[decodedRoot] = leaf;
  689. }
  690. }
  691. leaf = obj;
  692. }
  693. return leaf;
  694. };
  695. var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
  696. if (!givenKey) {
  697. return;
  698. }
  699. // Transform dot notation to bracket notation
  700. var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
  701. // The regex chunks
  702. var brackets = /(\[[^[\]]*])/;
  703. var child = /(\[[^[\]]*])/g;
  704. // Get the parent
  705. var segment = options.depth > 0 && brackets.exec(key);
  706. var parent = segment ? key.slice(0, segment.index) : key;
  707. // Stash the parent if it exists
  708. var keys = [];
  709. if (parent) {
  710. // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
  711. if (!options.plainObjects && has.call(Object.prototype, parent)) {
  712. if (!options.allowPrototypes) {
  713. return;
  714. }
  715. }
  716. keys.push(parent);
  717. }
  718. // Loop through children appending to the array until we hit depth
  719. var i = 0;
  720. while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
  721. i += 1;
  722. if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
  723. if (!options.allowPrototypes) {
  724. return;
  725. }
  726. }
  727. keys.push(segment[1]);
  728. }
  729. // If there's a remainder, just add whatever is left
  730. if (segment) {
  731. keys.push('[' + key.slice(segment.index) + ']');
  732. }
  733. return parseObject(keys, val, options, valuesParsed);
  734. };
  735. var normalizeParseOptions = function normalizeParseOptions(opts) {
  736. if (!opts) {
  737. return defaults;
  738. }
  739. if (typeof opts.allowEmptyArrays !== 'undefined' && typeof opts.allowEmptyArrays !== 'boolean') {
  740. throw new TypeError('`allowEmptyArrays` option can only be `true` or `false`, when provided');
  741. }
  742. if (typeof opts.decodeDotInKeys !== 'undefined' && typeof opts.decodeDotInKeys !== 'boolean') {
  743. throw new TypeError('`decodeDotInKeys` option can only be `true` or `false`, when provided');
  744. }
  745. if (opts.decoder !== null && typeof opts.decoder !== 'undefined' && typeof opts.decoder !== 'function') {
  746. throw new TypeError('Decoder has to be a function.');
  747. }
  748. if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
  749. throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
  750. }
  751. var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
  752. var duplicates = typeof opts.duplicates === 'undefined' ? defaults.duplicates : opts.duplicates;
  753. if (duplicates !== 'combine' && duplicates !== 'first' && duplicates !== 'last') {
  754. throw new TypeError('The duplicates option must be either combine, first, or last');
  755. }
  756. var allowDots = typeof opts.allowDots === 'undefined' ? opts.decodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots;
  757. return {
  758. allowDots: allowDots,
  759. allowEmptyArrays: typeof opts.allowEmptyArrays === 'boolean' ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays,
  760. allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
  761. allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,
  762. arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
  763. charset: charset,
  764. charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
  765. comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
  766. decodeDotInKeys: typeof opts.decodeDotInKeys === 'boolean' ? opts.decodeDotInKeys : defaults.decodeDotInKeys,
  767. decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
  768. delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
  769. // eslint-disable-next-line no-implicit-coercion, no-extra-parens
  770. depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth,
  771. duplicates: duplicates,
  772. ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
  773. interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
  774. parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
  775. parseArrays: opts.parseArrays !== false,
  776. plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
  777. strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
  778. };
  779. };
  780. module.exports = function (str, opts) {
  781. var options = normalizeParseOptions(opts);
  782. if (str === '' || str === null || typeof str === 'undefined') {
  783. return options.plainObjects ? Object.create(null) : {};
  784. }
  785. var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
  786. var obj = options.plainObjects ? Object.create(null) : {};
  787. // Iterate over the keys and setup the new object
  788. var keys = Object.keys(tempObj);
  789. for (var i = 0; i < keys.length; ++i) {
  790. var key = keys[i];
  791. var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
  792. obj = utils.merge(obj, newObj, options);
  793. }
  794. if (options.allowSparse === true) {
  795. return obj;
  796. }
  797. return utils.compact(obj);
  798. };
  799. }, function(modId) { var map = {"./utils":1729044221120}; return __REQUIRE__(map[modId], modId); })
  800. return __REQUIRE__(1729044221118);
  801. })()
  802. //miniprogram-npm-outsideDeps=["side-channel"]
  803. //# sourceMappingURL=index.js.map