Travis build: 728 [ci skip]
This commit is contained in:
126
README.md
126
README.md
@ -244,12 +244,14 @@
|
||||
* [`getType`](#gettype)
|
||||
* [`hexToRGB`](#hextorgb)
|
||||
* [`isArray`](#isarray)
|
||||
* [`isArrayLike`](#isarraylike)
|
||||
* [`isBoolean`](#isboolean)
|
||||
* [`isFunction`](#isfunction)
|
||||
* [`isNull`](#isnull)
|
||||
* [`isNumber`](#isnumber)
|
||||
* [`isString`](#isstring)
|
||||
* [`isSymbol`](#issymbol)
|
||||
* [`isValidJSON`](#isvalidjson)
|
||||
* [`randomHexColorCode`](#randomhexcolorcode)
|
||||
* [`RGBToHex`](#rgbtohex)
|
||||
* [`sdbm`](#sdbm)
|
||||
@ -261,16 +263,6 @@
|
||||
|
||||
</details>
|
||||
|
||||
### _Uncategorized_
|
||||
|
||||
<details>
|
||||
<summary>View contents</summary>
|
||||
|
||||
* [`isArrayLike`](#isarraylike)
|
||||
* [`isValidJSON`](#isvalidjson)
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
## 🔌 Adapter
|
||||
|
||||
@ -4057,6 +4049,37 @@ isArray([1]); // true
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### 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;
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
isArrayLike(document.querySelector('.className')); // true
|
||||
isArrayLike('abc'); // true
|
||||
isArrayLike(null); // false
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### isBoolean
|
||||
|
||||
Checks if the given argument is a native boolean element.
|
||||
@ -4194,6 +4217,36 @@ isSymbol(Symbol('x')); // true
|
||||
<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;
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
isValidJSON('{"name":"Adam","age":20}'); // true
|
||||
isValidJSON('{"name":"Adam",age:"20"}'); // false
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### randomHexColorCode
|
||||
|
||||
Generates a random hexadecimal color code.
|
||||
@ -4404,59 +4457,6 @@ 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
Reference in New Issue
Block a user