Skip to content

Commit

Permalink
Merge pull request #7 from marekpalenik/patch-1
Browse files Browse the repository at this point in the history
replace js keyword native
  • Loading branch information
ThomasR authored Jan 13, 2017
2 parents d2fccd9 + 82828a1 commit fda2d90
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 fda2d90

Please sign in to comment.