source: node_modules/es-toolkit/dist/compat/function/rearg.js

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 543 bytes
RevLine 
[a762898]1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const flatten = require('../array/flatten.js');
6
7function rearg(func, ...indices) {
8 const flattenIndices = flatten.flatten(indices);
9 return function (...args) {
10 const reorderedArgs = flattenIndices.map(i => args[i]).slice(0, args.length);
11 for (let i = reorderedArgs.length; i < args.length; i++) {
12 reorderedArgs.push(args[i]);
13 }
14 return func.apply(this, reorderedArgs);
15 };
16}
17
18exports.rearg = rearg;
Note: See TracBrowser for help on using the repository browser.