Module types
The types module provides tool functions for determining data types.
The following is a specific introduction and examples:
1
2
3var util = require('util');
console.log(util.types.isDate(new Date()));
console.log(util.types.isRegExp(/some regexp/));
static function
isEmpty
Checks if the given variable contains no value (no enumerable properties)
1static Boolean types.isEmpty(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if empty
isArray
Checks whether the given variable is an array
1static Boolean types.isArray(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is an array
isBoolean
Tests whether the given variable is a Boolean
1static Boolean types.isBoolean(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is Boolean, it returns True
isNull
Checks whether the given variable is Null
1static Boolean types.isNull(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is Null, it returns True
isNullOrUndefined
Checks whether the given variable is Null or Undefined
1static Boolean types.isNullOrUndefined(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is Null or Undefined, it returns True
isNumber
Tests whether the given variable is a number
1static Boolean types.isNumber(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is a number
isBigInt
Tests whether the given variable is a BigInt
1static Boolean types.isBigInt(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is a number
isString
Checks whether the given variable is a string
1static Boolean types.isString(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is a string
isUndefined
Checks whether the given variable is Undefined
1static Boolean types.isUndefined(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is Undefined, return True
isRegExp
Tests whether the given variable is a regular object
1static Boolean types.isRegExp(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is a regular object
isObject
Tests whether the given variable is an object
1static Boolean types.isObject(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is an object
isDate
Tests whether the given variable is a date object
1static Boolean types.isDate(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is a date object
isNativeError
Tests whether the given variable is an error object
1static Boolean types.isNativeError(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is an error object
isPrimitive
Checks whether the given variable is of primitive type
1static Boolean types.isPrimitive(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is a primitive type
isSymbol
Check whether the given variable is of type Symbol
1static Boolean types.isSymbol(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is a Symbol type, it returns True
isDataView
Checks whether the given variable is of type DataView
1static Boolean types.isDataView(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is a DataView type, it returns True
isExternal
Checks whether the given variable is of type External
1static Boolean types.isExternal(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is an External type, it returns True
isMap
Check whether the given variable is of type Map
1static Boolean types.isMap(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is a Map type, it returns True
isMapIterator
Checks whether the given variable is of type MapIterator
1static Boolean types.isMapIterator(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is a MapIterator type
isPromise
Checks whether the given variable is of type Promise
1static Boolean types.isPromise(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is a Promise type, it returns True
isAsyncFunction
Checks whether the given variable is of type AsyncFunction
1static Boolean types.isAsyncFunction(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is an AsyncFunction type, it returns True
isSet
Checks whether the given variable is of type Set
1static Boolean types.isSet(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is a Set type, it returns True
isSetIterator
Checks whether the given variable is of type SetIterator
1static Boolean types.isSetIterator(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is a SetIterator type, it returns True
isTypedArray
Checks whether the given variable is of type TypedArray
1static Boolean types.isTypedArray(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is a TypedArray type, it returns True
isFloat32Array
Checks whether the given variable is of type Float32Array
1static Boolean types.isFloat32Array(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is a Float32Array type, it returns True
isFloat64Array
Checks whether the given variable is of type Float64Array
1static Boolean types.isFloat64Array(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is a Float64Array type, it returns True
isInt8Array
Checks whether the given variable is of type Int8Array
1static Boolean types.isInt8Array(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is of type Int8Array, it returns True
isInt16Array
Checks whether the given variable is of type Int16Array
1static Boolean types.isInt16Array(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is an Int16Array type, it returns True
isInt32Array
Checks whether the given variable is of type Int32Array
1static Boolean types.isInt32Array(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is of type Int32Array, it returns True
isUint8Array
Checks whether the given variable is of type Uint8Array
1static Boolean types.isUint8Array(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is Uint8Array type
isUint8ClampedArray
Checks whether the given variable is of type Uint8ClampedArray
1static Boolean types.isUint8ClampedArray(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is Uint8ClampedArray type
isUint16Array
Checks whether the given variable is of type Uint16Array
1static Boolean types.isUint16Array(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is Uint16Array type
isUint32Array
Checks whether the given variable is of type Uint32Array
1static Boolean types.isUint32Array(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is Uint32Array type
isFunction
Tests whether the given variable is a function object
1static Boolean types.isFunction(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, returns True if it is a function object
isBuffer
Tests whether the given variable is a functionBufferobject
1static Boolean types.isBuffer(Value v);
Call parameters:
- v: Value, given the variable to be detected
Return results:
- Boolean, if it is a functionBufferObject returns True