Travis build: 1196

This commit is contained in:
30secondsofcode
2018-01-11 19:20:57 +00:00
parent 7c90851e90
commit 0fc59a817c
5 changed files with 85 additions and 6 deletions

View File

@ -261,6 +261,8 @@ average(1, 2, 3);
<summary>View contents</summary> <summary>View contents</summary>
* [`cleanObj`](#cleanobj) * [`cleanObj`](#cleanobj)
* [`functions`](#functions)
* [`functionsIn`](#functionsin)
* [`invertKeyValues`](#invertkeyvalues) * [`invertKeyValues`](#invertkeyvalues)
* [`lowercaseKeys`](#lowercasekeys) * [`lowercaseKeys`](#lowercasekeys)
* [`mapKeys`](#mapkeys) * [`mapKeys`](#mapkeys)
@ -3922,6 +3924,63 @@ cleanObj(testObj, ['a'], 'children'); // { a: 1, children : { a: 1}}
<br>[⬆ Back to top](#table-of-contents) <br>[⬆ Back to top](#table-of-contents)
### functions
Returns an array of function property names from own enumerable properties of object.
Use `Object.keys(obj)` to iterate over the object's own properties, `Array.filter()` to keep only those that are functions.
```js
const functions = obj => Object.keys(obj).filter(key => typeof obj[key] === 'function');
```
<details>
<summary>Examples</summary>
```js
function Foo() {
this.a = () => 1;
this.b = () => 2;
}
functions(new Foo()); // ['a', 'b']
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### functionName
Returns an array of function property names from own and inherited enumerable properties of object.
Use `Object.keys(obj)` and `Object.get.PrototypeOf(obj)` to iterate over the object's own and inherited properties, `Array.filter()` to keep only those that are functions.
Use the spread operator (`...`) to combine all returned property names into one array.
```js
const functionsIn = obj =>
[...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))].filter(
key => typeof obj[key] === 'function'
);
```
<details>
<summary>Examples</summary>
```js
function Foo() {
this.a = () => 1;
this.b = () => 2;
}
Foo.prototype.c = () => 3;
functionsIn(new Foo()); // ['a', 'b', 'c']
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### invertKeyValues ### invertKeyValues
Inverts the key-value pairs of an object, without mutating it. Inverts the key-value pairs of an object, without mutating it.
@ -5427,6 +5486,7 @@ const httpPost = (url, callback, data = null, err = console.error) => {
const newPost = { const newPost = {
"userId": 1, "userId": 1,
"id": 1337, "id": 1337,

File diff suppressed because one or more lines are too long

View File

@ -5,8 +5,7 @@ Returns an array of function property names from own enumerable properties of ob
Use `Object.keys(obj)` to iterate over the object's own properties, `Array.filter()` to keep only those that are functions. Use `Object.keys(obj)` to iterate over the object's own properties, `Array.filter()` to keep only those that are functions.
```js ```js
const functions = obj => const functions = obj => Object.keys(obj).filter(key => typeof obj[key] === 'function');
Object.keys(obj).filter(key => typeof obj[key] === 'function');
``` ```
```js ```js
@ -14,5 +13,5 @@ function Foo() {
this.a = () => 1; this.a = () => 1;
this.b = () => 2; this.b = () => 2;
} }
functions(new Foo); // ['a', 'b'] functions(new Foo()); // ['a', 'b']
``` ```

View File

@ -7,7 +7,9 @@ Use the spread operator (`...`) to combine all returned property names into one
```js ```js
const functionsIn = obj => const functionsIn = obj =>
[...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))].filter(key => typeof obj[key] === 'function'); [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))].filter(
key => typeof obj[key] === 'function'
);
``` ```
```js ```js
@ -16,5 +18,5 @@ function Foo() {
this.b = () => 2; this.b = () => 2;
} }
Foo.prototype.c = () => 3; Foo.prototype.c = () => 3;
functionsIn(new Foo); // ['a', 'b', 'c'] functionsIn(new Foo()); // ['a', 'b', 'c']
``` ```

View File

@ -36,6 +36,7 @@ const httpPost = (url, callback, data = null, err = console.error) => {
const newPost = { const newPost = {
"userId": 1, "userId": 1,
"id": 1337, "id": 1337,