Skip to content

Commit

Permalink
Merge pull request #34 from purescript-contrib/joneshf-patch-1
Browse files Browse the repository at this point in the history
Inline `objToString` and `objKeys`
  • Loading branch information
thomashoneyman authored Sep 2, 2019
2 parents 1a9a4d8 + 9a25bce commit 50a0af2
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Data/Argonaut/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@ exports.stringify = function (j) {
return JSON.stringify(j);
};

var objToString = Object.prototype.toString;
var objKeys = Object.keys;

function isArray(a) {
return objToString.call(a) === "[object Array]";
return Object.prototype.toString.call(a) === "[object Array]";
}

exports._caseJson = function (isNull, isBool, isNum, isStr, isArr, isObj, j) {
if (j == null) return isNull();
else if (typeof j === "boolean") return isBool(j);
else if (typeof j === "number") return isNum(j);
else if (typeof j === "string") return isStr(j);
else if (objToString.call(j) === "[object Array]")
else if (Object.prototype.toString.call(j) === "[object Array]")
return isArr(j);
else return isObj(j);
};
Expand Down Expand Up @@ -83,8 +80,8 @@ exports._compare = function _compare (EQ, GT, LT, a, b) {
else if (typeof b === "string") return GT;
else if (isArray(b)) return GT;
else {
var akeys = objKeys(a);
var bkeys = objKeys(b);
var akeys = Object.keys(a);
var bkeys = Object.keys(b);
if (akeys.length < bkeys.length) return LT;
else if (akeys.length > bkeys.length) return GT;
var keys = akeys.concat(bkeys).sort();
Expand Down

0 comments on commit 50a0af2

Please sign in to comment.