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