export async function mapAsync<T, R = T> ( arr: T[], cb: (el: T, i: number, a0: T[]) => Promise<R>, ): Promise<R[]> { return Promise.all(arr.map(async (el, i, a0) => { return await cb(el, i, a0) })) } export function distinctBy<T> (arr: T[], k: string, undefinedIsDistinct?: boolean): T[] { const arrK = arr.map((a) => hash((a as any)[k])) return arr.filter((a, i) => { const aK = (a as any)[k] if (aK === undefined) { return !!undefinedIsDistinct } else { return arrK.indexOf(hash(aK)) === i } }) } export function * chunk<T> (arr: T[], n: number) { for (let i = 0; i < arr.length; i += n) { yield arr.slice(i, i + n) } }
Are you trying to create next lodash or something?
lodash
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Are you trying to create next
lodash
or something?