bonsai-analyzer
Version:
Trim your dependency tree.
29 lines (24 loc) • 587 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = sortModules;
function checkDirection(direction, sort) {
if (sort === 0 || direction === 'ASC') {
return sort;
} else {
return sort > 0 ? -1 : 1;
}
} // flowlint-next-line unclear-type:off
function compare(a, b) {
return a === b ? 0 : a > b ? 1 : -1;
}
function sortModules(extendedModules, sort) {
return extendedModules.sort((a, b) => {
const {
field,
direction
} = sort;
return checkDirection(direction, compare(a[field], b[field]));
});
}