Repository URL to install this package:
|
Version:
6.0.4 ▾
|
// @todo - from exotic?
// import tester from '../cast/toTestable'
import { Matchable } from './typings'
function tester(...args: any[]) {
throw new TypeError('need to handle circular exotic <> chain-able dependency')
}
/**
* the original simple to-test matcher for traversable,
* will be merged into, or simplified as simplified into matcher
*
* @since 2.0.0
*
* @TODO should use matcher,
* @TODO should inprove the callback data...
*
* @types matcher
*
* @param keys matchable keys
* @param vals matchable values
* @return matched or not
*
* @example
*
* anyKeyVal([], [])(0, 0)
* //=> false
*
* anyKeyVal([() => true], [])(0, 0)
* //=> true
*
*/
export default (keys: Matchable[], vals: Matchable[]) => (
prop: string | number | symbol,
val: any
): boolean => {
for (let i = 0; i < keys.length; i++) {
if (tester(keys[i], prop, val)) return true
}
for (let i = 0; i < vals.length; i++) {
if (tester(vals[i], val, prop)) return true
}
return false
}