es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
12 lines (9 loc) • 327 B
JavaScript
import { identity } from '../../function/identity.mjs';
import { isFunction } from '../../predicate/isFunction.mjs';
function wrap(value, wrapper) {
return function (...args) {
const wrapFn = isFunction(wrapper) ? wrapper : identity;
return wrapFn.apply(this, [value, ...args]);
};
}
export { wrap };