Travis build: 727 [ci skip]
This commit is contained in:
63
README.md
63
README.md
@ -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
@ -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
|
||||
```
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user