UNPKG

bananas-commerce-admin

Version:

What's this, an admin for apes?

32 lines 972 B
/** * Filters and organizes UI component contributions by tags. * * @param {ContribComponentMap} map - Component map as imported/exported from BCOM * @param {string[]} filter - Optional tags to filter and order components * @returns {ContribComponentListItem[]} * * @example * // Get all contribs * contribute(Bananas.subscription.contrib.dashboard); * * @example * // Get specific contribs in order * contribute(Bananas.subscription.contrib.dashboard, "dashboard:stats:subscription:events", "dashboard:stats:subscription:count"); */ export const contribute = (map, ...filter) => { if (map == null) return []; if (filter && filter.length > 0) { return filter .filter((tag) => tag in map) .map((tag) => ({ tag, contrib: map[tag], })); } return Object.entries(map).map(([tag, contrib]) => ({ tag, contrib, })); }; //# sourceMappingURL=contribute.js.map