Sha256: fe4f9a6fd833631e7398c65e54067d166b752d5cbb2ca46dc1aa4394ea53a99b
Contents?: true
Size: 941 Bytes
Versions: 199
Compression:
Stored size: 941 Bytes
Contents
var Q = require("./q"); module.exports = Queue; function Queue() { var ends = Q.defer(); var closed = Q.defer(); return { put: function (value) { var next = Q.defer(); ends.resolve({ head: value, tail: next.promise }); ends.resolve = next.resolve; }, get: function () { var result = ends.promise.get("head"); ends.promise = ends.promise.get("tail"); return result.fail(function (error) { closed.resolve(error); throw error; }); }, closed: closed.promise, close: function (error) { error = error || new Error("Can't get value from closed queue"); var end = {head: Q.reject(error)}; end.tail = end; ends.resolve(end); return closed.promise; } }; }
Version data entries
199 entries across 122 versions & 19 rubygems