is-named-callback.js 394 B

1234567891011121314
  1. 'use strict'
  2. let callbacks = ['done', 'cb', 'callback', 'next']
  3. module.exports = function isNamedCallback(potentialCallbackName, exceptions) {
  4. for (let i = 0; i < exceptions.length; i++) {
  5. callbacks = callbacks.filter((item) => {
  6. return item !== exceptions[i]
  7. })
  8. }
  9. return callbacks.some((trueCallbackName) => {
  10. return potentialCallbackName === trueCallbackName
  11. })
  12. }