is-named-callback.js 404 Bytes
Newer Older
YazhouChen's avatar
YazhouChen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
'use strict'

let callbacks = ['done', 'cb', 'callback', 'next']

module.exports = function isNamedCallback(potentialCallbackName, exceptions) {
  for (let i = 0; i < exceptions.length; i++) {
    callbacks = callbacks.filter(function(item) {
      return item !== exceptions[i]
    })
  }
  return callbacks.some(function(trueCallbackName) {
    return potentialCallbackName === trueCallbackName
  })
}