MCPcopy Create free account
hub / github.com/TruthHun/BookStack / catchFilter

Function catchFilter

static/word2md/mammoth.browser.js:4548–4579  ·  view source on GitHub ↗
(instances, cb, promise)

Source from the content-addressed store, hash-verified

4546var errorObj = util.errorObj;
4547
4548function catchFilter(instances, cb, promise) {
4549 return function(e) {
4550 var boundTo = promise._boundValue();
4551 predicateLoop: for (var i = 0; i < instances.length; ++i) {
4552 var item = instances[i];
4553
4554 if (item === Error ||
4555 (item != null && item.prototype instanceof Error)) {
4556 if (e instanceof item) {
4557 return tryCatch(cb).call(boundTo, e);
4558 }
4559 } else if (typeof item === "function") {
4560 var matchesPredicate = tryCatch(item).call(boundTo, e);
4561 if (matchesPredicate === errorObj) {
4562 return matchesPredicate;
4563 } else if (matchesPredicate) {
4564 return tryCatch(cb).call(boundTo, e);
4565 }
4566 } else if (util.isObject(e)) {
4567 var keys = getKeys(item);
4568 for (var j = 0; j < keys.length; ++j) {
4569 var key = keys[j];
4570 if (item[key] != e[key]) {
4571 continue predicateLoop;
4572 }
4573 }
4574 return tryCatch(cb).call(boundTo, e);
4575 }
4576 }
4577 return NEXT_FILTER;
4578 };
4579}
4580
4581return catchFilter;
4582};

Callers 1

mammoth.browser.jsFile · 0.70

Calls 1

tryCatchFunction · 0.70

Tested by

no test coverage detected