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
optimacms-0.1.61 spec/dummy/node_modules/q/queue.js
disco_app-0.18.0 test/dummy/node_modules/q/queue.js
disco_app-0.18.2 test/dummy/node_modules/q/queue.js
disco_app-0.16.1 test/dummy/node_modules/q/queue.js
disco_app-0.15.2 test/dummy/node_modules/q/queue.js
disco_app-0.18.4 test/dummy/node_modules/q/queue.js
disco_app-0.18.1 test/dummy/node_modules/q/queue.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/q/queue.js
disco_app-0.14.0 test/dummy/node_modules/q/queue.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/q/queue.js
tang-0.2.1 spec/tang_app/node_modules/q/queue.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/q/queue.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/q/queue.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/q/queue.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/q/queue.js
tang-0.2.0 spec/tang_app/node_modules/q/queue.js
tang-0.1.0 spec/tang_app/node_modules/q/queue.js
tang-0.0.9 spec/tang_app/node_modules/q/queue.js
enju_library-0.3.8 spec/dummy/node_modules/q/queue.js
ilog-0.4.1 node_modules/q/queue.js