sindresorhus/p-map

Allow breaking from iterator

開放

#31 建立於 2020年10月13日

 (15 則留言) (0 個反應) (0 位負責人)JavaScript (66 個分叉)user submission
enhancementhelp wanted

倉庫指標

星標
 (1,499 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

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?

貢獻者指南