sequeue

very basic sequential function queue

Usage no npm install needed!

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

README

sequeue

# installation
$ npm install sequeue

Sequeue can be used in node, with AMD (require.js) or without any module loader.

Node:

var sequeue = require('sequeue');

sequeue([
  function(next) {
    setTimeout(function() {
      console.log(1);
      next();
    }, 1000);
  },
  function() {
    console.log(2);
    // last function should not call next()
    // otherwise you will get an "undefined is not a function"
  }
]);

// will output:
// 1
// 2

AMD:

define(['./sequeue'], function (sequeue) {
  // usage
  var sequeue = require('sequeue');


  sequeue([
    function(next) {
      setTimeout(function() {
        console.log(1);
        next();
      }, 1000);
    },
    function() {
      console.log(2);
      // last function should not call next()
      // otherwise you will get an "undefined is not a function"
    }
  ]);

  // will output:
  // 1
  // 2
});

Without module loader:

(function(window) {
  // usage
  var sequeue = window.sequeue;

  sequeue([
    function(next) {
      setTimeout(function() {
        console.log(1);
        next();
      }, 1000);
    },
    function() {
      console.log(2);
      // last function should not call next()
      // otherwise you will get an "undefined is not a function"
    }
  ]);

  // will output:
  // 1
  // 2
})(window);