Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple pMapSkip's #52

Merged

Conversation

ferrinweb
Copy link
Contributor

@ferrinweb ferrinweb commented Sep 30, 2021

like this:

console.log(await pMap([1, pMapSkip, 2, pMapSkip, 3], async value => value)) // [1, 2, 3]

@sindresorhus
Copy link
Owner

@huntharo Would you be willing to help review?

Copy link
Contributor

@huntharo huntharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to address the O(n^2) complexity on the number of pMapSkip items and fix the existing performance issue with the usage of .splice() in a loop.

I left an example of how to test the performance and how to change the .unshift() usage back to .push() with a loop that does a .pop() (using the array as a O(1) stack). The only remaining work would be to implement the super splice loop that loops through result only a single time and touches each item only a single time.

index.js Outdated Show resolved Hide resolved
test.js Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@sindresorhus sindresorhus changed the title Add support for multiple pMapSkips Add support for multiple pMapSkips Nov 2, 2021
@sindresorhus sindresorhus changed the title Add support for multiple pMapSkips Add support for multiple pMapSkip's Nov 2, 2021
@sindresorhus sindresorhus merged commit 94eb532 into sindresorhus:main Nov 2, 2021
@sindresorhus
Copy link
Owner

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants