Skip to content
measure how fast your objects are changing
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
examples
test
.gitignore
README.md
foo.js
index.js
package.json

README.md

velocity

var V = require('./index');
var velocity = V();

var x = [];

x = velocity.watch(x);
x.follow('push');   
x.push('foo');
setTimeout(function(){
    x.push('bar');
    setTimeout(function(){
        x.push('baz');
        setTimeout(function(){
            x.push('qux');
            console.log(x.getVelocity('push') + " pushes per second.");
        },200);
    },200);
},200);


> 4 pushes per second.

Velocity is a small and simple tool that allows you to measure how many times a method is called by .watch(ing) the object you are concerned with and then following the methods you care about with .on('').

Methods

.watch(obj)

Pass watch an object you want to watch. Returns the watched version of the item.

.follow('method')

Follow the rate of which obj.method is called where obj is from .watch.

.on('method',fn)

Follow the rate of which obj.method is called where obj is from .watch. Identical in functionality as .follow with the added bonus of allowing you to attach a callback on the method call.

.getVelocity('method')

Returns the rate (in whole number) of the number of times method is called per second.

Something went wrong with that request. Please try again.