UNPKG

@blinkk/editor

Version:

Structured content editor with live previews.

33 lines 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createPriorityKeySort = void 0; /** * Sort keys based on priority list of keys. They will always be first and in * same order as the priority list. * * @param priorityKeys List of keys that should be sorted before any other keys. */ function createPriorityKeySort(priorityKeys) { return (a, b) => { const isAInPriority = priorityKeys.includes(a); const isBInPriority = priorityKeys.includes(b); if (isAInPriority || isBInPriority) { if (isAInPriority && isBInPriority) { return priorityKeys.indexOf(a) - priorityKeys.indexOf(b); } else if (isAInPriority) { return -1; } return 1; } if (a < b) { return -1; } if (a > b) { return 1; } return 0; }; } exports.createPriorityKeySort = createPriorityKeySort; //# sourceMappingURL=prioritySort.js.map