diff options
author | isaacs <i@izs.me> | 2013-07-26 14:38:08 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-08-01 15:08:01 -0700 |
commit | 22c68fdc1dae40f0ed9c71a02f66e5b2c6353691 (patch) | |
tree | b6d14cad6f5a9ba78172f77c5c2ec10b8a6cb89c /lib/querystring.js | |
parent | 9a29aa8c552eb2b120c101c1cfd66ba565a17ed5 (diff) | |
download | node-new-22c68fdc1dae40f0ed9c71a02f66e5b2c6353691.tar.gz |
src: Replace macros with util functions
Diffstat (limited to 'lib/querystring.js')
-rw-r--r-- | lib/querystring.js | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/querystring.js b/lib/querystring.js index ce9853d7f0..e9ff825d55 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -22,6 +22,7 @@ // Query String Utilities var QueryString = exports; +var util = require('util'); // If obj.hasOwnProperty has been overridden, then calling @@ -114,11 +115,11 @@ QueryString.escape = function(str) { }; var stringifyPrimitive = function(v) { - if (IS_STRING(v)) + if (util.isString(v)) return v; - if (IS_BOOLEAN(v)) + if (util.isBoolean(v)) return v ? 'true' : 'false'; - if (IS_NUMBER(v)) + if (util.isNumber(v)) return isFinite(v) ? v : ''; return ''; }; @@ -127,14 +128,14 @@ var stringifyPrimitive = function(v) { QueryString.stringify = QueryString.encode = function(obj, sep, eq, name) { sep = sep || '&'; eq = eq || '='; - if (IS_NULL(obj)) { + if (util.isNull(obj)) { obj = undefined; } - if (IS_OBJECT(obj)) { + if (util.isObject(obj)) { return Object.keys(obj).map(function(k) { var ks = QueryString.escape(stringifyPrimitive(k)) + eq; - if (IS_ARRAY(obj[k])) { + if (util.isArray(obj[k])) { return obj[k].map(function(v) { return ks + QueryString.escape(stringifyPrimitive(v)); }).join(sep); @@ -156,7 +157,7 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { eq = eq || '='; var obj = {}; - if (!IS_STRING(qs) || qs.length === 0) { + if (!util.isString(qs) || qs.length === 0) { return obj; } @@ -164,7 +165,7 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { qs = qs.split(sep); var maxKeys = 1000; - if (options && IS_NUMBER(options.maxKeys)) { + if (options && util.isNumber(options.maxKeys)) { maxKeys = options.maxKeys; } @@ -197,7 +198,7 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { if (!hasOwnProperty(obj, k)) { obj[k] = v; - } else if (IS_ARRAY(obj[k])) { + } else if (util.isArray(obj[k])) { obj[k].push(v); } else { obj[k] = [obj[k], v]; |