From 82828a1a91f1c91e71b069dcb8c17bf05195a88f Mon Sep 17 00:00:00 2001 From: marekpalenik Date: Mon, 21 Nov 2016 13:40:58 +0100 Subject: [PATCH] replace js keyword native please change name of variable native to something else, as it is also a javascript keyword, and e.g. some minifiers fail on it. --- lib/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index 872b3fe..f6d4c8d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -57,11 +57,11 @@ const sortify = (value, replacer, space) => { // replacer, toJSON(), cyclic references and other stuff is better handled by native stringifier. // So we do JSON.stringify(sortKeys( JSON.parse(JSON.stringify()) )). // This approach is slightly slower but much safer than a manual stringification. - let native = jsonStringify(value, replacer, 0); - if (!native || native[0] !== '{' && native[0] !== '[') { // if value is not an Object or Array - return native; + let nativeJson = jsonStringify(value, replacer, 0); + if (!nativeJson || nativeJson[0] !== '{' && nativeJson[0] !== '[') { // if value is not an Object or Array + return nativeJson; } - let cleanObj = JSON.parse(native); + let cleanObj = JSON.parse(nativeJson); return jsonStringify(sortKeys(cleanObj), null, space); };