MCPcopy Create free account
hub / github.com/RadLikeWhoa/Countable / validateArguments

Function validateArguments

Countable.js:92–101  ·  view source on GitHub ↗

* `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)

Source from the content-addressed store, hash-verified

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

Callers 1

Countable.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…