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

Version Path
trusty-festivity-extension-2.5.11 node_modules/bower/node_modules/p-throttler/node_modules/q/queue.js
trusty-festivity-extension-2.5.11 node_modules/bower/node_modules/q/queue.js
trusty-festivity-extension-2.5.10 node_modules/bower/node_modules/q/queue.js
trusty-festivity-extension-2.5.10 node_modules/bower/node_modules/p-throttler/node_modules/q/queue.js
trusty-festivity-extension-2.5.9 node_modules/bower/node_modules/p-throttler/node_modules/q/queue.js
trusty-festivity-extension-2.5.9 node_modules/bower/node_modules/q/queue.js
trusty-festivity-extension-2.5.8 node_modules/bower/node_modules/p-throttler/node_modules/q/queue.js
trusty-festivity-extension-2.5.8 node_modules/bower/node_modules/q/queue.js
trusty-festivity-extension-2.5.7 node_modules/bower/node_modules/p-throttler/node_modules/q/queue.js
trusty-festivity-extension-2.5.7 node_modules/bower/node_modules/q/queue.js
trusty-festivity-extension-2.5.6 node_modules/bower/node_modules/p-throttler/node_modules/q/queue.js
trusty-festivity-extension-2.5.6 node_modules/bower/node_modules/q/queue.js
xcodebuild-helper-1.2.3 externals/ios-sim-master/node_modules/q/queue.js
trusty-festivity-extension-2.5.5 node_modules/bower/node_modules/p-throttler/node_modules/q/queue.js
trusty-festivity-extension-2.5.5 node_modules/bower/node_modules/q/queue.js
trusty-festivity-extension-2.5.4 node_modules/bower/node_modules/q/queue.js
trusty-festivity-extension-2.5.4 node_modules/bower/node_modules/p-throttler/node_modules/q/queue.js
trusty-festivity-extension-2.5.3 node_modules/bower/node_modules/q/queue.js
trusty-festivity-extension-2.5.3 node_modules/bower/node_modules/p-throttler/node_modules/q/queue.js
trusty-festivity-extension-2.5.2 node_modules/bower/node_modules/p-throttler/node_modules/q/queue.js