updated npm modules
This commit is contained in:
59
node_modules/qs/lib/utils.js
generated
vendored
59
node_modules/qs/lib/utils.js
generated
vendored
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var has = Object.prototype.hasOwnProperty;
|
||||
var isArray = Array.isArray;
|
||||
|
||||
var hexTable = (function () {
|
||||
var array = [];
|
||||
@@ -12,13 +13,11 @@ var hexTable = (function () {
|
||||
}());
|
||||
|
||||
var compactQueue = function compactQueue(queue) {
|
||||
var obj;
|
||||
|
||||
while (queue.length) {
|
||||
while (queue.length > 1) {
|
||||
var item = queue.pop();
|
||||
obj = item.obj[item.prop];
|
||||
var obj = item.obj[item.prop];
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
if (isArray(obj)) {
|
||||
var compacted = [];
|
||||
|
||||
for (var j = 0; j < obj.length; ++j) {
|
||||
@@ -30,8 +29,6 @@ var compactQueue = function compactQueue(queue) {
|
||||
item.obj[item.prop] = compacted;
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
var arrayToObject = function arrayToObject(source, options) {
|
||||
@@ -51,10 +48,10 @@ var merge = function merge(target, source, options) {
|
||||
}
|
||||
|
||||
if (typeof source !== 'object') {
|
||||
if (Array.isArray(target)) {
|
||||
if (isArray(target)) {
|
||||
target.push(source);
|
||||
} else if (typeof target === 'object') {
|
||||
if (options.plainObjects || options.allowPrototypes || !has.call(Object.prototype, source)) {
|
||||
} else if (target && typeof target === 'object') {
|
||||
if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
|
||||
target[source] = true;
|
||||
}
|
||||
} else {
|
||||
@@ -64,20 +61,21 @@ var merge = function merge(target, source, options) {
|
||||
return target;
|
||||
}
|
||||
|
||||
if (typeof target !== 'object') {
|
||||
if (!target || typeof target !== 'object') {
|
||||
return [target].concat(source);
|
||||
}
|
||||
|
||||
var mergeTarget = target;
|
||||
if (Array.isArray(target) && !Array.isArray(source)) {
|
||||
if (isArray(target) && !isArray(source)) {
|
||||
mergeTarget = arrayToObject(target, options);
|
||||
}
|
||||
|
||||
if (Array.isArray(target) && Array.isArray(source)) {
|
||||
if (isArray(target) && isArray(source)) {
|
||||
source.forEach(function (item, i) {
|
||||
if (has.call(target, i)) {
|
||||
if (target[i] && typeof target[i] === 'object') {
|
||||
target[i] = merge(target[i], item, options);
|
||||
var targetItem = target[i];
|
||||
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
||||
target[i] = merge(targetItem, item, options);
|
||||
} else {
|
||||
target.push(item);
|
||||
}
|
||||
@@ -107,15 +105,21 @@ var assign = function assignSingleSource(target, source) {
|
||||
}, target);
|
||||
};
|
||||
|
||||
var decode = function (str) {
|
||||
var decode = function (str, decoder, charset) {
|
||||
var strWithoutPlus = str.replace(/\+/g, ' ');
|
||||
if (charset === 'iso-8859-1') {
|
||||
// unescape never throws, no try...catch needed:
|
||||
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
||||
}
|
||||
// utf-8
|
||||
try {
|
||||
return decodeURIComponent(str.replace(/\+/g, ' '));
|
||||
return decodeURIComponent(strWithoutPlus);
|
||||
} catch (e) {
|
||||
return str;
|
||||
return strWithoutPlus;
|
||||
}
|
||||
};
|
||||
|
||||
var encode = function encode(str) {
|
||||
var encode = function encode(str, defaultEncoder, charset) {
|
||||
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
|
||||
// It has been adapted here for stricter adherence to RFC 3986
|
||||
if (str.length === 0) {
|
||||
@@ -124,6 +128,12 @@ var encode = function encode(str) {
|
||||
|
||||
var string = typeof str === 'string' ? str : String(str);
|
||||
|
||||
if (charset === 'iso-8859-1') {
|
||||
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
||||
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
||||
});
|
||||
}
|
||||
|
||||
var out = '';
|
||||
for (var i = 0; i < string.length; ++i) {
|
||||
var c = string.charCodeAt(i);
|
||||
@@ -186,7 +196,9 @@ var compact = function compact(value) {
|
||||
}
|
||||
}
|
||||
|
||||
return compactQueue(queue);
|
||||
compactQueue(queue);
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
var isRegExp = function isRegExp(obj) {
|
||||
@@ -194,16 +206,21 @@ var isRegExp = function isRegExp(obj) {
|
||||
};
|
||||
|
||||
var isBuffer = function isBuffer(obj) {
|
||||
if (obj === null || typeof obj === 'undefined') {
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
||||
};
|
||||
|
||||
var combine = function combine(a, b) {
|
||||
return [].concat(a, b);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
arrayToObject: arrayToObject,
|
||||
assign: assign,
|
||||
combine: combine,
|
||||
compact: compact,
|
||||
decode: decode,
|
||||
encode: encode,
|
||||
|
||||
Reference in New Issue
Block a user