jsesc
Advanced tools
Comparing version 0.4.0 to 0.4.1
13
jsesc.js
@@ -1,2 +0,2 @@ | ||
/*! http://mths.be/jsesc v0.4.0 by @mathias */ | ||
/*! http://mths.be/jsesc v0.4.1 by @mathias */ | ||
;(function(root, evil) { | ||
@@ -111,2 +111,3 @@ | ||
var result; | ||
var isEmpty = true; | ||
@@ -121,2 +122,3 @@ if (!isString(argument)) { | ||
forEach(argument, function(value) { | ||
isEmpty = false; | ||
result.push( | ||
@@ -127,2 +129,5 @@ (compact ? '' : indent) + | ||
}); | ||
if (isEmpty) { | ||
return '[]'; | ||
} | ||
return '[' + newLine + result.join(',' + newLine) + newLine + | ||
@@ -155,2 +160,3 @@ (compact ? '' : oldIndent) + ']'; | ||
forOwn(argument, function(key, value) { | ||
isEmpty = false; | ||
result.push( | ||
@@ -163,2 +169,5 @@ (compact ? '' : indent) + | ||
}); | ||
if (isEmpty) { | ||
return '{}'; | ||
} | ||
return '{' + newLine + result.join(',' + newLine) + newLine + | ||
@@ -219,3 +228,3 @@ (compact ? '' : oldIndent) + '}'; | ||
jsesc.version = '0.4.0'; | ||
jsesc.version = '0.4.1'; | ||
@@ -222,0 +231,0 @@ /*--------------------------------------------------------------------------*/ |
{ | ||
"name": "jsesc", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "A JavaScript library for escaping JavaScript strings while generating the shortest possible valid output.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://mths.be/jsesc", |
@@ -90,3 +90,3 @@ # jsesc [![Build status](https://travis-ci.org/mathiasbynens/jsesc.png?branch=master)](https://travis-ci.org/mathiasbynens/jsesc) [![Dependency status](https://gemnasium.com/mathiasbynens/jsesc.png)](https://gemnasium.com/mathiasbynens/jsesc) | ||
jsesc([ | ||
'Ich ♥ Bücher': 'foo 𝌆 bar' | ||
'Ich ♥ Bücher', 'foo 𝌆 bar' | ||
]); | ||
@@ -261,4 +261,4 @@ // → '[\'Ich \\u2665 B\\xFCcher\',\'foo \\uD834\\uDF06 bar\']' | ||
// Values that aren’t strings, regular expressions, arrays, or object literals | ||
// can’t be escaped, so they’ll just be preserved: | ||
// Values that are acceptable in JSON but aren’t strings, arrays, or object | ||
// literals can’t be escaped, so they’ll just be preserved: | ||
jsesc([ 'foo\x00bar', [1, '©', { 'foo': true, 'qux': null }], 42 ], { | ||
@@ -265,0 +265,0 @@ 'json': true |
25748
229