source: trip-planner-front/node_modules/qs/dist/qs.js@ 6a80231

Last change on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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