Constnium/node_modules/eslint-plugin-promise/rules/lib/is-named-callback.js
2022-06-23 02:27:43 +02:00

14 lines
394 B
JavaScript

'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((item) => {
return item !== exceptions[i]
})
}
return callbacks.some((trueCallbackName) => {
return potentialCallbackName === trueCallbackName
})
}