mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-28 21:24:26 +08:00
DISABLE_THIRD_PARTY_CHECK=Package needs updating with node_modules Change-Id: I889f1b86c586e37307a3e13ad762aa56d1ece150 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1946468 Commit-Queue: Paul Lewis <aerotwist@chromium.org> Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
44 lines
975 B
JavaScript
44 lines
975 B
JavaScript
/*
|
|
Copyright (c) 2012, Yahoo! Inc. All rights reserved.
|
|
Code licensed under the BSD License:
|
|
http://yuilibrary.com/license/
|
|
*/
|
|
var Stack = function() {
|
|
this.errors = [];
|
|
this.finished = 0;
|
|
this.results = [];
|
|
this.total = 0;
|
|
};
|
|
|
|
Stack.prototype = {
|
|
add: function(fn) {
|
|
var self = this,
|
|
index = self.total;
|
|
|
|
self.total += 1;
|
|
|
|
return function(err) {
|
|
if (err) { self.errors[index] = err; }
|
|
|
|
self.finished += 1;
|
|
self.results[index] = fn.apply(null, arguments);
|
|
self.test();
|
|
};
|
|
},
|
|
|
|
test: function() {
|
|
if (this.finished >= this.total && this.callback) {
|
|
this.callback.call(null, this.errors.length ? this.errors : null,
|
|
this.results, this.data);
|
|
}
|
|
},
|
|
|
|
done: function(callback, data) {
|
|
this.callback = callback;
|
|
this.data = data;
|
|
this.test();
|
|
}
|
|
};
|
|
|
|
exports.Stack = Stack;
|