Skip to content

A simple bit of code to enable serialization of JavaScript functions.

Notifications You must be signed in to change notification settings

ben-bradley/seereal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Seereal

I like async, but I don't like putting dependencies in my code so I figured out how to use just the parts I wanted.

There are a lot of other projects that do the exact same thing and a whole lot more, but this one is mine.

And I think it's pretty.

Example

var serial = require('./');

function a(next) {
  setTimeout(function () {
    console.log('A');
    next(null, 'A');
  }, 1000);
}

function b(next) {
  setTimeout(function () {
    console.log('B');
    next(null, 'B');
  }, 100);
}

function e(next) {
  setTimeout(function () {
    console.log('making an error');
    next(new Error('fake error'));
  }, 500);
}

serial([a, b], function (err, results) {
  console.log(results); // => [ 'A', 'B' ]
});

serial([b, a], function (err, results) {
  console.log(results); // => [ 'B', 'A' ]
});

serial([a, e, b], function (err, results) {
  console.log(results); // => [ 'A' ]
  console.log(err.message); // => 'fake error'
});

Other Projects

About

A simple bit of code to enable serialization of JavaScript functions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages