| [a762898] | 1 | /**
|
|---|
| 2 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 3 | *
|
|---|
| 4 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 5 | *
|
|---|
| 6 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 7 | *
|
|---|
| 8 | * @template T1 The type of the first argument.
|
|---|
| 9 | * @template R The return type of the function.
|
|---|
| 10 | * @param {function(arg1: T1): R} func The function to partially apply.
|
|---|
| 11 | * @param {T1} arg1 The first argument to apply.
|
|---|
| 12 | * @returns {function(): R} A new function that takes no arguments and returns the result of the original function.
|
|---|
| 13 | *
|
|---|
| 14 | * @example
|
|---|
| 15 | * const addOne = (x: number) => x + 1;
|
|---|
| 16 | * const addOneToFive = partial(addOne, 5);
|
|---|
| 17 | * console.log(addOneToFive()); // => 6
|
|---|
| 18 | */
|
|---|
| 19 | declare function partial<T1, R>(func: (arg1: T1) => R, arg1: T1): () => R;
|
|---|
| 20 | /**
|
|---|
| 21 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 22 | *
|
|---|
| 23 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 24 | *
|
|---|
| 25 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 26 | *
|
|---|
| 27 | * @template T1 The type of the first argument.
|
|---|
| 28 | * @template T2 The type of the second argument.
|
|---|
| 29 | * @template R The return type of the function.
|
|---|
| 30 | * @param {function(arg1: T1, arg2: T2): R} func The function to partially apply.
|
|---|
| 31 | * @param {T1} arg1 The first argument to apply.
|
|---|
| 32 | * @returns {function(arg2: T2): R} A new function that takes the second argument and returns the result of the original function.
|
|---|
| 33 | *
|
|---|
| 34 | * @example
|
|---|
| 35 | * const multiply = (x: number, y: number) => x * y;
|
|---|
| 36 | * const double = partial(multiply, 2);
|
|---|
| 37 | * console.log(double(5)); // => 10
|
|---|
| 38 | */
|
|---|
| 39 | declare function partial<T1, T2, R>(func: (arg1: T1, arg2: T2) => R, arg1: T1): (arg2: T2) => R;
|
|---|
| 40 | /**
|
|---|
| 41 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 42 | *
|
|---|
| 43 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 44 | *
|
|---|
| 45 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 46 | *
|
|---|
| 47 | * @template T1 The type of the first argument.
|
|---|
| 48 | * @template T2 The type of the second argument.
|
|---|
| 49 | * @template R The return type of the function.
|
|---|
| 50 | * @param {function(arg1: T1, arg2: T2): R} func The function to partially apply.
|
|---|
| 51 | * @param {Placeholder} placeholder The placeholder for the first argument.
|
|---|
| 52 | * @param {T2} arg2 The second argument to apply.
|
|---|
| 53 | * @returns {function(arg1: T1): R} A new function that takes the first argument and returns the result of the original function.
|
|---|
| 54 | *
|
|---|
| 55 | * @example
|
|---|
| 56 | * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`;
|
|---|
| 57 | * const greetWithHello = partial(greet, partial.placeholder, 'John');
|
|---|
| 58 | * console.log(greetWithHello('Hello')); // => 'Hello, John!'
|
|---|
| 59 | */
|
|---|
| 60 | declare function partial<T1, T2, R>(func: (arg1: T1, arg2: T2) => R, placeholder: Placeholder, arg2: T2): (arg1: T1) => R;
|
|---|
| 61 | /**
|
|---|
| 62 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 63 | *
|
|---|
| 64 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 65 | *
|
|---|
| 66 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 67 | *
|
|---|
| 68 | * @template T1 The type of the first argument.
|
|---|
| 69 | * @template T2 The type of the second argument.
|
|---|
| 70 | * @template T3 The type of the third argument.
|
|---|
| 71 | * @template R The return type of the function.
|
|---|
| 72 | * @param {function(arg1: T1, arg2: T2, arg3: T3): R} func The function to partially apply.
|
|---|
| 73 | * @param {T1} arg1 The first argument to apply.
|
|---|
| 74 | * @returns {function(arg2: T2, arg3: T3): R} A new function that takes the second and third arguments and returns the result of the original function.
|
|---|
| 75 | *
|
|---|
| 76 | * @example
|
|---|
| 77 | * const sumThree = (a: number, b: number, c: number) => a + b + c;
|
|---|
| 78 | * const addFive = partial(sumThree, 5);
|
|---|
| 79 | * console.log(addFive(3, 2)); // => 10
|
|---|
| 80 | */
|
|---|
| 81 | declare function partial<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1): (arg2: T2, arg3: T3) => R;
|
|---|
| 82 | /**
|
|---|
| 83 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 84 | *
|
|---|
| 85 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 86 | *
|
|---|
| 87 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 88 | *
|
|---|
| 89 | * @template T1 The type of the first argument.
|
|---|
| 90 | * @template T2 The type of the second argument.
|
|---|
| 91 | * @template T3 The type of the third argument.
|
|---|
| 92 | * @template R The return type of the function.
|
|---|
| 93 | * @param {function(arg1: T1, arg2: T2, arg3: T3): R} func The function to partially apply.
|
|---|
| 94 | * @param {Placeholder} arg1 The placeholder for the first argument.
|
|---|
| 95 | * @param {T2} arg2 The second argument to apply.
|
|---|
| 96 | * @returns {function(arg1: T1, arg3: T3): R} A new function that takes the first and third arguments and returns the result of the original function.
|
|---|
| 97 | *
|
|---|
| 98 | * @example
|
|---|
| 99 | * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`;
|
|---|
| 100 | * const greetWithPlaceholder = partial(greet, partial.placeholder, 'John');
|
|---|
| 101 | * console.log(greetWithPlaceholder('Hello')); // => 'Hello, John!'
|
|---|
| 102 | */
|
|---|
| 103 | declare function partial<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: Placeholder, arg2: T2): (arg1: T1, arg3: T3) => R;
|
|---|
| 104 | /**
|
|---|
| 105 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 106 | *
|
|---|
| 107 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 108 | *
|
|---|
| 109 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 110 | *
|
|---|
| 111 | * @template T1 The type of the first argument.
|
|---|
| 112 | * @template T2 The type of the second argument.
|
|---|
| 113 | * @template T3 The type of the third argument.
|
|---|
| 114 | * @template R The return type of the function.
|
|---|
| 115 | * @param {function(arg1: T1, arg2: T2, arg3: T3): R} func The function to partially apply.
|
|---|
| 116 | * @param {Placeholder} arg1 The placeholder for the first argument.
|
|---|
| 117 | * @param {Placeholder} arg2 The placeholder for the second argument.
|
|---|
| 118 | * @param {T3} arg3 The third argument to apply.
|
|---|
| 119 | * @returns {function(arg1: T1, arg2: T2): R} A new function that takes the first and second arguments and returns the result of the original function.
|
|---|
| 120 | *
|
|---|
| 121 | * @example
|
|---|
| 122 | * const multiply = (x: number, y: number, z: number) => x * y * z;
|
|---|
| 123 | * const multiplyWithPlaceholders = partial(multiply, partial.placeholder, partial.placeholder, 2);
|
|---|
| 124 | * console.log(multiplyWithPlaceholders(3, 4)); // => 24
|
|---|
| 125 | */
|
|---|
| 126 | declare function partial<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: Placeholder, arg2: Placeholder, arg3: T3): (arg1: T1, arg2: T2) => R;
|
|---|
| 127 | /**
|
|---|
| 128 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 129 | *
|
|---|
| 130 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 131 | *
|
|---|
| 132 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 133 | *
|
|---|
| 134 | * @template T1 The type of the first argument.
|
|---|
| 135 | * @template T2 The type of the second argument.
|
|---|
| 136 | * @template T3 The type of the third argument.
|
|---|
| 137 | * @template R The return type of the function.
|
|---|
| 138 | * @param {function(arg1: T1, arg2: T2, arg3: T3): R} func The function to partially apply.
|
|---|
| 139 | * @param {T1} arg1 The first argument to apply.
|
|---|
| 140 | * @param {Placeholder} arg2 The placeholder for the second argument.
|
|---|
| 141 | * @param {T3} arg3 The third argument to apply.
|
|---|
| 142 | * @returns {function(arg2: T2): R} A new function that takes the second argument and returns the result of the original function.
|
|---|
| 143 | *
|
|---|
| 144 | * @example
|
|---|
| 145 | * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`;
|
|---|
| 146 | * const greetWithPlaceholder = partial(greet, 'Hello', partial.placeholder);
|
|---|
| 147 | * console.log(greetWithPlaceholder('John')); // => 'Hello, John!'
|
|---|
| 148 | */
|
|---|
| 149 | declare function partial<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, arg1: T1, arg2: Placeholder, arg3: T3): (arg2: T2) => R;
|
|---|
| 150 | /**
|
|---|
| 151 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 152 | *
|
|---|
| 153 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 154 | *
|
|---|
| 155 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 156 | *
|
|---|
| 157 | * @template T1 The type of the first argument.
|
|---|
| 158 | * @template T2 The type of the second argument.
|
|---|
| 159 | * @template T3 The type of the third argument.
|
|---|
| 160 | * @template R The return type of the function.
|
|---|
| 161 | * @param {function(arg1: T1, arg2: T2, arg3: T3): R} func The function to partially apply.
|
|---|
| 162 | * @param {Placeholder} arg1 The first argument to apply.
|
|---|
| 163 | * @param {T2} arg2 The placeholder for the second argument.
|
|---|
| 164 | * @param {T3} arg3 The third argument to apply.
|
|---|
| 165 | * @returns {function(arg2: T2): R} A new function that takes the second argument and returns the result of the original function.
|
|---|
| 166 | *
|
|---|
| 167 | * @example
|
|---|
| 168 | * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`;
|
|---|
| 169 | * const greetWithPlaceholder = partial(greet, 'Hello', partial.placeholder);
|
|---|
| 170 | * console.log(greetWithPlaceholder('John')); // => 'Hello, John!'
|
|---|
| 171 | */
|
|---|
| 172 | declare function partial<T1, T2, T3, R>(func: (arg1: T1, arg2: T2, arg3: T3) => R, plc1: Placeholder, arg2: T2, arg3: T3): (arg1: T1) => R;
|
|---|
| 173 | /**
|
|---|
| 174 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 175 | *
|
|---|
| 176 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 177 | *
|
|---|
| 178 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 179 | *
|
|---|
| 180 | * @template T1 The type of the first argument.
|
|---|
| 181 | * @template T2 The type of the second argument.
|
|---|
| 182 | * @template T3 The type of the third argument.
|
|---|
| 183 | * @template T4 The type of the fourth argument.
|
|---|
| 184 | * @template R The return type of the function.
|
|---|
| 185 | * @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|---|
| 186 | * @param {T1} arg1 The first argument to apply.
|
|---|
| 187 | * @returns {function(arg2: T2): R} A new function that takes the second argument and returns the result of the original function.
|
|---|
| 188 | *
|
|---|
| 189 | * @example
|
|---|
| 190 | * const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w;
|
|---|
| 191 | * const double = partial(multiply, 2);
|
|---|
| 192 | * console.log(double(5, 4, 3)); // => 120
|
|---|
| 193 | */
|
|---|
| 194 | declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1): (arg2: T2, arg3: T3, arg4: T4) => R;
|
|---|
| 195 | /**
|
|---|
| 196 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 197 | *
|
|---|
| 198 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 199 | *
|
|---|
| 200 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 201 | *
|
|---|
| 202 | * @template T1 The type of the first argument.
|
|---|
| 203 | * @template T2 The type of the second argument.
|
|---|
| 204 | * @template T3 The type of the third argument.
|
|---|
| 205 | * @template T4 The type of the fourth argument.
|
|---|
| 206 | * @template R The return type of the function.
|
|---|
| 207 | * @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|---|
| 208 | * @param {Placeholder} arg1 The placeholder for the first argument.
|
|---|
| 209 | * @param {Placeholder} arg2 The placeholder for the second argument.
|
|---|
| 210 | * @param {T3} arg3 The third argument to apply.
|
|---|
| 211 | * @param {T4} arg4 The fourth argument to apply.
|
|---|
| 212 | * @returns {function(arg1: T1, arg2: T2): R} A new function that takes the first and second arguments and returns the result of the original function.
|
|---|
| 213 | *
|
|---|
| 214 | * @example
|
|---|
| 215 | * const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w;
|
|---|
| 216 | * const multiplyWithPlaceholders = partial(multiply, partial.placeholder, partial.placeholder, 2, 3);
|
|---|
| 217 | * console.log(multiplyWithPlaceholders(4, 5)); // => 120
|
|---|
| 218 | */
|
|---|
| 219 | declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: Placeholder, arg3: T3, arg4: T4): (arg1: T1, arg2: T2) => R;
|
|---|
| 220 | /**
|
|---|
| 221 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 222 | *
|
|---|
| 223 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 224 | *
|
|---|
| 225 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 226 | *
|
|---|
| 227 | * @template T1 The type of the first argument.
|
|---|
| 228 | * @template T2 The type of the second argument.
|
|---|
| 229 | * @template T3 The type of the third argument.
|
|---|
| 230 | * @template T4 The type of the fourth argument.
|
|---|
| 231 | * @template R The return type of the function.
|
|---|
| 232 | * @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|---|
| 233 | * @param {T1} arg1 The first argument to apply.
|
|---|
| 234 | * @param {T2} arg2 The second argument to apply.
|
|---|
| 235 | * @returns {function(arg3: T3, arg4: T4): R} A new function that takes the third and fourth arguments and returns the result of the original function.
|
|---|
| 236 | *
|
|---|
| 237 | * @example
|
|---|
| 238 | * const sumFour = (a: number, b: number, c: number, d: number) => a + b + c + d;
|
|---|
| 239 | * const addOneAndTwo = partial(sumFour, 1, 2);
|
|---|
| 240 | * console.log(addOneAndTwo(3, 4)); // => 10
|
|---|
| 241 | */
|
|---|
| 242 | declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2): (arg3: T3, arg4: T4) => R;
|
|---|
| 243 | /**
|
|---|
| 244 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 245 | *
|
|---|
| 246 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 247 | *
|
|---|
| 248 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 249 | *
|
|---|
| 250 | * @template T1 The type of the first argument.
|
|---|
| 251 | * @template T2 The type of the second argument.
|
|---|
| 252 | * @template T3 The type of the third argument.
|
|---|
| 253 | * @template T4 The type of the fourth argument.
|
|---|
| 254 | * @template R The return type of the function.
|
|---|
| 255 | * @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|---|
| 256 | * @param {T1} arg1 The first argument to apply.
|
|---|
| 257 | * @param {Placeholder} arg2 The placeholder for the second argument.
|
|---|
| 258 | * @param {T3} arg3 The third argument to apply.
|
|---|
| 259 | * @param {T4} arg4 The fourth argument to apply.
|
|---|
| 260 | * @returns {function(arg2: T2, arg4: T4): R} A new function that takes the second and fourth arguments and returns the result of the original function.
|
|---|
| 261 | *
|
|---|
| 262 | * @example
|
|---|
| 263 | * const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`;
|
|---|
| 264 | * const greetWithPlaceholder = partial(greet, 'Hello', partial.placeholder, '!');
|
|---|
| 265 | * console.log(greetWithPlaceholder('John')); // => 'Hello, John!'
|
|---|
| 266 | */
|
|---|
| 267 | declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: T3): (arg2: T2, arg4: T4) => R;
|
|---|
| 268 | /**
|
|---|
| 269 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 270 | *
|
|---|
| 271 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 272 | *
|
|---|
| 273 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 274 | *
|
|---|
| 275 | * @template T1 The type of the first argument.
|
|---|
| 276 | * @template T2 The type of the second argument.
|
|---|
| 277 | * @template T3 The type of the third argument.
|
|---|
| 278 | * @template T4 The type of the fourth argument.
|
|---|
| 279 | * @template R The return type of the function.
|
|---|
| 280 | * @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|---|
| 281 | * @param {Placeholder} arg1 The placeholder for the first argument.
|
|---|
| 282 | * @param {T2} arg2 The second argument to apply.
|
|---|
| 283 | * @param {T3} arg3 The third argument to apply.
|
|---|
| 284 | * @param {T4} arg4 The fourth argument to apply.
|
|---|
| 285 | * @returns {function(arg1: T1, arg3: T3): R} A new function that takes the first and third arguments and returns the result of the original function.
|
|---|
| 286 | *
|
|---|
| 287 | * @example
|
|---|
| 288 | * const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w;
|
|---|
| 289 | * const multiplyWithPlaceholder = partial(multiply, partial.placeholder, 2, 3);
|
|---|
| 290 | * console.log(multiplyWithPlaceholder(4)); // => 24
|
|---|
| 291 | */
|
|---|
| 292 | declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: T2, arg3: T3): (arg1: T1, arg4: T4) => R;
|
|---|
| 293 | /**
|
|---|
| 294 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 295 | *
|
|---|
| 296 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 297 | *
|
|---|
| 298 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 299 | *
|
|---|
| 300 | * @template T1 The type of the first argument.
|
|---|
| 301 | * @template T2 The type of the second argument.
|
|---|
| 302 | * @template T3 The type of the third argument.
|
|---|
| 303 | * @template T4 The type of the fourth argument.
|
|---|
| 304 | * @template R The return type of the function.
|
|---|
| 305 | * @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|---|
| 306 | * @param {Placeholder} arg1 The placeholder for the first argument.
|
|---|
| 307 | * @param {T2} arg2 The second argument to apply.
|
|---|
| 308 | * @param {Placeholder} arg3 The placeholder for the third argument.
|
|---|
| 309 | * @param {T4} arg4 The fourth argument to apply.
|
|---|
| 310 | * @returns {function(arg1: T1, arg3: T3): R} A new function that takes the first and third arguments and returns the result of the original function.
|
|---|
| 311 | */
|
|---|
| 312 | declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: T2, arg3: Placeholder, arg4: T4): (arg1: T1, arg3: T3) => R;
|
|---|
| 313 | /**
|
|---|
| 314 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 315 | *
|
|---|
| 316 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 317 | *
|
|---|
| 318 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 319 | *
|
|---|
| 320 | * @template T1 The type of the first argument.
|
|---|
| 321 | * @template T2 The type of the second argument.
|
|---|
| 322 | * @template T3 The type of the third argument.
|
|---|
| 323 | * @template T4 The type of the fourth argument.
|
|---|
| 324 | * @template R The return type of the function.
|
|---|
| 325 | * @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|---|
| 326 | * @param {Placeholder} arg1 The placeholder for the first argument.
|
|---|
| 327 | * @param {Placeholder} arg2 The placeholder for the second argument.
|
|---|
| 328 | * @param {T3} arg3 The third argument to apply.
|
|---|
| 329 | * @param {T4} arg4 The fourth argument to apply.
|
|---|
| 330 | * @returns {function(arg1: T1, arg2: T2): R} A new function that takes the first and second arguments and returns the result of the original function.
|
|---|
| 331 | *
|
|---|
| 332 | * @example
|
|---|
| 333 | * const multiply = (x: number, y: number, z: number, w: number) => x * y * z * w;
|
|---|
| 334 | * const multiplyWithPlaceholders = partial(multiply, partial.placeholder, partial.placeholder, 2, 3);
|
|---|
| 335 | * console.log(multiplyWithPlaceholders(4, 5)); // => 120
|
|---|
| 336 | */
|
|---|
| 337 | declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: Placeholder, arg3: T3, arg4: T4): (arg1: T1, arg2: T2) => R;
|
|---|
| 338 | /**
|
|---|
| 339 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 340 | *
|
|---|
| 341 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 342 | *
|
|---|
| 343 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 344 | *
|
|---|
| 345 | * @template T1 The type of the first argument.
|
|---|
| 346 | * @template T2 The type of the second argument.
|
|---|
| 347 | * @template T3 The type of the third argument.
|
|---|
| 348 | * @template T4 The type of the fourth argument.
|
|---|
| 349 | * @template R The return type of the function.
|
|---|
| 350 | * @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|---|
| 351 | * @param {T1} arg1 The first argument to apply.
|
|---|
| 352 | * @param {T2} arg2 The second argument to apply.
|
|---|
| 353 | * @param {T3} arg3 The third argument to apply.
|
|---|
| 354 | * @returns {function(arg4: T4): R} A new function that takes the fourth argument and returns the result of the original function.
|
|---|
| 355 | */
|
|---|
| 356 | declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: T3): (arg4: T4) => R;
|
|---|
| 357 | /**
|
|---|
| 358 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 359 | *
|
|---|
| 360 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 361 | *
|
|---|
| 362 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 363 | *
|
|---|
| 364 | * @template T1 The type of the first argument.
|
|---|
| 365 | * @template T2 The type of the second argument.
|
|---|
| 366 | * @template T3 The type of the third argument.
|
|---|
| 367 | * @template T4 The type of the fourth argument.
|
|---|
| 368 | * @template R The return type of the function.
|
|---|
| 369 | * @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|---|
| 370 | * @param {T1} arg1 The first argument to apply.
|
|---|
| 371 | * @param {T2} arg2 The second argument to apply.
|
|---|
| 372 | * @param {Placeholder} arg3 The placeholder for the third argument.
|
|---|
| 373 | * @param {T4} arg4 The fourth argument to apply.
|
|---|
| 374 | * @returns {function(arg3: T3): R} A new function that takes the third argument and returns the result of the original function.
|
|---|
| 375 | */
|
|---|
| 376 | declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: T2, arg3: Placeholder, arg4: T4): (arg3: T3) => R;
|
|---|
| 377 | /**
|
|---|
| 378 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 379 | *
|
|---|
| 380 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 381 | *
|
|---|
| 382 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 383 | *
|
|---|
| 384 | * @template T1 The type of the first argument.
|
|---|
| 385 | * @template T2 The type of the second argument.
|
|---|
| 386 | * @template T3 The type of the third argument.
|
|---|
| 387 | * @template T4 The type of the fourth argument.
|
|---|
| 388 | * @template R The return type of the function.
|
|---|
| 389 | * @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|---|
| 390 | * @param {T1} arg1 The first argument to apply.
|
|---|
| 391 | * @param {Placeholder} arg2 The placeholder for the second argument.
|
|---|
| 392 | * @param {T3} arg3 The third argument to apply.
|
|---|
| 393 | * @param {T4} arg4 The fourth argument to apply.
|
|---|
| 394 | * @returns {function(arg2: T2): R} A new function that takes the second argument and returns the result of the original function.
|
|---|
| 395 | */
|
|---|
| 396 | declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: T1, arg2: Placeholder, arg3: T3, arg4: T4): (arg2: T2) => R;
|
|---|
| 397 | /**
|
|---|
| 398 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 399 | *
|
|---|
| 400 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 401 | *
|
|---|
| 402 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 403 | *
|
|---|
| 404 | * @template T1 The type of the first argument.
|
|---|
| 405 | * @template T2 The type of the second argument.
|
|---|
| 406 | * @template T3 The type of the third argument.
|
|---|
| 407 | * @template T4 The type of the fourth argument.
|
|---|
| 408 | * @template R The return type of the function.
|
|---|
| 409 | * @param {function(arg1: T1, arg2: T2, arg3: T3, arg4: T4): R} func The function to partially apply.
|
|---|
| 410 | * @param {Placeholder} arg1 The placeholder for the first argument.
|
|---|
| 411 | * @param {T2} arg2 The second argument to apply.
|
|---|
| 412 | * @param {T3} arg3 The third argument to apply.
|
|---|
| 413 | * @param {T4} arg4 The fourth argument to apply.
|
|---|
| 414 | * @returns {function(arg1: T1): R} A new function that takes the first argument and returns the result of the original function.
|
|---|
| 415 | */
|
|---|
| 416 | declare function partial<T1, T2, T3, T4, R>(func: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => R, arg1: Placeholder, arg2: T2, arg3: T3, arg4: T4): (arg1: T1) => R;
|
|---|
| 417 | /**
|
|---|
| 418 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 419 | *
|
|---|
| 420 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 421 | *
|
|---|
| 422 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 423 | *
|
|---|
| 424 | * @template TS The types of the arguments.
|
|---|
| 425 | * @template R The return type of the function.
|
|---|
| 426 | * @param {function(...args: TS): R} func The function to partially apply.
|
|---|
| 427 | * @returns {function(...args: TS): R} A new function that takes the same arguments as the original function.
|
|---|
| 428 | *
|
|---|
| 429 | * @example
|
|---|
| 430 | * const add = (...numbers: number[]) => numbers.reduce((sum, n) => sum + n, 0);
|
|---|
| 431 | * const addFive = partial(add, 5);
|
|---|
| 432 | * console.log(addFive(1, 2, 3)); // => 11
|
|---|
| 433 | */
|
|---|
| 434 | declare function partial<TS extends any[], R>(func: (...args: TS) => R): (...args: TS) => R;
|
|---|
| 435 | /**
|
|---|
| 436 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 437 | *
|
|---|
| 438 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 439 | *
|
|---|
| 440 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 441 | *
|
|---|
| 442 | * @template TS The types of the arguments.
|
|---|
| 443 | * @template T1 The type of the first argument.
|
|---|
| 444 | * @template R The return type of the function.
|
|---|
| 445 | * @param {function(arg1: T1, ...args: TS): R} func The function to partially apply.
|
|---|
| 446 | * @param {T1} arg1 The first argument to apply.
|
|---|
| 447 | * @returns {function(...args: TS): R} A new function that takes the remaining arguments and returns the result of the original function.
|
|---|
| 448 | *
|
|---|
| 449 | * @example
|
|---|
| 450 | * const greet = (greeting: string, ...names: string[]) => `${greeting}, ${names.join(', ')}!`;
|
|---|
| 451 | * const greetHello = partial(greet, 'Hello');
|
|---|
| 452 | * console.log(greetHello('Alice', 'Bob')); // => 'Hello, Alice, Bob!'
|
|---|
| 453 | */
|
|---|
| 454 | declare function partial<TS extends any[], T1, R>(func: (arg1: T1, ...args: TS) => R, arg1: T1): (...args: TS) => R;
|
|---|
| 455 | /**
|
|---|
| 456 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 457 | *
|
|---|
| 458 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 459 | *
|
|---|
| 460 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 461 | *
|
|---|
| 462 | * @template TS The types of the arguments.
|
|---|
| 463 | * @template T1 The type of the first argument.
|
|---|
| 464 | * @template T2 The type of the second argument.
|
|---|
| 465 | * @template R The return type of the function.
|
|---|
| 466 | * @param {function(arg1: T1, arg2: T2, ...args: TS): R} func The function to partially apply.
|
|---|
| 467 | * @param {T1} arg1 The first argument to apply.
|
|---|
| 468 | * @param {T2} arg2 The second argument to apply.
|
|---|
| 469 | * @returns {function(...args: TS): R} A new function that takes the remaining arguments and returns the result of the original function.
|
|---|
| 470 | *
|
|---|
| 471 | * @example
|
|---|
| 472 | * const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`;
|
|---|
| 473 | * const greetWithHello = partial(greet, 'Hello', '!');
|
|---|
| 474 | * console.log(greetWithHello('John')); // => 'Hello, John!'
|
|---|
| 475 | */
|
|---|
| 476 | declare function partial<TS extends any[], T1, T2, R>(func: (arg1: T1, arg2: T2, ...args: TS) => R, t1: T1, arg2: T2): (...args: TS) => R;
|
|---|
| 477 | /**
|
|---|
| 478 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 479 | *
|
|---|
| 480 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 481 | *
|
|---|
| 482 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 483 | *
|
|---|
| 484 | * @template TS The types of the arguments.
|
|---|
| 485 | * @template T1 The type of the first argument.
|
|---|
| 486 | * @template T2 The type of the second argument.
|
|---|
| 487 | * @template T3 The type of the third argument.
|
|---|
| 488 | * @template R The return type of the function.
|
|---|
| 489 | * @param {function(t1: T1, arg2: T2, arg3: T3, ...args: TS): R} func The function to partially apply.
|
|---|
| 490 | * @param {T1} t1 The first argument to apply.
|
|---|
| 491 | * @param {T2} arg2 The second argument to apply.
|
|---|
| 492 | * @param {T3} arg3 The third argument to apply.
|
|---|
| 493 | * @returns {function(...args: TS): R} A new function that takes the remaining arguments and returns the result of the original function.
|
|---|
| 494 | *
|
|---|
| 495 | * @example
|
|---|
| 496 | * const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`;
|
|---|
| 497 | * const greetWithHello = partial(greet, 'Hello', 'John', '!');
|
|---|
| 498 | * console.log(greetWithHello()); // => 'Hello, John!'
|
|---|
| 499 | */
|
|---|
| 500 | declare function partial<TS extends any[], T1, T2, T3, R>(func: (t1: T1, arg2: T2, arg3: T3, ...args: TS) => R, t1: T1, arg2: T2, arg3: T3): (...args: TS) => R;
|
|---|
| 501 | /**
|
|---|
| 502 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 503 | *
|
|---|
| 504 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 505 | *
|
|---|
| 506 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 507 | *
|
|---|
| 508 | * @template TS The types of the arguments.
|
|---|
| 509 | * @template T1 The type of the first argument.
|
|---|
| 510 | * @template T2 The type of the second argument.
|
|---|
| 511 | * @template T3 The type of the third argument.
|
|---|
| 512 | * @template T4 The type of the fourth argument.
|
|---|
| 513 | * @template R The return type of the function.
|
|---|
| 514 | * @param {function(t1: T1, arg2: T2, arg3: T3, arg4: T4, ...args: TS): R} func The function to partially apply.
|
|---|
| 515 | * @param {T1} t1 The first argument to apply.
|
|---|
| 516 | * @param {T2} arg2 The second argument to apply.
|
|---|
| 517 | * @param {T3} arg3 The third argument to apply.
|
|---|
| 518 | * @param {T4} arg4 The fourth argument to apply.
|
|---|
| 519 | * @returns {function(...args: TS): R} A new function that takes the remaining arguments and returns the result of the original function.
|
|---|
| 520 | *
|
|---|
| 521 | * @example
|
|---|
| 522 | * const greet = (greeting: string, name: string, punctuation: string) => `${greeting}, ${name}${punctuation}`;
|
|---|
| 523 | * const greetWithHello = partial(greet, 'Hello', 'John', '!');
|
|---|
| 524 | * console.log(greetWithHello()); // => 'Hello, John!'
|
|---|
| 525 | */
|
|---|
| 526 | declare function partial<TS extends any[], T1, T2, T3, T4, R>(func: (t1: T1, arg2: T2, arg3: T3, arg4: T4, ...args: TS) => R, t1: T1, arg2: T2, arg3: T3, arg4: T4): (...args: TS) => R;
|
|---|
| 527 | /**
|
|---|
| 528 | * Creates a function that invokes `func` with `partialArgs` prepended to the arguments it receives. This method is like `bind` except it does not alter the `this` binding.
|
|---|
| 529 | *
|
|---|
| 530 | * The partial.placeholder value, which defaults to a `symbol`, may be used as a placeholder for partially applied arguments.
|
|---|
| 531 | *
|
|---|
| 532 | * Note: This method doesn't set the `length` property of partially applied functions.
|
|---|
| 533 | *
|
|---|
| 534 | * @template F The type of the function to partially apply.
|
|---|
| 535 | * @param {F} func The function to partially apply.
|
|---|
| 536 | * @param {...any[]} partialArgs The arguments to be partially applied.
|
|---|
| 537 | * @returns {function(...args: any[]): ReturnType<F>} A new function that takes the remaining arguments and returns the result of the original function.
|
|---|
| 538 | *
|
|---|
| 539 | * @example
|
|---|
| 540 | * const add = (...numbers: number[]) => numbers.reduce((sum, n) => sum + n, 0);
|
|---|
| 541 | * const addFive = partial(add, 5);
|
|---|
| 542 | * console.log(addFive(1, 2, 3)); // => 11
|
|---|
| 543 | */
|
|---|
| 544 | declare function partial<F extends (...args: any[]) => any>(func: F, ...partialArgs: any[]): (...args: any[]) => ReturnType<F>;
|
|---|
| 545 | declare namespace partial {
|
|---|
| 546 | var placeholder: typeof placeholderSymbol;
|
|---|
| 547 | }
|
|---|
| 548 | declare const placeholderSymbol: unique symbol;
|
|---|
| 549 | type Placeholder = typeof placeholderSymbol;
|
|---|
| 550 |
|
|---|
| 551 | export { partial };
|
|---|