Sha256: b33607e495b910c3a4b26936c9edf4b85c22964ec88e03e66f1e89a8ba1cc026
Contents?: true
Size: 1.05 KB
Versions: 24
Compression:
Stored size: 1.05 KB
Contents
// Load modules // Declare internals var internals = { delimiter: '&' }; internals.stringify = function (obj, prefix) { if (Buffer.isBuffer(obj)) { obj = obj.toString(); } else if (obj instanceof Date) { obj = obj.toISOString(); } else if (obj === null) { obj = ''; } if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean') { return [encodeURIComponent(prefix) + '=' + encodeURIComponent(obj)]; } var values = []; for (var key in obj) { if (obj.hasOwnProperty(key)) { values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']')); } } return values; }; module.exports = function (obj, delimiter) { delimiter = typeof delimiter === 'undefined' ? internals.delimiter : delimiter; var keys = []; for (var key in obj) { if (obj.hasOwnProperty(key)) { keys = keys.concat(internals.stringify(obj[key], key)); } } return keys.join(delimiter); };
Version data entries
24 entries across 17 versions & 2 rubygems