Travis build: 727 [ci skip]

This commit is contained in:
Travis CI
2017-12-31 13:06:22 +00:00
parent e5013c22b3
commit 5a4905925a
5 changed files with 96 additions and 12 deletions

View File

@ -261,6 +261,16 @@
</details>
### _Uncategorized_
<details>
<summary>View contents</summary>
* [`isArrayLike`](#isarraylike)
* [`isValidJSON`](#isvalidjson)
</details>
---
## 🔌 Adapter
@ -4394,6 +4404,59 @@ yesNo('Foo', true); // true
<br>[⬆ Back to top](#table-of-contents)
---
## _Uncategorized_
### isArrayLike
Checks if the provided argument is array-like (i.e. is iterable).
Use `Array.from()` and a `try... catch` block to check if the provided argument is array-like.
```js
const isArrayLike = arr => {
try {
Array.from(arr);
return true;
} catch (e) {
return false;
}
};
```
```js
isArrayLike(document.querySelector('.className')); // true
isArrayLike('abc'); // true
isArrayLike(null); // false
```
<br>[⬆ back to top](#table-of-contents)
### isValidJSON
Checks if the provided argument is a valid JSON.
Use `JSON.parse()` and a `try... catch` block to check if the provided argument is a valid JSON.
```js
const isValidJSON = obj => {
try {
JSON.parse(obj);
return true;
} catch (e) {
return false;
}
};
```
```js
isValidJSON('{"name":"Adam","age":20}'); // true
isValidJSON('{"name":"Adam",age:"20"}'); // false
```
<br>[⬆ back to top](#table-of-contents)
## Collaborators

File diff suppressed because one or more lines are too long

View File

@ -6,18 +6,17 @@ Use `Array.from()` and a `try... catch` block to check if the provided argument
```js
const isArrayLike = arr => {
try{
try {
Array.from(arr);
return true;
}
catch(e){
} catch (e) {
return false;
}
}
};
```
```js
isArrayLike(document.querySelector('.className')) // true
isArrayLike('abc') // true
isArrayLike(null) // false
isArrayLike(document.querySelector('.className')); // true
isArrayLike('abc'); // true
isArrayLike(null); // false
```

View File

@ -6,14 +6,13 @@ Use `JSON.parse()` and a `try... catch` block to check if the provided argument
```js
const isValidJSON = obj => {
try{
try {
JSON.parse(obj);
return true;
}
catch(e){
} catch (e) {
return false;
}
}
};
```
```js

View File

@ -66,6 +66,7 @@ inRange:math
intersection:array
isArmstrongNumber:math
isArray:utility
isArrayLike:uncategorized
isBoolean:utility
isDivisible:math
isEven:math
@ -75,6 +76,7 @@ isNumber:utility
isPrime:math
isString:utility
isSymbol:utility
isValidJSON:uncategorized
JSONToDate:date
JSONToFile:node
last:array