Comparing version 1.2.1 to 1.2.2
35
index.js
'use strict'; | ||
var dotProp = require('dot-prop'); | ||
var arrify = require('arrify'); | ||
var dotPropGet = dotProp.get; | ||
@@ -13,29 +14,29 @@ | ||
(Array.isArray(prop) ? prop : [prop]).forEach(function (el) { | ||
var x = a; | ||
var y = b; | ||
arrify(prop).some(function (el) { | ||
var x; | ||
var y; | ||
if (typeof el === 'function') { | ||
x = el(x); | ||
y = el(y); | ||
x = el(a); | ||
y = el(b); | ||
} else if (typeof el === 'string') { | ||
x = dotPropGet(a, el); | ||
y = dotPropGet(b, el); | ||
} else { | ||
x = a; | ||
y = b; | ||
} | ||
if (typeof el === 'string') { | ||
x = dotPropGet(x, el); | ||
y = dotPropGet(y, el); | ||
} | ||
// lower priority for each prop | ||
ret++; | ||
if (x === y) { | ||
return; | ||
ret = 0; | ||
return false; | ||
} | ||
if (typeof x === 'string' && typeof y === 'string') { | ||
ret += x.localeCompare(y); | ||
return; | ||
ret = x.localeCompare(y); | ||
return ret !== 0; | ||
} | ||
ret += x < y ? -1 : 1; | ||
ret = x < y ? -1 : 1; | ||
return true; | ||
}); | ||
@@ -42,0 +43,0 @@ |
{ | ||
"name": "sort-on", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Sort an array on an object property", | ||
@@ -36,2 +36,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"arrify": "^1.0.0", | ||
"dot-prop": "^2.0.0" | ||
@@ -38,0 +39,0 @@ }, |
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
3767
37
2
+ Addedarrify@^1.0.0
+ Addedarrify@1.0.1(transitive)