Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Reconsider use of pipe #44

Closed
dapplion opened this issue Oct 28, 2022 · 2 comments · Fixed by #69
Closed

Reconsider use of pipe #44

dapplion opened this issue Oct 28, 2022 · 2 comments · Fixed by #69
Labels
help wanted Extra attention is needed P4 Very low priority

Comments

@dapplion
Copy link

pipe is shown to be an expensive abstraction. In this specific use case it looks like a regular for loop would be enough.

async function filterMultiaddrs (peerId: PeerId, multiaddrs: Multiaddr[], addressFilter: AddressFilter, isCertified: boolean = false) {
return await pipe(
multiaddrs,
(source) => each(source, (multiaddr) => {
if (!isMultiaddr(multiaddr)) {
log.error('multiaddr must be an instance of Multiaddr')
throw errcode(new Error('multiaddr must be an instance of Multiaddr'), codes.ERR_INVALID_PARAMETERS)
}
}),
(source) => filter(source, async (multiaddr) => await addressFilter(peerId, multiaddr)),
(source) => map(source, (multiaddr) => {
return {
multiaddr,
isCertified
}
}),
async (source) => await all(source)
)
}

@p-shahi p-shahi moved this to Weekly Candidates/Discuss in js-libp2p Nov 15, 2022
@mpetrunic mpetrunic moved this from Weekly Candidates/Discuss to Backlog in js-libp2p Nov 15, 2022
@p-shahi
Copy link
Member

p-shahi commented Nov 22, 2022

Keeping this as low priority for now

@tinytb tinytb added help wanted Extra attention is needed P4 Very low priority labels Dec 2, 2022
@p-shahi p-shahi moved this from 🪵Backlog to 🧊Icebox🥶 in js-libp2p Dec 6, 2022
@p-shahi p-shahi moved this from 🧊Icebox🥶 to 🪵Backlog in js-libp2p Dec 6, 2022
achingbrain added a commit that referenced this issue Mar 2, 2023
Every iteration of every pipeline function in `it-pipe` crosses an
async boundary so it can harm performance if your pipleline would
otherwise be synchronous.

Fixes #44
achingbrain added a commit that referenced this issue Mar 2, 2023
Every iteration of every pipeline function in `it-pipe` crosses an
async boundary so it can harm performance if your pipleline would
otherwise be synchronous.

Fixes #44
@github-project-automation github-project-automation bot moved this from 🪵Backlog to 🎉Done in js-libp2p Mar 2, 2023
github-actions bot pushed a commit that referenced this issue Mar 2, 2023
## [6.0.4](v6.0.3...v6.0.4) (2023-03-02)

### Bug Fixes

* remove it-pipe ([#69](#69)) ([dcf2e8e](dcf2e8e)), closes [#44](#44)
@github-actions
Copy link

github-actions bot commented Mar 2, 2023

🎉 This issue has been resolved in version 6.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed P4 Very low priority
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants