repo.or.cz
/
chromium-blink-merge.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
Disable view source for Developer Tools.
[chromium-blink-merge.git]
/
chrome
/
test
/
data
/
third_party
/
spaceport
/
js
/
util
/
quickPromise.js
blob
0872247dba183e6fab6e00e1bb746994e1466e24
1
define([ 'util/ensureCallback' ], function (ensureCallback) {
2
function quickPromise() {
3
var thens = [ ];
4
var resolved = false;
5
6
function resolve() {
7
if (resolved) {
8
throw new Error("Already resolved");
9
}
10
resolved = true;
11
12
while (thens.length) {
13
var fn = thens.pop();
14
fn();
15
}
16
}
17
18
function then(fn) {
19
fn = ensureCallback(fn);
20
if (resolved) {
21
fn();
22
} else {
23
thens.push(fn);
24
}
25
}
26
27
return {
28
resolve: resolve,
29
then: then
30
};
31
}
32
33
return quickPromise;
34
});