* `validateArguments` validates the arguments given to each function call. * Errors are logged to the console as warnings, but Countable fails * silently. * * @private * * @param {Nodes|String} targets A (collection of) element(s) or a single *
(targets, callback)
| 90 | */ |
| 91 | |
| 92 | function validateArguments (targets, callback) { |
| 93 | const nodes = Object.prototype.toString.call(targets) |
| 94 | const targetsValid = typeof targets === 'string' || ((nodes === '[object NodeList]' || nodes === '[object HTMLCollection]') || targets.nodeType === 1) |
| 95 | const callbackValid = typeof callback === 'function' |
| 96 | |
| 97 | if (!targetsValid) console.error('Countable: Not a valid target') |
| 98 | if (!callbackValid) console.error('Countable: Not a valid callback function') |
| 99 | |
| 100 | return targetsValid && callbackValid |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * `count` trims an element's value, optionally strips HTML tags and counts |
no outgoing calls
no test coverage detected
searching dependent graphs…