MCPcopy Index your code
hub / github.com/tomas/needle / stringify

Function stringify

lib/querystring.js:6–22  ·  view source on GitHub ↗
(obj, prefix)

Source from the content-addressed store, hash-verified

4var toString = Object.prototype.toString;
5
6function stringify(obj, prefix) {
7 if (prefix && (obj === null || typeof obj == 'undefined')) {
8 return prefix + '=';
9 } else if (toString.call(obj) == '[object Array]') {
10 return stringifyArray(obj, prefix);
11 } else if (toString.call(obj) == '[object Object]') {
12 return stringifyObject(obj, prefix);
13 } else if (toString.call(obj) == '[object Date]') {
14 return obj.toISOString();
15 } else if (prefix) { // string inside array or hash
16 return prefix + '=' + encodeURIComponent(String(obj));
17 } else if (String(obj).indexOf('=') !== -1) { // string with equal sign
18 return String(obj);
19 } else {
20 throw new TypeError('Cannot build a querystring out of: ' + obj);
21 }
22};
23
24function stringifyArray(arr, prefix) {
25 var ret = [];

Callers 4

needle.jsFile · 0.85
stringifyArrayFunction · 0.85
stringifyObjectFunction · 0.85

Calls 2

stringifyArrayFunction · 0.85
stringifyObjectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…