UNPKG

@bemedev/core

Version:

The core library of @bemedev

38 lines (35 loc) 1.16 kB
import { _unknown } from '../../globals/utils/_unknown.js'; import { castFn } from '../../globals/utils/castFn.js'; import { expandFn } from '../../globals/utils/expandFn.js'; import { identity } from '../../globals/utils/identity.js'; const castings = castFn()({ is: expandFn((value) => { return typeof value === 'function'; }, { strict: (fn) => { return (value) => typeof value === 'function' && fn(value); }, }), forceCast: (value) => { return _unknown(value); }, dynamic: (..._) => identity, checker: castFn()({ /** * Very low * Checks if value is a function with one argument * @param value value to check * @returns true if value is a function with one argument */ is: (value) => { return (typeof value === 'function' && value.length === 1 && !/^\s*class\s+/.test(value.toString())); }, byType: expandFn((checker) => checker, { forceCast: (value) => _unknown(value), }), }), }); export { castings }; //# sourceMappingURL=castings.js.map