From b48fa8f16ddcce5bc39e95479114a8443322af9b Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Tue, 16 Jan 2018 16:42:17 +0200 Subject: [PATCH] Added a few type checking snippets from lodash --- snippets/isArrayBuffer.md | 13 +++++++++++++ snippets/isMap.md | 13 +++++++++++++ snippets/isRegExp.md | 13 +++++++++++++ snippets/isSet.md | 13 +++++++++++++ snippets/isTypedArray.md | 13 +++++++++++++ snippets/isWeakMap.md | 13 +++++++++++++ snippets/isWeakSet.md | 13 +++++++++++++ tag_database | 7 +++++++ 8 files changed, 98 insertions(+) create mode 100644 snippets/isArrayBuffer.md create mode 100644 snippets/isMap.md create mode 100644 snippets/isRegExp.md create mode 100644 snippets/isSet.md create mode 100644 snippets/isTypedArray.md create mode 100644 snippets/isWeakMap.md create mode 100644 snippets/isWeakSet.md diff --git a/snippets/isArrayBuffer.md b/snippets/isArrayBuffer.md new file mode 100644 index 000000000..7c28d4398 --- /dev/null +++ b/snippets/isArrayBuffer.md @@ -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 +``` diff --git a/snippets/isMap.md b/snippets/isMap.md new file mode 100644 index 000000000..b3a202c5d --- /dev/null +++ b/snippets/isMap.md @@ -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 +``` diff --git a/snippets/isRegExp.md b/snippets/isRegExp.md new file mode 100644 index 000000000..db57bf587 --- /dev/null +++ b/snippets/isRegExp.md @@ -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 +``` diff --git a/snippets/isSet.md b/snippets/isSet.md new file mode 100644 index 000000000..bddf3fcbb --- /dev/null +++ b/snippets/isSet.md @@ -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 +``` diff --git a/snippets/isTypedArray.md b/snippets/isTypedArray.md new file mode 100644 index 000000000..7b7416bf9 --- /dev/null +++ b/snippets/isTypedArray.md @@ -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 +``` diff --git a/snippets/isWeakMap.md b/snippets/isWeakMap.md new file mode 100644 index 000000000..432f17f7e --- /dev/null +++ b/snippets/isWeakMap.md @@ -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 +``` diff --git a/snippets/isWeakSet.md b/snippets/isWeakSet.md new file mode 100644 index 000000000..a72a1f0ac --- /dev/null +++ b/snippets/isWeakSet.md @@ -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 +``` diff --git a/tag_database b/tag_database index 83883ba8a..34a1c6e92 100644 --- a/tag_database +++ b/tag_database @@ -81,24 +81,31 @@ intersection:array,math invertKeyValues:object isAbsoluteURL:string,utility,browser,url isArray:type,array +isArrayBuffer:type isArrayLike:type,array isBoolean:type isDivisible:math isEven:math isFunction:type,function isLowerCase:string,utility +isMap:type isNull:type isNumber:type,math isObject:type,object isPrime:math isPrimitive:type,function,array,string isPromiseLike:type,function,promise +isRegExp:type,regexp +isSet:type isSorted:array isString:type,string isSymbol:type isTravisCI:node +isTypedArray:type isUpperCase:string,utility isValidJSON:type,json +isWeakMap:type +isWeakSet:type join:array JSONToFile:node,json last:array