This repository has been archived on 2026-03-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
StasisWarden-Legacy/node_modules/es-toolkit/dist/compat/function/rearg.mjs
T

15 lines
441 B
JavaScript

import { flatten } from '../array/flatten.mjs';
function rearg(func, ...indices) {
const flattenIndices = flatten(indices);
return function (...args) {
const reorderedArgs = flattenIndices.map(i => args[i]).slice(0, args.length);
for (let i = reorderedArgs.length; i < args.length; i++) {
reorderedArgs.push(args[i]);
}
return func.apply(this, reorderedArgs);
};
}
export { rearg };