"Fossies" - the Fresh Open Source Software Archive

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