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

bergson

v0.16.0

Published

Time and scheduling for the web

Downloads

16

Readme

Bergson

What is Bergson?

Bergson is the scheduling system for Flocking and Aconite. It provides a variety of clocks driven by different sources (such as requestAnimationFrame, the Web Audio API, and setInterval), and a priority queue-based scheduler that allows you to queue up one-time and repeating function calls.

Bergson provides a very low-level API for scheduling, and is intended for library developers to build their own rhythmic and pattern-based abstractions on top of.

Examples

Creating a Scheduler with the requestAnimationFrame Clock

var scheduler = berg.scheduler({
    components: {
        clock: {
            type: "berg.clock.requestAnimationFrame",
            options: {
                freq: 60
            }
        }
    }
});

scheduler.start();

Scheduling one-time events

scheduler.schedule({
    type: "once",
    time: 30            // 30 seconds from now
    callback: function (now) {
        // Do something in the future.
    }
});

Scheduling repeating events

scheduler.schedule({
    type: "repeat",
    time: 5,            // Start repeating five seconds from now.
    freq: 2,            // Repeat every two seconds.
    end: 20,            // Stop repeating 20 seconds from now.
    callback: function (now) {
        // Do something repeatedly.
    }
});

Listening for Clock Events Directly

scheduler.clock.events.onTick.addListener(function (time, rate) {
    // Do something every time the clock ticks.
});

Bergson API

Scheduler API

Score Event Specifications

A score event specification is a JSON-type (i.e. plain old, non-prototypal) object that describes the event to be scheduled. It can contain the following properties.

Scheduler Model

For more information on interacting with models, see the Infusion documentation about the Change Applier.

Scheduler Members

Scheduler Methods

Clock API

Clock Members

Clock Methods

Clock Events

Types of Clocks

Building and Testing Bergson

Prerequisites

Bergson uses Node.js, npm, Grunt, and Testem for its build and test tooling. Here's how to get set up:

1. Install the [Node.js](https://nodejs.org/en/) LTS release
3. Install Grunt: <code>npm install -g grunt-cli</code>
4. Install Testem: <code>npm install -g testem</code>

How to Build Bergson

To download all of Bergson's dependencies, build them, and then build Bergson itself, run the following commands:

npm install
grunt

Running Bergson's Test Suite

Bergson's test suite can be run on both Node.js and all of the browsers installed on your computer using Testem:

npm test

If you'd like to run only the Node.js tests, run:

npm run node-test

Or if you only want to run the browser tests:

npm run browser-test

Alternatively, if you'd like to only run the tests in one browser, you can open the test suite tests/unit/all-tests.html file by hand in your browser.

Community

Bergson is supported by the Flocking community and uses its forums:

Mailing List

The Flocking mailing list is the place to ask questions, share code, and request new features.

Chat

Flocking has an IRC channel, which can also be used to ask questions about Bergson. Join #flocking on irc.freenode.net.

Credits and License

Bergson is written and maintained by Colin Clark. It is dually licensed under the MIT and GPL 2.0 licenses.