Files
Schnappix/node_modules/@egjs/hammerjs/src/utils/bool-or-fn.js
T

16 lines
445 B
JavaScript

import { TYPE_FUNCTION } from './utils-consts';
/**
* @private
* let a boolean value also be a function that must return a boolean
* this first item in args will be used as the context
* @param {Boolean|Function} val
* @param {Array} [args]
* @returns {Boolean}
*/
export default function boolOrFn(val, args) {
if (typeof val === TYPE_FUNCTION) {
return val.apply(args ? args[0] || undefined : undefined, args);
}
return val;
}