File "apply.ts"
Full path: /home/fsibplc/public_html/sommilito-bank2/splide-4.1.3/src/js/utils/function/apply/apply.ts
File
size: 812 B (812 B bytes)
MIME-type: text/x-java
Charset: utf-8
Download Open Edit Advanced Editor Back
import { AnyFunction, ShiftN } from '../../../types';
import { slice } from '../../arrayLike';
/**
* Create a function where provided arguments are bound.
* `this` parameter will be always null.
*
* @param func - A function.
* @param args - Arguments to bind to the function.
*
* @return A function where arguments are bound.
*/
export function apply<F extends AnyFunction, A extends any[] = any[]>(
func: F,
...args: A
): ( ...args: ShiftN<Parameters<F>, A["length"]> ) => ReturnType<F>;
/**
* Create a function where provided arguments are bound.
* `this` parameter will be always null.
*
* @param func - A function.
*/
export function apply( func: AnyFunction ): any {
// eslint-disable-next-line prefer-rest-params, prefer-spread
return func.bind( null, ...slice( arguments, 1 ) );
}