Added a few type checking snippets from lodash
This commit is contained in:
13
snippets/isArrayBuffer.md
Normal file
13
snippets/isArrayBuffer.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
### isArrayBuffer
|
||||||
|
|
||||||
|
Checks if value is classified as a ArrayBuffer object.
|
||||||
|
|
||||||
|
Use the `instanceof`operator to check if the provided value is a `ArrayBuffer` object.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const isArrayBuffer = val => val instanceof ArrayBuffer;
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
isArrayBuffer(new ArrayBuffer()); // true
|
||||||
|
```
|
||||||
13
snippets/isMap.md
Normal file
13
snippets/isMap.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
### isMap
|
||||||
|
|
||||||
|
Checks if value is classified as a Map object.
|
||||||
|
|
||||||
|
Use the `instanceof`operator to check if the provided value is a `Map` object.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const isMap = val => val instanceof Map;
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
isMap(new Map()); // true
|
||||||
|
```
|
||||||
13
snippets/isRegExp.md
Normal file
13
snippets/isRegExp.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
### isRegExp
|
||||||
|
|
||||||
|
Checks if value is classified as a RegExp object.
|
||||||
|
|
||||||
|
Use the `instanceof`operator to check if the provided value is a `RegExp` object.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const isRegExp = val => val instanceof RegExp;
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
isRegExp(/./g); // true
|
||||||
|
```
|
||||||
13
snippets/isSet.md
Normal file
13
snippets/isSet.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
### isSet
|
||||||
|
|
||||||
|
Checks if value is classified as a Set object.
|
||||||
|
|
||||||
|
Use the `instanceof`operator to check if the provided value is a `Set` object.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const isSet = val => val instanceof Set;
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
isSet(new Set()); // true
|
||||||
|
```
|
||||||
13
snippets/isTypedArray.md
Normal file
13
snippets/isTypedArray.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
### isTypedArray
|
||||||
|
|
||||||
|
Checks if value is classified as a TypedArray object.
|
||||||
|
|
||||||
|
Use the `instanceof`operator to check if the provided value is a `TypedArray` object.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const isTypedArray = val => val instanceof TypedArray;
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
isTypedArray(new TypedArray()); // true
|
||||||
|
```
|
||||||
13
snippets/isWeakMap.md
Normal file
13
snippets/isWeakMap.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
### isWeakMap
|
||||||
|
|
||||||
|
Checks if value is classified as a WeakMap object.
|
||||||
|
|
||||||
|
Use the `instanceof`operator to check if the provided value is a `WeakMap` object.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const isWeakMap = val => val instanceof WeakMap;
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
isWeakMap(new WeakMap()); // true
|
||||||
|
```
|
||||||
13
snippets/isWeakSet.md
Normal file
13
snippets/isWeakSet.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
### isWeakSet
|
||||||
|
|
||||||
|
Checks if value is classified as a WeakSet object.
|
||||||
|
|
||||||
|
Use the `instanceof`operator to check if the provided value is a `WeakSet` object.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const isWeakSet = val => val instanceof WeakSet;
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
isWeakSet(new WeakSet()); // true
|
||||||
|
```
|
||||||
@ -81,24 +81,31 @@ intersection:array,math
|
|||||||
invertKeyValues:object
|
invertKeyValues:object
|
||||||
isAbsoluteURL:string,utility,browser,url
|
isAbsoluteURL:string,utility,browser,url
|
||||||
isArray:type,array
|
isArray:type,array
|
||||||
|
isArrayBuffer:type
|
||||||
isArrayLike:type,array
|
isArrayLike:type,array
|
||||||
isBoolean:type
|
isBoolean:type
|
||||||
isDivisible:math
|
isDivisible:math
|
||||||
isEven:math
|
isEven:math
|
||||||
isFunction:type,function
|
isFunction:type,function
|
||||||
isLowerCase:string,utility
|
isLowerCase:string,utility
|
||||||
|
isMap:type
|
||||||
isNull:type
|
isNull:type
|
||||||
isNumber:type,math
|
isNumber:type,math
|
||||||
isObject:type,object
|
isObject:type,object
|
||||||
isPrime:math
|
isPrime:math
|
||||||
isPrimitive:type,function,array,string
|
isPrimitive:type,function,array,string
|
||||||
isPromiseLike:type,function,promise
|
isPromiseLike:type,function,promise
|
||||||
|
isRegExp:type,regexp
|
||||||
|
isSet:type
|
||||||
isSorted:array
|
isSorted:array
|
||||||
isString:type,string
|
isString:type,string
|
||||||
isSymbol:type
|
isSymbol:type
|
||||||
isTravisCI:node
|
isTravisCI:node
|
||||||
|
isTypedArray:type
|
||||||
isUpperCase:string,utility
|
isUpperCase:string,utility
|
||||||
isValidJSON:type,json
|
isValidJSON:type,json
|
||||||
|
isWeakMap:type
|
||||||
|
isWeakSet:type
|
||||||
join:array
|
join:array
|
||||||
JSONToFile:node,json
|
JSONToFile:node,json
|
||||||
last:array
|
last:array
|
||||||
|
|||||||
Reference in New Issue
Block a user