
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A circular list you never knew you needed
cartwheel takes an array (or any array-like/iterable) and gives you a circular iterator. You can ask for the next or previous value any number of times, and it will keep cycling through the list.
npm install cartwheel
<script src="https://unpkg.com/cartwheel@1.1.0"></script>
Or if you want to host it yourself, go to releases and download cartwheel.umd.min.js. Then:
<script src="cartwheel.umd.min.js"></script>
import cartwheel from "cartwheel";
// Pass an iterable
const items = ["Ed", "Edd", "Eddy"];
const iterator = cartwheel(items);
// Start iterating
iterator.nextValue();
// Ed
iterator.nextValue();
// Edd
iterator.nextValue();
// Eddy
// It‘s circular, remember?
iterator.nextValue();
// Ed
// Standard ES iterator protocol if you like
iterator.next();
// { value: 'Edd', done: false }
// `done` will always be false though
iterator.next();
// { value: 'Eddy', done: false }
// Rewind
iterator.previousValue();
// Edd
iterator.previousValue();
// Ed
// They see me rollin‘, they hatin‘
iterator.previousValue();
// Eddy
// Iterator protocol again
iterator.previous();
// { value: 'Edd', done: false }
cartwheel(iterable) returns an iterator object with the following methods:
next()Returns the next item to what you last accessed. If it is the first call, returns the first item in the iterable. done is always false.
Example: { value: 42, done: false }
nextValue()Same as next(), but returns the value directly.
previous()Returns the previous item to what you last accessed. If it is the first call, returns the last item in the iterable. done is always false.
Example: { value: 1337, done: false }
previousValue()Same as previous(), but returns the value directly.
Anywhere you want to iterate a list of items in a circular “round robin” fashion. Think keyboard-navigable menus, tabs, carousels and typeahead suggestions.
Yes. It works with anything that is compatible with Array.from().
Kind of. It does offer a similar API, but the implementation looks nothing like a linked list.
FAQs
A circular list you never knew you needed
We found that cartwheel 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.