source: node_modules/es-toolkit/dist/function/rest.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: 442 bytes
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5function rest(func, startIndex = func.length - 1) {
6 return function (...args) {
7 const rest = args.slice(startIndex);
8 const params = args.slice(0, startIndex);
9 while (params.length < startIndex) {
10 params.push(undefined);
11 }
12 return func.apply(this, [...params, rest]);
13 };
14}
15
16exports.rest = rest;
Note: See TracBrowser for help on using the repository browser.