acted
flexible and composable actor library
Last updated 7 months ago by nikhedonia .
ISC · Repository · Bugs · Original npm · Tarball
$ cnpm install acted 
SYNC missed versions from official npm registry.

#acted

actor library for js

example

import {actor, timeWindowed, worker} from 'acted'

let log = actor(function*(next){
  const value = yield next();
  console.log(value);
})


console.log('logger is asnyc');
log(1);
console.log('logger returns promise');
log(2).then( _=> console.log('logging complete') )

const slowLog = timeWindowed( log, 1000 );

slowLog(3).then( ()=> console.log('executes task and moves on to next task when at least 1 second has passed') )
slowLog(4).then( ()=> console.log('does start timer with task') )



let sortedLog = actor(function*(next){
  const value = yield next();
  console.log(value);
}, q => { q = q.sort(); return q.shift(); })


//sorts the batch of items before running
sortedLog(2);
sortedLog(1);
sortedLog(3);



//performs async work
const run = actor(worker);
run( x=>1 ).then( x=> console.log('done :', x) );
run( x=>2 ).then( x=> console.log('done :', x) );

Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (1)
  • co ^4.6.0
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |