Skip to content

Commit

Permalink
replace js keyword native
Browse files Browse the repository at this point in the history
please change name of variable native to something else, as it is also a javascript keyword, and e.g. some minifiers fail on it.
  • Loading branch information
marekpalenik authored Nov 21, 2016
1 parent d2fccd9 commit 82828a1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down

0 comments on commit 82828a1

Please sign in to comment.