import * as t from './src/types' /** * @description * Add a cap on the number of arguments passable to `fn`. Any arguments beyond * `limit` will not be passed, which is useful for creating functions * compatible with currying or as callbacks / parameters to higher order * functions. * * @parameters * | name | type | description | * | :--: | :--: | ----------- | * | fn | `Function` | Function whose arguments to limit | * | limit | `Number` | The number of arguments to allow (default = 1) | * * @returns `Function` – new function accepting only `limit` arguments * * @example * const log = cap(console.log, 2) * * log(1, 2, 3) * // -> [ 1, 2 ] * * ;['1', '2.2', '2.54'].map(parseInt) * // -> [ 1, NaN, NaN ] * * const toInt = cap(parseInt) * ;['1', '2.2', '2.54'].map(toInt) * // -> [ 1, 2, 2 ] * * @since v1.0.0 * @tag functions */ interface Cap { > (fn: F): (arg: T1) => ReturnType (fn: F, limit: 0): () => ReturnType > (fn: F, limit: 1): (arg: T1) => ReturnType , T2 = t.ParamType> (fn: F, limit: 2): (...args: [T1, T2]) => ReturnType , T2 = t.ParamType, T3 = t.ParamType> (fn: F, limit: 3): (...args: [T1, T2, T3]) => ReturnType , T2 = t.ParamType, T3 = t.ParamType, T4 = t.ParamType> (fn: F, limit: 4): (...args: [T1, T2, T3, T4]) => ReturnType , T2 = t.ParamType, T3 = t.ParamType, T4 = t.ParamType, T5 = t.ParamType> (fn: F, limit: 5): (...args: [T1, T2, T3, T4, T5]) => ReturnType , T2 = t.ParamType, T3 = t.ParamType, T4 = t.ParamType, T5 = t.ParamType, T6 = t.ParamType> (fn: F, limit: 6): (...args: [T1, T2, T3, T4, T5, T6]) => ReturnType } declare const cap: Cap export = cap