npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

inbetween-time

v3.0.1

Published

Iteration tool similar to coroutines. Get the `setInterval()` with the performance of `requestAnimationFrame()` with a new modern roboust API

Readme

Inbetween-time.js

Iteration tool Similar to Unity coroutine. A tool used like you would get from setInterval() but with the perfomace of requestAnimationFrame(). With the the ability to programmatically pause the iterations and resume.

Usage

npm install inbetween-time

Repo

https://github.com/gilbertfrausto/inbetween-time

Examples

https://inbetween-time.web.app/

Example code

https://github.com/gilbertfrausto/inbetween-time/blob/master/examples/index.html

Inbetween time constructor and instance

Options object

| Option | Description | | ------ | ----------- | | timer | Time in ms between each Iteration. | | count | Max number of iterations. | | method | Method to be called for each iteration. | | onComplete | A function to be called when all iterations are complete. |

Inbetween time Instance

| Method | Description | Parameter(s) | Returns | | ----------------- | --------------------------------------------------------------- | -------------------- | --------- | | iterator() | Kicks off the iterations. | none | void | | wait() | Pauses the iterator for a specified time in milliseconds. | yieldTime (number) | void | | getCount() | Gets the total number of iterations to be performed. | none | number | | setCount() | Changes the total number of iterations. | changed (number) | void | | getIterations() | Gets the current number of completed iterations. | none | number | | completed() | Returns true if the iterator has finished, otherwise false. | none | boolean | | pause() | Pauses all iterations until resume() is called. | none | void | | resume() | Resumes iterations after being paused. | none | void |

import inBetweenTime from 'inbetween-time';

let myInstance = inBetweenTime({
	timer: 1000,
	count: 5,
	method: () => {
		console.log(`
			Will fire ${myInstance.getCount()} times!,
			Iteration count ${myInstance.getIterations() + 1}
		`);
	}
});

myInstance.iterator();  // Start iterator
myInstance.wait(2000);  // Pause iteration
myInstance.resume();    // Restarts iterations

Immutable, Data-Oriented API

This version of the API is designed to be immutable and data-oriented. Instead of creating an instance that manages its own state, you create a state object and then use pure functions to transform that state. This makes the logic more predictable and easier to test.

State Object

The state object is a plain JavaScript object that contains all the information about the iterator's state. It has the following properties:

| Property | Description | | ------------- | ------------------------------------------------ | | timer | Time in ms between each Iteration. | | count | Max number of iterations. | | method | Method to be called for each iteration. | | onComplete | A function to be called when all iterations are complete. | | current | The current number of completed iterations. | | paused | true if the iterator is paused, otherwise false. | | isCompleted | true if the iterator has finished, otherwise false. | | lastTime | The timestamp of the last iteration. |

Functions

| Function | Description | Parameter(s) | Returns | | ----------------------- | --------------------------------------------------------------------------- | ------------------------------------------ | ---------------------------- | | createIteratorState() | Creates a new iterator state object. | spec (object) | Readonly<IteratorState> | | pause() | Pauses the iterator. | state (IteratorState) | Readonly<IteratorState> | | resume() | Resumes the iterator. | state (IteratorState) | Readonly<IteratorState> | | setCount() | Changes the total number of iterations. | state (IteratorState), newCount (number) | Readonly<IteratorState> | | setTimer() | Changes the time between iterations. | state (IteratorState), newTimer (number) | Readonly<IteratorState> | | tick() | The core logic of the iterator. Calculates the next state based on the current time. | state (IteratorState), timestamp (number) | Readonly<IteratorState> | | createRunner() | Creates a new runner that manages the iterator's state. | initialState (IteratorState), onStateChange (function) | Readonly<Runner> | | wait() | Pauses the iterator for a specified time in milliseconds. | runner (Runner), yieldTime (number) | void |

Example

import {
  createIteratorState,
  createRunner,
  pause,
  resume,
  wait,
} from 'inbetween-time';

const initialState = createIteratorState({
  timer: 1000,
  count: 5,
  method: () => {
    console.log('Iteration!');
  },
  onComplete: () => {
    console.log('Completed!');
  },
});

const runner = createRunner(initialState, (newState) => {
  console.log('State changed:', newState);
});

// Pause the runner after 2 seconds
setTimeout(() => {
  runner.dispatch(pause);
}, 2000);

// Resume the runner after 4 seconds
setTimeout(() => {
  runner.dispatch(resume);
}, 4000);

// Use wait to pause for a specific duration
wait(runner, 2000);