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

timeywimey

v0.5.0

Published

A task scheduler and idle-detector for JavaScript. Goes ding when there's stuff.

Downloads

1

Readme

Timeywimey Device

Timeywimey Device

A task scheduler and idle-detector for JavaScript.

Purpose

Sometimes, a task takes a long time to run. During those sometimes, we also sometimes need to update the data which will power that task. (Animations, for example.) As such, we want to be able to execute the task, but only after we have the most up to date data.

Or, if it's an expensive task, we only want to do it when we think the JS engine isn't in the middle of anything, and the user isn't doing anything we'd cause to hang.

In other words, we need a scheduler with a li'l bit of brains in it.

Usage

Scheduling a task is simple:

TW.scheduleTask('breakfast', getSomeCoffee);

Timeywimey is smart enough to execute the task as soon as it can; either when it thinks your app is idle, or when the timer for that specific task occurs, but only if no new calls have been made to it in the meanwhile.

Given the above example, if another task is scheduled for 'breakfast' before it's been triggered:

TW.scheduleTask('breakfast', getSomeYogurt);

The timer is reset, and when it fires it'll trigger both tasks.

Also, if timeywimey thinks that the JS engine isn't doing anything intensive, it'll go ahead and execute your tasks for you.

Options

this.idleThreshold Determines how many ticks pass before timeywimey calls the system "idle".

this.tick Determines how often to check whether the system is working or not.

this.tasks A hash of all the tasks registered for timeywimey. It's possible to browse this hash for various information about the tasks, or to modify them, if for some reason you need to do so.

this.defaultInterval The default amount of time to wait before executing a task. Increasing this provides more time for all tasks to wait before attempting to execute.

API

Pop it in a script tag, use an async loader, or whathaveyou. Provided in vanilla and coffee for your tasting preference.

TW.queueTask(label, callback [, queue]); Schedule callback to be executed when the label task is executed. If the optional queue is true, the callback will be added to a queue, with any existing callbacks. Queueing a task without passing something truthy as the third argument will default to false, which replaces the existing queue for this task with the single callback just passed.

TW.executeTasks(label); Executes all queued tasks for a given queue.

TW.executeIdleTasks(); Used to execute all the queued tasks when the system is idle, but can be called to immediately execute all tasks.

TW.working(); Overrride this with whatever kind of logic and/or graphics you'd like to show when a long-running task occurs.

TW.finished(); Override this with the logic and/or graphics to show then that long-running task completes.

TW.nextTask(); Executes the next task in a given queue immediately, and removes it from the array.

TW.lastTask(); Executes the last (most recently) added task to the queue, and removes it from the array.

TODO

  • [x] Listen for user-input events, such as keyboard and mouse, and integrate with idle checking.
  • [x] Inline docs.
  • [ ] Add to npm.
  • [ ] Add to bower.

Special Thanks

@drpowell had the original idea, and the entire OpenBio Codefest 2013 group, from where this sprung.