UNPKG

contexify

Version:

A TypeScript library providing a powerful dependency injection container with context-based IoC capabilities, inspired by LoopBack's Context system.

33 lines 1.19 kB
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); function compareBindingsByTag(phaseTagName = "phase", orderOfPhases = []) { return (a, b) => { return compareByOrder(a.tagMap[phaseTagName], b.tagMap[phaseTagName], orderOfPhases); }; } __name(compareBindingsByTag, "compareBindingsByTag"); function compareByOrder(a, b, order = []) { a = a ?? ""; b = b ?? ""; const i1 = order.indexOf(a); const i2 = order.indexOf(b); if (i1 !== -1 || i2 !== -1) { return i1 - i2; } if (typeof a === "symbol" && typeof b === "string") return -1; if (typeof a === "string" && typeof b === "symbol") return 1; if (typeof a === "symbol") a = a.toString(); if (typeof b === "symbol") b = b.toString(); return a < b ? -1 : a > b ? 1 : 0; } __name(compareByOrder, "compareByOrder"); function sortBindingsByPhase(bindings, phaseTagName, orderOfPhases) { return bindings.sort(compareBindingsByTag(phaseTagName, orderOfPhases)); } __name(sortBindingsByPhase, "sortBindingsByPhase"); export { compareBindingsByTag, compareByOrder, sortBindingsByPhase }; //# sourceMappingURL=binding-sorter.js.map