From 2e04af953463643791f6362bd8ef4c6ba190abfa Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 18 Apr 2012 13:48:51 -0700 Subject: Squashed commit of the following: commit 2054551bfb01a0f4ca2e138b9d724835462d45cd Merge: 765c2da 616a853 Author: Valerio Virgillito Date: Wed Apr 18 13:48:21 2012 -0700 Merge branch 'refs/heads/master' into integration commit 765c2da8e1aa03550caf42b2bd5f367555ad2843 Author: Valerio Virgillito Date: Tue Apr 17 15:29:41 2012 -0700 updating the picasa carousel Signed-off-by: Valerio Virgillito commit 9484f1c82b81e27edf2dc0a1bcc1fa3b12077406 Merge: d27f2df cacb4a2 Author: Valerio Virgillito Date: Tue Apr 17 15:03:50 2012 -0700 Merge branch 'refs/heads/master' into integration commit d27f2df4d846064444263d7832d213535962abe7 Author: Valerio Virgillito Date: Wed Apr 11 10:39:36 2012 -0700 integrating new picasa carousel component Signed-off-by: Valerio Virgillito commit 6f98384c9ecbc8abe55ccfe1fc25a0c7ce22c493 Author: Valerio Virgillito Date: Tue Apr 10 14:33:00 2012 -0700 fixed the text area case issue Text area was renamed from TextArea to Textarea Signed-off-by: Valerio Virgillito commit 1e83e26652266136802bc7af930379c1ecd631a6 Author: Valerio Virgillito Date: Mon Apr 9 22:10:45 2012 -0700 integrating montage v0.8 into ninja. Signed-off-by: Valerio Virgillito Signed-off-by: Valerio Virgillito --- node_modules/montage/core/promise-queue.js | 65 ++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 node_modules/montage/core/promise-queue.js (limited to 'node_modules/montage/core/promise-queue.js') diff --git a/node_modules/montage/core/promise-queue.js b/node_modules/montage/core/promise-queue.js new file mode 100644 index 00000000..11eeb788 --- /dev/null +++ b/node_modules/montage/core/promise-queue.js @@ -0,0 +1,65 @@ + +var Montage = require("./core").Montage; +var Promise = require("./promise").Promise; + +exports.PromiseQueue = Montage.create(Montage, { + init: { + value: function () { + this._ends = Promise.defer(); + this._closed = Promise.defer(); + this.closed = this._closed.promise; + return this; + } + }, + put: { + value: function (value) { + var next = Promise.defer(); + this._ends.resolve({ + head: value, + tail: next.promise + }); + this._ends.resolve = function (resolution) { + next.resolve(resolution); + }; + } + }, + get: { + value: function () { + var ends = this._ends; + var result = ends.promise.get("head"); + this._ends = { + resolve: function (resolution) { + ends.resolve(resolution); + }, + promise: ends.promise.get("tail") + }; + return result.fail(function (reason, error, rejection) { + this._closed.resolve(); + return rejection; + }); + } + }, + close: { + value: function (reason, error, rejection) { + var end = { + head: rejections || Promise.reject(reason, error) + }; + end.tail = end; + this._ends.resolve(end); + return this._closed.promise; + } + }, + forEach: { + value: function (put, thisp) { + var queue = this; + function loop() { + return queue.get().then(function (value) { + put.call(thisp, value); + }) + .then(loop); + } + return loop(); + } + } +}); + -- cgit v1.2.3