Sha256: 11da610579c2289aa0b5e59fd772ac8b30d24d748a0092a20753db6d703bb9e0

Contents?: true

Size: 1.39 KB

Versions: 47

Compression:

Stored size: 1.39 KB

Contents

"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;
};

Version data entries

47 entries across 43 versions & 15 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/bluebird/js/release/catch_filter.js
disco_app-0.18.0 test/dummy/node_modules/bluebird/js/release/catch_filter.js
disco_app-0.18.2 test/dummy/node_modules/bluebird/js/release/catch_filter.js
disco_app-0.16.1 test/dummy/node_modules/bluebird/js/release/catch_filter.js
disco_app-0.15.2 test/dummy/node_modules/bluebird/js/release/catch_filter.js
disco_app-0.18.4 test/dummy/node_modules/bluebird/js/release/catch_filter.js
disco_app-0.18.1 test/dummy/node_modules/bluebird/js/release/catch_filter.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/bluebird/js/release/catch_filter.js
disco_app-0.14.0 test/dummy/node_modules/bluebird/js/release/catch_filter.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/bluebird/js/release/catch_filter.js
tang-0.2.1 spec/tang_app/node_modules/bluebird/js/release/catch_filter.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/bluebird/js/release/catch_filter.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/bluebird/js/release/catch_filter.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/bluebird/js/release/catch_filter.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/bluebird/js/release/catch_filter.js
tang-0.2.0 spec/tang_app/node_modules/bluebird/js/release/catch_filter.js
tang-0.1.0 spec/tang_app/node_modules/bluebird/js/release/catch_filter.js
tang-0.0.9 spec/tang_app/node_modules/bluebird/js/release/catch_filter.js
enju_library-0.3.8 spec/dummy/node_modules/bluebird/js/release/catch_filter.js
ilog-0.4.1 node_modules/consolidate/node_modules/bluebird/js/release/catch_filter.js