templural
Version:
Template function for plural-sensitive formatting
14 lines • 771 B
JavaScript
const defaultCategoryPriority = ['other', 'one', 'two', 'few', 'many', 'zero'];
const defaultCategoryOrder = ['zero', 'one', 'two', 'few', 'many', 'other'];
export function resolveCategoryOrders(pluralCategories, options) {
const { categoryPriority = defaultCategoryPriority, categoryOrder = defaultCategoryOrder } = options !== null && options !== void 0 ? options : {};
const categories = [];
categoryPriority
.filter(c => pluralCategories.includes(c))
.forEach(c => {
var _a;
categories.push([...((_a = categories[categories.length - 1]) !== null && _a !== void 0 ? _a : []), c].sort((c1, c2) => categoryOrder.indexOf(c1) - categoryOrder.indexOf(c2)));
});
return categories;
}
//# sourceMappingURL=categories.js.map