mirror of
https://github.com/morhetz/gruvbox.git
synced 2025-11-16 15:23:47 -05:00
chore(package): re-init package with commitizen and standard-release
This commit is contained in:
42
node_modules/compare-func/index.js
generated
vendored
Normal file
42
node_modules/compare-func/index.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
var arrayify = require('array-ify');
|
||||
var dotPropGet = require('dot-prop').get;
|
||||
|
||||
function compareFunc(prop) {
|
||||
return function(a, b) {
|
||||
var ret = 0;
|
||||
|
||||
arrayify(prop).some(function(el) {
|
||||
var x;
|
||||
var y;
|
||||
|
||||
if (typeof el === 'function') {
|
||||
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 (x === y) {
|
||||
ret = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof x === 'string' && typeof y === 'string') {
|
||||
ret = x.localeCompare(y);
|
||||
return ret !== 0;
|
||||
}
|
||||
|
||||
ret = x < y ? -1 : 1;
|
||||
return true;
|
||||
});
|
||||
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = compareFunc;
|
||||
Reference in New Issue
Block a user