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> </details>
### _Uncategorized_
<details>
<summary>View contents</summary>
* [`isArrayLike`](#isarraylike)
* [`isValidJSON`](#isvalidjson)
</details>
--- ---
## 🔌 Adapter ## 🔌 Adapter
@ -4394,6 +4404,59 @@ yesNo('Foo', true); // true
<br>[⬆ Back to top](#table-of-contents) <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 ## 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 ```js
const isArrayLike = arr => { const isArrayLike = arr => {
try{ try {
Array.from(arr); Array.from(arr);
return true; return true;
} } catch (e) {
catch(e){
return false; return false;
} }
} };
``` ```
```js ```js
isArrayLike(document.querySelector('.className')) // true isArrayLike(document.querySelector('.className')); // true
isArrayLike('abc') // true isArrayLike('abc'); // true
isArrayLike(null) // false isArrayLike(null); // false
``` ```

View File

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

View File

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