-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #665 from bugsnag/v7-callbacks
V7: Callback refactor
- Loading branch information
Showing
31 changed files
with
321 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = (callbacks, callbackArg, callbackType, logger) => { | ||
let ignore = false | ||
const cbs = callbacks.slice(0) | ||
while (!ignore) { | ||
if (!cbs.length) break | ||
try { | ||
ignore = cbs.pop()(callbackArg) === false | ||
} catch (e) { | ||
logger.error(`Error occurred in ${callbackType} callback, continuing anyway…`) | ||
logger.error(e) | ||
} | ||
} | ||
return ignore | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
const { filter, isArray } = require('./es-utils') | ||
|
||
exports.intRange = (min = 1, max = Infinity) => value => | ||
typeof value === 'number' && | ||
parseInt('' + value, 10) === value && | ||
value >= min && value <= max | ||
|
||
exports.stringWithLength = value => typeof value === 'string' && !!value.length | ||
|
||
exports.listOfFunctions = value => typeof value === 'function' || (isArray(value) && filter(value, f => typeof f === 'function').length === value.length) |
Oops, something went wrong.