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

nsynq-js

v0.1.0-alpha

Published

Schedule JavaScript operations along a timeline progression defined by `n`

Downloads

5

Readme

*nsynq

Schedule JavaScript operations along a timeline progression defined by n

About

CSS animations are nice, but what if you want to do some heavier things? Something more interactive and in sync with other tandem operations like audio and video? *nsynq could be your friend indeed.

I wanted to have some operations play at certain points on a timeline, e.g. co-ordinated to specific streaming music files, and I wanted a really easy way to notate the points on the timeline, so I built this! It seems to work OK so far...

Installation

Node.JS

npm install nsynq-js

Bower

bower install nsynq-js

Dependencies

Works out of the box. Doesn't require any external libraries.

Usage

*nsynq assumes that you've got a timeline that progresses from zero to timelineLength. Any point along that timeline is defined as n. We also define an object that holds the operations you wish to perform and any expression statements that those operations will get fired at point n:

var output = document.getElementById('output');

// The length of the timeline to render. Must always have a fixed length
var timelineLength = 200;

// The operations object containing the expressions and operations to fire
var operations = {
  'when n eq 0': function () {
    output.innerHTML = '<h1>Let us begin...</h1>';
  },
  'do per 1 n': function () {
    output.innerHTML += '<br>&nbsp;&nbsp;&nbsp;' + n + ' : ';
  },
  'when n around 40:2': function ( n ) {
    output.innerHTML += ' (around 40:2, matches >= 38 && <= 42)';
  },
  'when n gte 150, do approx 10:2 n': function ( n ) {
    output.innerHTML += ' <strong>Holla at you from ' + n + '</strong>';
  },
  'when n within 50-150, do per 10 n': function ( n ) {
    output.innerHTML += ' (within 50-150, per 10 n)';
  },
  'do per 8 n': function ( n ) {
    output.innerHTML += ' <em>(' + n + ' is an 8 baller)</em>';
  },
  'when n eq 200': function () {
    output.innerHTML += '<h3>... Baby, bye-bye-bye (the end)</h3>';
  }
};

var nsynqWatcher = new Nsynq( timelineLength, operations );
var n = 0;

function animate() {
  requestAnimationFrame( animate );

  if ( n <= timelineLength ) {
    nsynqWatcher.seek(n);
    n++;
  }
}

animate();

See the basic example to view how the above code behaves.

Todo

  • Pre-computing makes it faster when playing back timeline operations, but perhaps I could put in a switch to choose between dynamic or static timeline behaviours
  • Figure out better compensation from frame skipping (approx and around expressions can kind of do that, but it's not entirely perfect)

Releases

0.1.0-alpha

  • Initial version of API behaviours

Licence

MIT