array-tools
Advanced tools
Comparing version 1.4.4 to 1.4.5
@@ -423,5 +423,16 @@ "use strict"; | ||
return function tryIt(a, b){ | ||
var x = a[property] || null; | ||
var y = b[property] || null; | ||
var result = x < y ? -1 : x > y ? 1 : 0; | ||
var result; | ||
var x = a[property]; | ||
var y = b[property]; | ||
if (typeof x === "undefined" && typeof y !== "undefined"){ | ||
result = -1; | ||
} else if (typeof x !== "undefined" && typeof y === "undefined"){ | ||
result = 1; | ||
} else if (typeof x === "undefined" && typeof y === "undefined"){ | ||
result = 0; | ||
} else { | ||
var result = x < y ? -1 : x > y ? 1 : 0; | ||
} | ||
if (result === 0){ | ||
@@ -428,0 +439,0 @@ if (props.length){ |
{ | ||
"name": "array-tools", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "1.4.4", | ||
"version": "1.4.5", | ||
"description": "Useful functions for working with arrays", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/75lb/array-tools.git", |
@@ -37,1 +37,8 @@ var test = require("tape"); | ||
}); | ||
test("sortBy, with undefined vals 2", function(t){ | ||
var fixture = [ { a: "yeah" }, { }, { a: "what" } ]; | ||
var expected = [ { }, { a: "what" }, { a: "yeah" } ]; | ||
t.deepEqual(a.sortBy(fixture, "a"), expected); | ||
t.end(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34943
682