Browse Source

Initial commit

master
Sven Slootweg 3 months ago
commit
3293058945
  1. 20
      index.js
  2. 8
      package.json

20
index.js

@ -0,0 +1,20 @@
"use strict";
module.exports = function createResultBuffer() {
let buffer = [];
return {
push: function (item) {
// NOTE: item should always be a Promise, either resolved or rejected! Use Promise.resolve or Promise.reject to wrap an item if necessary
// FIXME: Actually validate this
buffer.push(item);
},
maybeRead: function (readCallback) {
if (buffer.length > 0) {
return buffer.shift();
} else {
return readCallback();
}
}
};
};

8
package.json

@ -0,0 +1,8 @@
{
"name": "result-buffer",
"version": "0.1.0",
"main": "index.js",
"repository": "https://git.cryto.net/joepie91/result-buffer.git",
"author": "Sven Slootweg <admin@cryto.net>",
"license": "WTFPL OR CC0-1.0"
}
Loading…
Cancel
Save