javascript-stringify
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -88,3 +88,3 @@ (function (root, stringify) { | ||
*/ | ||
var getGlobalVariable = function (value, indent, stringify) { | ||
var toGlobalVariable = function (value, indent, stringify) { | ||
return 'Function(' + stringify('return this;') + ')()'; | ||
@@ -102,3 +102,9 @@ }; | ||
var values = array.map(function (value) { | ||
return indent + stringify(value).split('\n').join('\n' + indent); | ||
var str = stringify(value); | ||
if (value === undefined) { | ||
return String(str) | ||
} | ||
return indent + str.split('\n').join('\n' + indent); | ||
}).join(indent ? ',\n' : ','); | ||
@@ -144,18 +150,35 @@ | ||
}, | ||
'[object Date]': function (date, indent, stringify) { | ||
'[object Date]': function (date) { | ||
return 'new Date(' + date.getTime() + ')'; | ||
}, | ||
'[object String]': function (string, indent, stringify) { | ||
'[object String]': function (string) { | ||
return 'new String(' + stringify(string.toString()) + ')'; | ||
}, | ||
'[object Number]': function (number, indent, stringify) { | ||
'[object Number]': function (number) { | ||
return 'new Number(' + number + ')'; | ||
}, | ||
'[object Boolean]': function (boolean, indent, stringify) { | ||
'[object Boolean]': function (boolean) { | ||
return 'new Boolean(' + boolean + ')'; | ||
}, | ||
'[object Uint8Array]': function (array, indent) { | ||
if (typeof Buffer === 'function' && Buffer.isBuffer(array)) { | ||
return 'new Buffer(' + stringify(array.toString()) + ')'; | ||
} | ||
if (indent) { | ||
var str = ''; | ||
for (var i = 0; i < array.length; i++) { | ||
str += indent + array[i] + ',\n' | ||
} | ||
return 'new Uint8Array([\n' + str + '\n])' | ||
} | ||
return 'new Uint8Array([' + array.join(indent ? ',\n' : ',') + '])' | ||
}, | ||
'[object RegExp]': String, | ||
'[object Function]': String, | ||
'[object global]': getGlobalVariable, | ||
'[object Window]': getGlobalVariable | ||
'[object global]': toGlobalVariable, | ||
'[object Window]': toGlobalVariable | ||
}; | ||
@@ -162,0 +185,0 @@ |
{ | ||
"name": "javascript-stringify", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Stringify is to `eval` as `JSON.stringify` is to `JSON.parse`", | ||
@@ -5,0 +5,0 @@ "main": "javascript-stringify.js", |
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
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
237
9775
4
1
0