diff options
author | Valerio Virgillito | 2012-04-18 13:48:51 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-04-18 13:48:51 -0700 |
commit | 2e04af953463643791f6362bd8ef4c6ba190abfa (patch) | |
tree | d07aaf646091ddf9dad5b030a7905055fd323490 /node_modules/montage/core/promise-queue.js | |
parent | 616a8532099fec2a15855eac97cd85cb60c4451c (diff) | |
download | ninja-2e04af953463643791f6362bd8ef4c6ba190abfa.tar.gz |
Squashed commit of the following:
commit 2054551bfb01a0f4ca2e138b9d724835462d45cd
Merge: 765c2da 616a853
Author: Valerio Virgillito <valerio@motorola.com>
Date: Wed Apr 18 13:48:21 2012 -0700
Merge branch 'refs/heads/master' into integration
commit 765c2da8e1aa03550caf42b2bd5f367555ad2843
Author: Valerio Virgillito <valerio@motorola.com>
Date: Tue Apr 17 15:29:41 2012 -0700
updating the picasa carousel
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
commit 9484f1c82b81e27edf2dc0a1bcc1fa3b12077406
Merge: d27f2df cacb4a2
Author: Valerio Virgillito <valerio@motorola.com>
Date: Tue Apr 17 15:03:50 2012 -0700
Merge branch 'refs/heads/master' into integration
commit d27f2df4d846064444263d7832d213535962abe7
Author: Valerio Virgillito <valerio@motorola.com>
Date: Wed Apr 11 10:39:36 2012 -0700
integrating new picasa carousel component
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
commit 6f98384c9ecbc8abe55ccfe1fc25a0c7ce22c493
Author: Valerio Virgillito <valerio@motorola.com>
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 <valerio@motorola.com>
commit 1e83e26652266136802bc7af930379c1ecd631a6
Author: Valerio Virgillito <valerio@motorola.com>
Date: Mon Apr 9 22:10:45 2012 -0700
integrating montage v0.8 into ninja.
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage/core/promise-queue.js')
-rw-r--r-- | node_modules/montage/core/promise-queue.js | 65 |
1 files changed, 65 insertions, 0 deletions
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 @@ | |||
1 | |||
2 | var Montage = require("./core").Montage; | ||
3 | var Promise = require("./promise").Promise; | ||
4 | |||
5 | exports.PromiseQueue = Montage.create(Montage, { | ||
6 | init: { | ||
7 | value: function () { | ||
8 | this._ends = Promise.defer(); | ||
9 | this._closed = Promise.defer(); | ||
10 | this.closed = this._closed.promise; | ||
11 | return this; | ||
12 | } | ||
13 | }, | ||
14 | put: { | ||
15 | value: function (value) { | ||
16 | var next = Promise.defer(); | ||
17 | this._ends.resolve({ | ||
18 | head: value, | ||
19 | tail: next.promise | ||
20 | }); | ||
21 | this._ends.resolve = function (resolution) { | ||
22 | next.resolve(resolution); | ||
23 | }; | ||
24 | } | ||
25 | }, | ||
26 | get: { | ||
27 | value: function () { | ||
28 | var ends = this._ends; | ||
29 | var result = ends.promise.get("head"); | ||
30 | this._ends = { | ||
31 | resolve: function (resolution) { | ||
32 | ends.resolve(resolution); | ||
33 | }, | ||
34 | promise: ends.promise.get("tail") | ||
35 | }; | ||
36 | return result.fail(function (reason, error, rejection) { | ||
37 | this._closed.resolve(); | ||
38 | return rejection; | ||
39 | }); | ||
40 | } | ||
41 | }, | ||
42 | close: { | ||
43 | value: function (reason, error, rejection) { | ||
44 | var end = { | ||
45 | head: rejections || Promise.reject(reason, error) | ||
46 | }; | ||
47 | end.tail = end; | ||
48 | this._ends.resolve(end); | ||
49 | return this._closed.promise; | ||
50 | } | ||
51 | }, | ||
52 | forEach: { | ||
53 | value: function (put, thisp) { | ||
54 | var queue = this; | ||
55 | function loop() { | ||
56 | return queue.get().then(function (value) { | ||
57 | put.call(thisp, value); | ||
58 | }) | ||
59 | .then(loop); | ||
60 | } | ||
61 | return loop(); | ||
62 | } | ||
63 | } | ||
64 | }); | ||
65 | |||