
Security News
New React Server Components Vulnerabilities: DoS and Source Code Exposure
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.
forkable-iterator
Advanced tools
Make a JS Iterator forkable.
Be aware that if you have a fork that is not consuming values as it gets further and further behind more memory will be used. Make sure you null out references to forks that you no longer need to allow garbage collection to occur.
npm install --save forkable-iterator
Also available on JSDelivr at "https://cdn.jsdelivr.net/npm/forkable-iterator@1".
import { buildForkableIterator, fork } from 'forkable-iterator';
function* Source() {
yield 1;
yield 2;
return 'return';
}
const forkableIterator = buildForkableIterator(source());
console.log(forkableIterator.next()); // { value: 1, done: false }
const child1 = fork(forkableIterator);
// { value: 2, done: false }
console.log(child1.next());
// { value: 2, done: false }
console.log(forkableIterator.next());
// { value: 'return', done: true }
console.log(child1.next());
// { value: 'return', done: true }
console.log(forkableIterator.next());
buildForkableIterator(source)Returns a ForkableIterator from the provided source iterator, which has the same API as Iterator, but can be forked.
To create a fork use the exported fork(forkableIterator) function.
The source iterator must not be read from directly as any forks will miss the values.
The returned ForkableIterator will not implement return() or throw() functions.
fork(forkableIterator)Create a fork of the provided ForkableIterator at the current point.
FAQs
Make a JS Iterator forkable.
The npm package forkable-iterator receives a total of 146 weekly downloads. As such, forkable-iterator popularity was classified as not popular.
We found that forkable-iterator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.