Estoy tratando de eliminar lodash de mi proyecto y una de las funciones que usamos es ._chain. Se está usando así:
chain(sortedItems || allItems) .filter((x) => this.filterItemsBySearchParam<T>(x, search)) .filter((x) => this.filterItemsByFacets<T>(x, facets)) .groupBy((x) => (groupBy ? [groupBy.split(',').map((path) => get(x, path))] : '')) .map((filteredItems: any, key) => { ...Intenté esto, pero no pude hacerlo funcionar:
private chain(value) { return { /** * @param {function|string} func function or function name (in chained value) * @param {...any} args */ filter(func, ...args) { if (typeof func === 'string') { return chain(value[func](...args)); } return chain(func(value, ...args)); }, value: () => value, }; }¿Hay una mejor manera de lograr esto?