fix type and make strict equal
This commit is contained in:
76
README.md
76
README.md
@ -503,16 +503,16 @@ const firstTwoMax = ary(Math.max, 2);
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### call
|
### call
|
||||||
|
|
||||||
Given a key and a set of arguments, call them when given a context. Primarily useful in composition.
|
Given a key and a set of arguments, call them when given a context. Primarily useful in composition.
|
||||||
|
|
||||||
Use a closure to call a stored key with stored arguments.
|
Use a closure to call a stored key with stored arguments.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const call = (key, ...args) => context => context[key](...args);
|
const call = (key, ...args) => context => context[key](...args);
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Examples</summary>
|
<summary>Examples</summary>
|
||||||
|
|
||||||
@ -524,23 +524,23 @@ const map = call.bind(null, 'map');
|
|||||||
Promise.resolve([1, 2, 3])
|
Promise.resolve([1, 2, 3])
|
||||||
.then(map(x => 2 * x))
|
.then(map(x => 2 * x))
|
||||||
.then(console.log); //[ 2, 4, 6 ]
|
.then(console.log); //[ 2, 4, 6 ]
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### collectInto
|
### collectInto
|
||||||
|
|
||||||
Changes a function that accepts an array into a variadic function.
|
Changes a function that accepts an array into a variadic function.
|
||||||
|
|
||||||
Given a function, return a closure that collects all inputs into an array-accepting function.
|
Given a function, return a closure that collects all inputs into an array-accepting function.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const collectInto = fn => (...args) => fn(args);
|
const collectInto = fn => (...args) => fn(args);
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Examples</summary>
|
<summary>Examples</summary>
|
||||||
|
|
||||||
@ -550,23 +550,23 @@ let p1 = Promise.resolve(1);
|
|||||||
let p2 = Promise.resolve(2);
|
let p2 = Promise.resolve(2);
|
||||||
let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
|
let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
|
||||||
Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds)
|
Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds)
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### flip
|
### flip
|
||||||
|
|
||||||
Flip takes a function as an argument, then makes the first argument the last.
|
Flip takes a function as an argument, then makes the first argument the last.
|
||||||
|
|
||||||
Return a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest.
|
Return a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const flip = fn => (first, ...rest) => fn(...rest, first);
|
const flip = fn => (first, ...rest) => fn(...rest, first);
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Examples</summary>
|
<summary>Examples</summary>
|
||||||
|
|
||||||
@ -578,7 +578,7 @@ let mergePerson = mergeFrom.bind(null, a);
|
|||||||
mergePerson(b); // == b
|
mergePerson(b); // == b
|
||||||
b = {};
|
b = {};
|
||||||
Object.assign(b, a); // == b
|
Object.assign(b, a); // == b
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
@ -754,23 +754,23 @@ rearged('b', 'c', 'a'); // ['a', 'b', 'c']
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### spreadOver
|
### spreadOver
|
||||||
|
|
||||||
Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.
|
Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.
|
||||||
|
|
||||||
Use closures and the spread operator (`...`) to map the array of arguments to the inputs of the function.
|
Use closures and the spread operator (`...`) to map the array of arguments to the inputs of the function.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const spreadOver = fn => argsArr => fn(...argsArr);
|
const spreadOver = fn => argsArr => fn(...argsArr);
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Examples</summary>
|
<summary>Examples</summary>
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const arrayMax = spreadOver(Math.max);
|
const arrayMax = spreadOver(Math.max);
|
||||||
arrayMax([1, 2, 3]); // 3
|
arrayMax([1, 2, 3]); // 3
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
@ -6694,7 +6694,7 @@ const matchesWith = (obj, source, fn) =>
|
|||||||
key =>
|
key =>
|
||||||
obj.hasOwnProperty(key) && fn
|
obj.hasOwnProperty(key) && fn
|
||||||
? fn(obj[key], source[key], key, obj, source)
|
? fn(obj[key], source[key], key, obj, source)
|
||||||
: obj[key] == source[key]
|
: obj[key] === source[key]
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -7114,7 +7114,7 @@ truthCheckCollection([{ user: 'Tinky-Winky', sex: 'male' }, { user: 'Dipsy', sex
|
|||||||
|
|
||||||
### unflattenObject 
|
### unflattenObject 
|
||||||
|
|
||||||
Unlatten an object with the paths for keys.
|
Unflatten an object with the paths for keys.
|
||||||
|
|
||||||
Use `Object.keys(obj)` combined with `Array.reduce()` to convert flattened path node to a leaf node.
|
Use `Object.keys(obj)` combined with `Array.reduce()` to convert flattened path node to a leaf node.
|
||||||
If the value of a key contains a dot delimiter (`.`), use `Array.split('.')`, string transformations and `JSON.parse()` to create an object, then `Object.assign()` to create the leaf node.
|
If the value of a key contains a dot delimiter (`.`), use `Array.split('.')`, string transformations and `JSON.parse()` to create an object, then `Object.assign()` to create the leaf node.
|
||||||
|
|||||||
@ -11,7 +11,7 @@ const matchesWith = (obj, source, fn) =>
|
|||||||
key =>
|
key =>
|
||||||
obj.hasOwnProperty(key) && fn
|
obj.hasOwnProperty(key) && fn
|
||||||
? fn(obj[key], source[key], key, obj, source)
|
? fn(obj[key], source[key], key, obj, source)
|
||||||
: obj[key] == source[key]
|
: obj[key] === source[key]
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
### unflattenObject
|
### unflattenObject
|
||||||
|
|
||||||
Unlatten an object with the paths for keys.
|
Unflatten an object with the paths for keys.
|
||||||
|
|
||||||
Use `Object.keys(obj)` combined with `Array.reduce()` to convert flattened path node to a leaf node.
|
Use `Object.keys(obj)` combined with `Array.reduce()` to convert flattened path node to a leaf node.
|
||||||
If the value of a key contains a dot delimiter (`.`), use `Array.split('.')`, string transformations and `JSON.parse()` to create an object, then `Object.assign()` to create the leaf node.
|
If the value of a key contains a dot delimiter (`.`), use `Array.split('.')`, string transformations and `JSON.parse()` to create an object, then `Object.assign()` to create the leaf node.
|
||||||
|
|||||||
Reference in New Issue
Block a user