Update formatting
This commit is contained in:
@ -7,7 +7,7 @@ lastUpdated: 2020-10-18T20:24:28+03:00
|
||||
|
||||
Creates a function that accepts up to `n` arguments, ignoring any additional arguments.
|
||||
|
||||
- Call the provided function, `fn`, with up to `n` arguments, using `Array.prototype.slice(0, n)` and the spread operator (`...`).
|
||||
- Call the provided function, `fn`, with up to `n` arguments, using `Array.prototype.slice()` and the spread operator (`...`).
|
||||
|
||||
```js
|
||||
const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
|
||||
|
||||
@ -7,7 +7,7 @@ lastUpdated: 2020-11-03T21:46:13+02:00
|
||||
|
||||
Returns all the elements of an array except the last one.
|
||||
|
||||
- Use `Array.prototype.slice(0, -1)` to return all but the last element of the array.
|
||||
- Use `Array.prototype.slice()` to return all but the last element of the array.
|
||||
|
||||
```js
|
||||
const initial = arr => arr.slice(0, -1);
|
||||
|
||||
@ -7,7 +7,8 @@ lastUpdated: 2020-10-22T20:24:30+03:00
|
||||
|
||||
Returns all elements in an array except for the first one.
|
||||
|
||||
- Return `Array.prototype.slice(1)` if `Array.prototype.length` is more than `1`, otherwise, return the whole array.
|
||||
- Use `Array.prototype.slice()`to return the array without the first element if `Array.prototype.length` is more than `1`.
|
||||
- Otherwise, return the whole array.
|
||||
|
||||
```js
|
||||
const tail = arr => (arr.length > 1 ? arr.slice(1) : arr);
|
||||
|
||||
@ -10,7 +10,7 @@ Uncurries a function up to depth `n`.
|
||||
- Return a variadic function.
|
||||
- Use `Array.prototype.reduce()` on the provided arguments to call each subsequent curry level of the function.
|
||||
- If the `length` of the provided arguments is less than `n` throw an error.
|
||||
- Otherwise, call `fn` with the proper amount of arguments, using `Array.prototype.slice(0, n)`.
|
||||
- Otherwise, call `fn` with the proper amount of arguments, using `Array.prototype.slice()`.
|
||||
- Omit the second argument, `n`, to uncurry up to depth `1`.
|
||||
|
||||
```js
|
||||
|
||||
Reference in New Issue
Block a user