h13i32maru / eo

Generator based flow control and DOM event loop for JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status

eo

eo is generator based flow control (like tj/co) and DOM event loop.

eo supports Promise, WHATWG Streams(Readable/Writable) and DOM event(click, touch, etc).

Install

TODO: publish to npmjs.com

Example

basic control flow.

eo(function*(){
  console.log('sleep...');
  var result = yield sleep(200);
  console.log('wake!', result);

  return 'finish!';
}).then((val)=>{
  console.log(val); // finish!
});

with ReadableStream.

eo(function*(){
  var rs = new SampleReadableStream();
  var data;
  while((data = yield rs) !== eo.EOF) {
    console.log('data', data);
  }
  console.log('finish');
});

with WritableStream.

eo(function*(){
  var ws = new SampleWritableStream();
  var data = [1, 2, 3, 4, eo.EOF];
  for (var chunk of data) {
    yield [ws, chunk];
  }

  console.log('finish');
});

with DOM event.

  var click = new eo.DOMEventStream('#box', 'click');
  eo.loop(function*(){
    var event = yield click;
    console.log('event', event);
  });

see example

Document

TODO: write document.

LICENSE

MIT

About

Generator based flow control and DOM event loop for JavaScript.

License:MIT License


Languages

Language:JavaScript 76.0%Language:CSS 20.6%Language:Shell 3.4%