25 lines
474 B
JavaScript
25 lines
474 B
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = sortByKeyOrder;
|
|
|
|
function findIndex(arr, err) {
|
|
let idx = Infinity;
|
|
arr.some((key, ii) => {
|
|
var _err$path;
|
|
|
|
if (((_err$path = err.path) == null ? void 0 : _err$path.indexOf(key)) !== -1) {
|
|
idx = ii;
|
|
return true;
|
|
}
|
|
});
|
|
return idx;
|
|
}
|
|
|
|
function sortByKeyOrder(keys) {
|
|
return (a, b) => {
|
|
return findIndex(keys, a) - findIndex(keys, b);
|
|
};
|
|
} |