Travis build: 1356
This commit is contained in:
27
README.md
27
README.md
@ -375,6 +375,7 @@ average(1, 2, 3);
|
||||
* [`hexToRGB`](#hextorgb-)
|
||||
* [`httpGet`](#httpget)
|
||||
* [`httpPost`](#httppost)
|
||||
* [`nthArg`](#ntharg)
|
||||
* [`parseCookie`](#parsecookie)
|
||||
* [`prettyBytes`](#prettybytes)
|
||||
* [`randomHexColorCode`](#randomhexcolorcode)
|
||||
@ -6396,6 +6397,32 @@ Logs: {
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### nthArg
|
||||
|
||||
Creates a function that gets the argument at index `n`. If `n` is negative, the nth argument from the end is returned.
|
||||
|
||||
Use `Array.slice()` to get the desired argument at index `n`.
|
||||
|
||||
```js
|
||||
const nthArg = n => (...args) => args.slice(n)[0];
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
const third = nthArg(2);
|
||||
third(1, 2, 3); // 3
|
||||
third(1, 2); // undefined
|
||||
const last = nthArg(-1);
|
||||
last(1, 2, 3, 4, 5); // 5
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### parseCookie
|
||||
|
||||
Parse an HTTP Cookie header string and return an object of all cookie name-value pairs.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -10,8 +10,8 @@ const nthArg = n => (...args) => args.slice(n)[0];
|
||||
|
||||
```js
|
||||
const third = nthArg(2);
|
||||
third(1,2,3); // 3
|
||||
third(1,2); // undefined
|
||||
third(1, 2, 3); // 3
|
||||
third(1, 2); // undefined
|
||||
const last = nthArg(-1);
|
||||
last(1,2,3,4,5); // 5
|
||||
last(1, 2, 3, 4, 5); // 5
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user