node-stringify
Advanced tools
Comparing version 0.0.15 to 0.0.16
var _ = require('underscore') | ||
var stringify = function (obj) { | ||
if (_.isNull(obj)) { return 'null' } | ||
if (_.isUndefined(obj)) { return 'undefined' } | ||
if (_.isRegExp(obj) || _.isNumber(obj) || _.isBoolean(obj)) { | ||
if (_.isNull(obj)) return 'null' | ||
if (_.isUndefined(obj)) return 'undefined' | ||
if (_.isRegExp(obj) || _.isNumber(obj) || _.isBoolean(obj)) | ||
return obj.toString() | ||
} | ||
if (_.isFunction(obj)) { | ||
if (_.isFunction(obj)) | ||
return '(' + obj.toString() + ')' | ||
} | ||
if (_.isString(obj)) { | ||
if (_.isString(obj)) | ||
return "'" + obj.replace(/'/g, "\\'").replace(/\n/g, '\\n') + "'" | ||
} | ||
if (_.isDate(obj)) { return 'new Date(' + obj.getTime() + ')' } | ||
if (_.isDate(obj)) return 'new Date(' + obj.getTime() + ')' | ||
if (_.isArguments(obj)) { | ||
if (_.isArguments(obj)) | ||
obj = _.toArray(obj) | ||
} | ||
if (_.isArray(obj)) { | ||
if (_.isArray(obj)) | ||
return '[' + _.map(obj, stringify).join(',') + ']' | ||
} | ||
if (_.isObject(obj)) { | ||
return '({' + _.map(obj, function (v, k) { return k + ':' + stringify(v) }).join(',') + '})' | ||
} | ||
if (_.isObject(obj)) | ||
return '({' + _.map(obj, function (v, k) { | ||
return k + ':' + stringify(v) | ||
}).join(',') + '})' | ||
} | ||
module.exports = stringify |
{ | ||
"name": "node-stringify", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"author": { | ||
@@ -18,3 +18,3 @@ "name": "Chiang Fu", | ||
"devDependencies": { | ||
"jasmine-node": "^1.14.3" | ||
"jasmine-node": "1.14.2" | ||
}, | ||
@@ -21,0 +21,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2545
21