Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: chrome/test/data/third_party/spaceport/js/util/quickPromise.js

Issue 10154006: Add test data for spaceport benchmark. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698