0.0.8 • Published 7 years ago

jumpin v0.0.8

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Jumpin

An emitter-like way to distributively create and modify objects.

Install

$ npm install jumpin --save

Usage

const Jumpin = require('jumpin');
const emitter = new Jumpin();
const allPredicate = () => true;
const timePredicate = (data) => {
    return typeof data.time === 'number';
};

emitter.on(allPredicate, (obj) => {
    obj.time = Date.now();
    //returning true means that failed predicates will be reexamine
    //note: listeners that were invoked in this cycle won't get invoke again
    //returning false or undefined means that failed predicates might not get reexamined
    return true;
});

//async operation - will delay main pipeline
emitter.on(timePredicate, (obj) => {
    return new Promise((resolve) => {
        setTimeout(() => {
            obj.time = new Date(obj.time).toISOString();
            return resolve(false);
        }, 250);
    });
});

emitter.trigger({
        type: 'first-event'
    })
    .then((data) => {
        console.log(data.type); //log 'first-event'
        console.log(data.time); //log formatted date
    });

API

Full API documentation is yet to be written, but you can view the source and examples.

Change Log

Jumpin v0.0.8

  • fix usage as node module

Jumpin v0.0.7

  • update package.json

Jumpin v0.0.6

  • update documentation

Jumpin v0.0.5

  • update documentation

Jumpin v0.0.4

  • update documentation
  • minor changes

Jumpin v0.0.3

  • fix bug in rerun mechanism

Jumpin v0.0.2

  • use PromiseCtor instead of promiseFactory

Jumpin v0.0.1

  • first release (beta)
0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago