jsesc
Advanced tools
Comparing version 1.2.0 to 1.2.1
30
jsesc.js
@@ -1,2 +0,2 @@ | ||
/*! https://mths.be/jsesc v1.2.0 by @mathias */ | ||
/*! https://mths.be/jsesc v1.2.1 by @mathias */ | ||
;(function(root) { | ||
@@ -121,3 +121,5 @@ | ||
var indent = options.indent; | ||
var oldIndent; | ||
var oldIndent = ''; | ||
var inline1 = options.__inline1__; | ||
var inline2 = options.__inline2__; | ||
var newLine = compact ? '' : '\n'; | ||
@@ -136,2 +138,5 @@ var result; | ||
} | ||
if (!compact) { | ||
options.__inline1__ = true; | ||
} | ||
return 'new Map(' + jsesc(Array.from(argument), options) + ')'; | ||
@@ -148,9 +153,17 @@ } | ||
options.wrap = true; | ||
oldIndent = options.__indent__; | ||
indent += oldIndent; | ||
options.__indent__ = indent; | ||
if (inline1) { | ||
options.__inline1__ = false; | ||
options.__inline2__ = true; | ||
} else { | ||
oldIndent = options.__indent__; | ||
indent += oldIndent; | ||
options.__indent__ = indent; | ||
} | ||
forEach(argument, function(value) { | ||
isEmpty = false; | ||
if (inline2) { | ||
options.__inline2__ = false; | ||
} | ||
result.push( | ||
(compact ? '' : indent) + | ||
(compact || inline2 ? '' : indent) + | ||
jsesc(value, options) | ||
@@ -162,2 +175,5 @@ ); | ||
} | ||
if (inline2) { | ||
return '[' + result.join(', ') + ']'; | ||
} | ||
return '[' + newLine + result.join(',' + newLine) + newLine + | ||
@@ -276,3 +292,3 @@ (compact ? '' : oldIndent) + ']'; | ||
jsesc.version = '1.2.0'; | ||
jsesc.version = '1.2.1'; | ||
@@ -279,0 +295,0 @@ /*--------------------------------------------------------------------------*/ |
{ | ||
"name": "jsesc", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "A JavaScript library for escaping JavaScript strings while generating the shortest possible valid output.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://mths.be/jsesc", |
17268
293