@bemedev/core
Version:
The core library of @bemedev
40 lines (36 loc) • 1.4 kB
JavaScript
;
var globals_utils__unknown = require('../../globals/utils/_unknown.cjs');
var globals_utils_castFn = require('../../globals/utils/castFn.cjs');
var globals_utils_expandFn = require('../../globals/utils/expandFn.cjs');
var globals_utils_identity = require('../../globals/utils/identity.cjs');
const castings = globals_utils_castFn.castFn()({
is: globals_utils_expandFn.expandFn((value) => {
return typeof value === 'function';
}, {
strict: (fn) => {
return (value) => typeof value === 'function' && fn(value);
},
}),
forceCast: (value) => {
return globals_utils__unknown._unknown(value);
},
dynamic: (..._) => globals_utils_identity.identity,
checker: globals_utils_castFn.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: globals_utils_expandFn.expandFn((checker) => checker, {
forceCast: (value) => globals_utils__unknown._unknown(value),
}),
}),
});
exports.castings = castings;
//# sourceMappingURL=castings.cjs.map