summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/bluebird/js/release/catch_filter.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/bluebird/js/release/catch_filter.js')
-rw-r--r--deps/npm/node_modules/bluebird/js/release/catch_filter.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/deps/npm/node_modules/bluebird/js/release/catch_filter.js b/deps/npm/node_modules/bluebird/js/release/catch_filter.js
new file mode 100644
index 0000000000..0f24ce23ec
--- /dev/null
+++ b/deps/npm/node_modules/bluebird/js/release/catch_filter.js
@@ -0,0 +1,42 @@
+"use strict";
+module.exports = function(NEXT_FILTER) {
+var util = require("./util");
+var getKeys = require("./es5").keys;
+var tryCatch = util.tryCatch;
+var errorObj = util.errorObj;
+
+function catchFilter(instances, cb, promise) {
+ return function(e) {
+ var boundTo = promise._boundValue();
+ predicateLoop: for (var i = 0; i < instances.length; ++i) {
+ var item = instances[i];
+
+ if (item === Error ||
+ (item != null && item.prototype instanceof Error)) {
+ if (e instanceof item) {
+ return tryCatch(cb).call(boundTo, e);
+ }
+ } else if (typeof item === "function") {
+ var matchesPredicate = tryCatch(item).call(boundTo, e);
+ if (matchesPredicate === errorObj) {
+ return matchesPredicate;
+ } else if (matchesPredicate) {
+ return tryCatch(cb).call(boundTo, e);
+ }
+ } else if (util.isObject(e)) {
+ var keys = getKeys(item);
+ for (var j = 0; j < keys.length; ++j) {
+ var key = keys[j];
+ if (item[key] != e[key]) {
+ continue predicateLoop;
+ }
+ }
+ return tryCatch(cb).call(boundTo, e);
+ }
+ }
+ return NEXT_FILTER;
+ };
+}
+
+return catchFilter;
+};