"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/request/node_modules/qs/dist/qs.js" (7 Feb 2017, 17339 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

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