seereal

A simple bit of code to enable serialization of JavaScript

Usage no npm install needed!

<script type="module">
  import seereal from 'https://cdn.skypack.dev/seereal';
</script>

README

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