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 🙏

© 2024 – Pkg Stats / Ryan Hefner

cycl

v1.1.0

Published

A process manager running on a unified requestAnimationFrame loop

Downloads

8

Readme

Cycl

A 1.5kb process manager running on a single requestAnimationFrame loop. Every process has a callback that, when active, fires once per frame.

Install

NPM + Browserify (recommended)

First install Cycl in your project root.

$ npm install cycl

Then include in your module using require().

var cycl = require('cycl');

File include

Download the latest cycl.global.min.js from http://github.com/InventingWithMonster/cycl and include it in your HTML document with a script tag, ie:

<script src="/path/to/cycl.global.min.js"></script>

This will load Cycl to the global scope as window.cycl, accessible in any script executed subsequently.

Use

Example process

var process = cycl.newProcess(function (framestamp) {
    console.log('hello world! ' + framestamp);
});

process.start(); // Will output 'hello world' and the timestamp of the executing frame

To run a function with Cycl, we first have to create a new process. Active processes are fired once per frame.

Create a new process

The method newProcess takes the optional parameter scope, and a callback. If scope is provided, our callback executes in its context (this refers to scope). Otherwise the process itself is used as the context.

var process = cycl.newProcess(scope, callback);

Start a process

On creation, a process is not active. To start it, we simply call .start().

process.start(); // Our process runs

Stopping a process

We can stop this process with .stop().

process.stop(); // Our process stops

Run a process for a specific amount of time

Processes can be set to stop after a predefined period of time by passing start() a duration argument (in ms).

process.start(1000); // Our process runs for 1000ms

Run process every x seconds

Processes can be set to fire at regular intervals, like a framerate-locked setInterval().

process.every(100); // Our process runs once every 100ms

Change scope and callback

The scope and callback of a process can be changed with .setCallback() and setScope(). All these process methods can be chained.

process
    .setScope(newScope)
    .setCallback(newCallback)
    .start();

Kill a process (for garbage collection)

To remove a process from memory, you first need to run .kill(), which will delete it from cycl's internal tracking. Then delete any references to that object.

process.kill(); // Process is removed from Cycl, but still exists
delete process; // Now references to process are removed, garbage collection can take place.