sla

A module which avoid boilerplate code when coding an SLA function in Node

npm install sla
8 downloads in the last month

node-sla

A tiny SLA node module that avoids setTimeout boilerplate code and allows an elapsed callback to be passed.

Example

var sla = require('sla');

//Will execute the code in the first callback
sla(1000, function(done) {
    console.log("Waiting....");
    setTimeout(done,900);
  }, function() {
    console.log("Elapsed");
  });

//Will execute the code in the second(elapsed) callback
sla(1000, function(done) {
    console.log("Waiting....");
    setTimeout(done,1001);
  }, function() {
    console.log("Elapsed");
  });

Installation

$ npm install sla
npm loves you