]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/request/node_modules/qs/dist/qs.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / request / node_modules / qs / dist / qs.js
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 e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2 'use strict';
3
4 var Stringify = require('./stringify');
5 var Parse = require('./parse');
6
7 module.exports = {
8     stringify: Stringify,
9     parse: Parse
10 };
11
12 },{"./parse":2,"./stringify":3}],2:[function(require,module,exports){
13 'use strict';
14
15 var Utils = require('./utils');
16
17 var has = Object.prototype.hasOwnProperty;
18
19 var defaults = {
20     delimiter: '&',
21     depth: 5,
22     arrayLimit: 20,
23     parameterLimit: 1000,
24     strictNullHandling: false,
25     plainObjects: false,
26     allowPrototypes: false,
27     allowDots: false,
28     decoder: Utils.decode
29 };
30
31 var parseValues = function parseValues(str, options) {
32     var obj = {};
33     var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
34
35     for (var i = 0; i < parts.length; ++i) {
36         var part = parts[i];
37         var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
38
39         var key, val;
40         if (pos === -1) {
41             key = options.decoder(part);
42             val = options.strictNullHandling ? null : '';
43         } else {
44             key = options.decoder(part.slice(0, pos));
45             val = options.decoder(part.slice(pos + 1));
46         }
47         if (has.call(obj, key)) {
48             obj[key] = [].concat(obj[key]).concat(val);
49         } else {
50             obj[key] = val;
51         }
52     }
53
54     return obj;
55 };
56
57 var parseObject = function parseObject(chain, val, options) {
58     if (!chain.length) {
59         return val;
60     }
61
62     var root = chain.shift();
63
64     var obj;
65     if (root === '[]') {
66         obj = [];
67         obj = obj.concat(parseObject(chain, val, options));
68     } else {
69         obj = options.plainObjects ? Object.create(null) : {};
70         var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
71         var index = parseInt(cleanRoot, 10);
72         if (
73             !isNaN(index) &&
74             root !== cleanRoot &&
75             String(index) === cleanRoot &&
76             index >= 0 &&
77             (options.parseArrays && index <= options.arrayLimit)
78         ) {
79             obj = [];
80             obj[index] = parseObject(chain, val, options);
81         } else {
82             obj[cleanRoot] = parseObject(chain, val, options);
83         }
84     }
85
86     return obj;
87 };
88
89 var parseKeys = function parseKeys(givenKey, val, options) {
90     if (!givenKey) {
91         return;
92     }
93
94     // Transform dot notation to bracket notation
95     var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey;
96
97     // The regex chunks
98
99     var parent = /^([^\[\]]*)/;
100     var child = /(\[[^\[\]]*\])/g;
101
102     // Get the parent
103
104     var segment = parent.exec(key);
105
106     // Stash the parent if it exists
107
108     var keys = [];
109     if (segment[1]) {
110         // If we aren't using plain objects, optionally prefix keys
111         // that would overwrite object prototype properties
112         if (!options.plainObjects && has.call(Object.prototype, segment[1])) {
113             if (!options.allowPrototypes) {
114                 return;
115             }
116         }
117
118         keys.push(segment[1]);
119     }
120
121     // Loop through children appending to the array until we hit depth
122
123     var i = 0;
124     while ((segment = child.exec(key)) !== null && i < options.depth) {
125         i += 1;
126         if (!options.plainObjects && has.call(Object.prototype, segment[1].replace(/\[|\]/g, ''))) {
127             if (!options.allowPrototypes) {
128                 continue;
129             }
130         }
131         keys.push(segment[1]);
132     }
133
134     // If there's a remainder, just add whatever is left
135
136     if (segment) {
137         keys.push('[' + key.slice(segment.index) + ']');
138     }
139
140     return parseObject(keys, val, options);
141 };
142
143 module.exports = function (str, opts) {
144     var options = opts || {};
145
146     if (options.decoder !== null && options.decoder !== undefined && typeof options.decoder !== 'function') {
147         throw new TypeError('Decoder has to be a function.');
148     }
149
150     options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : defaults.delimiter;
151     options.depth = typeof options.depth === 'number' ? options.depth : defaults.depth;
152     options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : defaults.arrayLimit;
153     options.parseArrays = options.parseArrays !== false;
154     options.decoder = typeof options.decoder === 'function' ? options.decoder : defaults.decoder;
155     options.allowDots = typeof options.allowDots === 'boolean' ? options.allowDots : defaults.allowDots;
156     options.plainObjects = typeof options.plainObjects === 'boolean' ? options.plainObjects : defaults.plainObjects;
157     options.allowPrototypes = typeof options.allowPrototypes === 'boolean' ? options.allowPrototypes : defaults.allowPrototypes;
158     options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : defaults.parameterLimit;
159     options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
160
161     if (str === '' || str === null || typeof str === 'undefined') {
162         return options.plainObjects ? Object.create(null) : {};
163     }
164
165     var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
166     var obj = options.plainObjects ? Object.create(null) : {};
167
168     // Iterate over the keys and setup the new object
169
170     var keys = Object.keys(tempObj);
171     for (var i = 0; i < keys.length; ++i) {
172         var key = keys[i];
173         var newObj = parseKeys(key, tempObj[key], options);
174         obj = Utils.merge(obj, newObj, options);
175     }
176
177     return Utils.compact(obj);
178 };
179
180 },{"./utils":4}],3:[function(require,module,exports){
181 'use strict';
182
183 var Utils = require('./utils');
184
185 var arrayPrefixGenerators = {
186     brackets: function brackets(prefix) {
187         return prefix + '[]';
188     },
189     indices: function indices(prefix, key) {
190         return prefix + '[' + key + ']';
191     },
192     repeat: function repeat(prefix) {
193         return prefix;
194     }
195 };
196
197 var defaults = {
198     delimiter: '&',
199     strictNullHandling: false,
200     skipNulls: false,
201     encode: true,
202     encoder: Utils.encode
203 };
204
205 var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots) {
206     var obj = object;
207     if (typeof filter === 'function') {
208         obj = filter(prefix, obj);
209     } else if (obj instanceof Date) {
210         obj = obj.toISOString();
211     } else if (obj === null) {
212         if (strictNullHandling) {
213             return encoder ? encoder(prefix) : prefix;
214         }
215
216         obj = '';
217     }
218
219     if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || Utils.isBuffer(obj)) {
220         if (encoder) {
221             return [encoder(prefix) + '=' + encoder(obj)];
222         }
223         return [prefix + '=' + String(obj)];
224     }
225
226     var values = [];
227
228     if (typeof obj === 'undefined') {
229         return values;
230     }
231
232     var objKeys;
233     if (Array.isArray(filter)) {
234         objKeys = filter;
235     } else {
236         var keys = Object.keys(obj);
237         objKeys = sort ? keys.sort(sort) : keys;
238     }
239
240     for (var i = 0; i < objKeys.length; ++i) {
241         var key = objKeys[i];
242
243         if (skipNulls && obj[key] === null) {
244             continue;
245         }
246
247         if (Array.isArray(obj)) {
248             values = values.concat(stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots));
249         } else {
250             values = values.concat(stringify(obj[key], prefix + (allowDots ? '.' + key : '[' + key + ']'), generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots));
251         }
252     }
253
254     return values;
255 };
256
257 module.exports = function (object, opts) {
258     var obj = object;
259     var options = opts || {};
260     var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter;
261     var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling;
262     var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls;
263     var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode;
264     var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null;
265     var sort = typeof options.sort === 'function' ? options.sort : null;
266     var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots;
267     var objKeys;
268     var filter;
269
270     if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') {
271         throw new TypeError('Encoder has to be a function.');
272     }
273
274     if (typeof options.filter === 'function') {
275         filter = options.filter;
276         obj = filter('', obj);
277     } else if (Array.isArray(options.filter)) {
278         objKeys = filter = options.filter;
279     }
280
281     var keys = [];
282
283     if (typeof obj !== 'object' || obj === null) {
284         return '';
285     }
286
287     var arrayFormat;
288     if (options.arrayFormat in arrayPrefixGenerators) {
289         arrayFormat = options.arrayFormat;
290     } else if ('indices' in options) {
291         arrayFormat = options.indices ? 'indices' : 'repeat';
292     } else {
293         arrayFormat = 'indices';
294     }
295
296     var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
297
298     if (!objKeys) {
299         objKeys = Object.keys(obj);
300     }
301
302     if (sort) {
303         objKeys.sort(sort);
304     }
305
306     for (var i = 0; i < objKeys.length; ++i) {
307         var key = objKeys[i];
308
309         if (skipNulls && obj[key] === null) {
310             continue;
311         }
312
313         keys = keys.concat(stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots));
314     }
315
316     return keys.join(delimiter);
317 };
318
319 },{"./utils":4}],4:[function(require,module,exports){
320 'use strict';
321
322 var hexTable = (function () {
323     var array = new Array(256);
324     for (var i = 0; i < 256; ++i) {
325         array[i] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
326     }
327
328     return array;
329 }());
330
331 exports.arrayToObject = function (source, options) {
332     var obj = options.plainObjects ? Object.create(null) : {};
333     for (var i = 0; i < source.length; ++i) {
334         if (typeof source[i] !== 'undefined') {
335             obj[i] = source[i];
336         }
337     }
338
339     return obj;
340 };
341
342 exports.merge = function (target, source, options) {
343     if (!source) {
344         return target;
345     }
346
347     if (typeof source !== 'object') {
348         if (Array.isArray(target)) {
349             target.push(source);
350         } else if (typeof target === 'object') {
351             target[source] = true;
352         } else {
353             return [target, source];
354         }
355
356         return target;
357     }
358
359     if (typeof target !== 'object') {
360         return [target].concat(source);
361     }
362
363     var mergeTarget = target;
364     if (Array.isArray(target) && !Array.isArray(source)) {
365         mergeTarget = exports.arrayToObject(target, options);
366     }
367
368     return Object.keys(source).reduce(function (acc, key) {
369         var value = source[key];
370
371         if (Object.prototype.hasOwnProperty.call(acc, key)) {
372             acc[key] = exports.merge(acc[key], value, options);
373         } else {
374             acc[key] = value;
375         }
376         return acc;
377     }, mergeTarget);
378 };
379
380 exports.decode = function (str) {
381     try {
382         return decodeURIComponent(str.replace(/\+/g, ' '));
383     } catch (e) {
384         return str;
385     }
386 };
387
388 exports.encode = function (str) {
389     // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
390     // It has been adapted here for stricter adherence to RFC 3986
391     if (str.length === 0) {
392         return str;
393     }
394
395     var string = typeof str === 'string' ? str : String(str);
396
397     var out = '';
398     for (var i = 0; i < string.length; ++i) {
399         var c = string.charCodeAt(i);
400
401         if (
402             c === 0x2D || // -
403             c === 0x2E || // .
404             c === 0x5F || // _
405             c === 0x7E || // ~
406             (c >= 0x30 && c <= 0x39) || // 0-9
407             (c >= 0x41 && c <= 0x5A) || // a-z
408             (c >= 0x61 && c <= 0x7A) // A-Z
409         ) {
410             out += string.charAt(i);
411             continue;
412         }
413
414         if (c < 0x80) {
415             out = out + hexTable[c];
416             continue;
417         }
418
419         if (c < 0x800) {
420             out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
421             continue;
422         }
423
424         if (c < 0xD800 || c >= 0xE000) {
425             out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
426             continue;
427         }
428
429         i += 1;
430         c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
431         out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)];
432     }
433
434     return out;
435 };
436
437 exports.compact = function (obj, references) {
438     if (typeof obj !== 'object' || obj === null) {
439         return obj;
440     }
441
442     var refs = references || [];
443     var lookup = refs.indexOf(obj);
444     if (lookup !== -1) {
445         return refs[lookup];
446     }
447
448     refs.push(obj);
449
450     if (Array.isArray(obj)) {
451         var compacted = [];
452
453         for (var i = 0; i < obj.length; ++i) {
454             if (obj[i] && typeof obj[i] === 'object') {
455                 compacted.push(exports.compact(obj[i], refs));
456             } else if (typeof obj[i] !== 'undefined') {
457                 compacted.push(obj[i]);
458             }
459         }
460
461         return compacted;
462     }
463
464     var keys = Object.keys(obj);
465     for (var j = 0; j < keys.length; ++j) {
466         var key = keys[j];
467         obj[key] = exports.compact(obj[key], refs);
468     }
469
470     return obj;
471 };
472
473 exports.isRegExp = function (obj) {
474     return Object.prototype.toString.call(obj) === '[object RegExp]';
475 };
476
477 exports.isBuffer = function (obj) {
478     if (obj === null || typeof obj === 'undefined') {
479         return false;
480     }
481
482     return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
483 };
484
485 },{}]},{},[1])(1)
486 });