JSPM

  • Created
  • Published
  • Downloads 411
  • Score
    100M100P100Q92027F
  • License MIT

a runtime interface

Package Exports

  • runtime
  • runtime/lib/hrtime

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (runtime) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

buildNPM version Gitter

Getting started - Documentation - Examples - Implementation status - License

The aim of the project is to provide an easy an non opinionated container to develop Runtime Interfaces being the main focus of the library to abstract async function composition into one function. In addition, and to make it expressive, some features were added:

  • path-to-regex mapping
  • a small declarative Stack API for each stack
  • completion with a callback, always on the 1st argument, that is in charge of passing arguments down to other functions on the same stack. Completion using the return value with async-done that supports completion when returning a stream, promise or an observable.

Changing from this

handleOne(function(err, value){
  if(err){ throw err; }
  handleTwo(function (err, value2){
    // etc.
  })
})

to this

var app = require('runtime').create();

function one(next, input){
  next(null, input, 'value');
}

function two(next, input, value){
  console.log(input, value);
  next();
}

var handle = app.stack(one, two, {
  wait: true
  onHandleNotFound: function(err, next){
    throw err;
  }
});

handle('input');

Getting started

Install runtime using npm

npm install runtime

and then require it into a module

var app = require('runtime').create();

app.set(':handle', function(next){
  setTimeout(next, Math.random()*10);
})

app.stack('1 2 3 4 5 6')();
app.stack('one two three four five six', {wait: true})();

Browser

At the moment is not tested in browsers but it should work. Use it at your own risk though :). Either a browserify or webpack bundle.js should do the trick.

Documentation

module.exports - Runtime API - Stack API

If you have something to ask, feel free to open an issue or come and chat in gitter with any questions. I wouldn't mind at all.

Examples

There are some use cases you can find at the examples directory.

Implementation status

growing a beard feels goood

status: unstable

It's been a while since the project started and finally is getting there. At the moment, the library needs polishing since it has some rough edges I'm working on. Is tested and usable but I want to fix some stuff I'm not really proud about. In any case, the top level API should not suffer any change.

I'll be using it everywhere so the first user involved here is me.

License

License