sindresorhus/p-map

Allow breaking from iterator

Open

#31 aberto em 13 de out. de 2020

Ver no GitHub
 (15 comments) (0 reactions) (0 assignees)JavaScript (66 forks)user submission
enhancementhelp wanted

Métricas do repositório

Stars
 (1.499 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

I wish I could stop the iteration early by returning something like pMap.stop (a Symbol) from the iterator.

This is basically the same request as https://github.com/sindresorhus/p-each-series/issues/3

For now, I have to throw an error on purpose just to break it. Thankfully, I don't need the return value of p-map anyway.

But with this feature, the parts of the array that weren't computed yet could be set to undefined, or pMap.uncomputed (another Symbol), or even be specified by a valueForUncomputedEarlyStop option.

Can I do a PR?

Guia do colaborador