Sha256: f324564946583468f469ee2f2f1ac13c074e414ed7a40f6b08c6c8eb05a430e0
Contents?: true
Size: 1.13 KB
Versions: 20
Compression:
Stored size: 1.13 KB
Contents
// Load modules var Utils = require('./utils'); // Declare internals var internals = { delimiter: '&' }; internals.stringify = function (obj, prefix) { if (Utils.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, options) { options = options || {}; var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.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
20 entries across 20 versions & 3 rubygems