updeep-remeda/esm/wrap.js
2023-01-03 13:51:35 -05:00

13 lines
362 B
JavaScript

import freeze from "./freeze.js";
const wrap = (fn) => (...args) => {
const diff = fn.length - args.length;
if (diff === 0) {
return freeze(fn(...args));
}
if (diff === 1) {
return (data) => freeze(fn(data, ...args));
}
throw new Error("Wrong number of arguments");
};
export default wrap;
//# sourceMappingURL=wrap.js.map