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

Version Path
hooch-0.4.2 jasmine/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
gulp_assets-1.0.0.pre.5 template/node_modules/gulp-livereload/node_modules/tiny-lr/node_modules/body-parser/node_modules/qs/lib/stringify.js
gulp_assets-1.0.0.pre.4 template/node_modules/gulp-livereload/node_modules/tiny-lr/node_modules/body-parser/node_modules/qs/lib/stringify.js
gulp_assets-1.0.0.pre.3 template/node_modules/gulp-livereload/node_modules/tiny-lr/node_modules/body-parser/node_modules/qs/lib/stringify.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
hooch-0.2.1 jasmine/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
hooch-0.2.0 jasmine/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
hooch-0.1.0 jasmine/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
hooch-0.0.8 jasmine/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
hooch-0.0.7 jasmine/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
hooch-0.0.6 jasmine/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/connect/node_modules/qs/lib/stringify.js