Utility functions for working with data types.
Classes
Methods
(static) getTypeName(value) → {string}
- Description:
- Returns the type name of a given value. - For primitives: returns `"string"`, `"number"`, etc. - For objects: returns class name or `"object"` if plain. - For built-in types like Date, RegExp, Map: returns the constructor name. - For plain objects: returns "object". For arrays: "array". - For classes: returns `"class"` for user defined classes. - For functions: returns `"function"`
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value whose type name to determine. |
Returns:
The detected type name.
- Type
- string
(static) inferDataType(value) → {InferDataTypeResult}
- Description:
- Parses common values like string "true" → boolean true, "42.0" → number, etc.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* |
Returns:
- Type
- InferDataTypeResult
(static) isArray(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
- `true` if the specified value is an array.
- Type
- boolean
(static) isAsyncFunction(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
- `true` if the specified value is an asynchronous function.
- Type
- boolean
(static) isBigInt(value) → {boolean}
- Description:
- Checks if the specified value is a bigint (primitive or BigInt object).
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
- `true` if the specified value is big integer.
- Type
- boolean
(static) isBoolean(value) → {boolean}
- Description:
- Checks if the specified value is a boolean (primitive or Boolean object).
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
- `true` if the specified value is boolean.
- Type
- boolean
(static) isDate(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
- `true` if the specified value is instance of Date.
- Type
- boolean
(static) isEmpty(value) → {boolean}
- Description:
- Checks if the specified value is "empty". The following are considered empty: - null, undefined - empty string: "" - empty array: [] - empty object: {} - empty Map or Set - Note: The implementation avoids treating numbers or booleans as "empty". Only typical "container-like" values and nullish types are evaluated.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
`true` if the value is considered empty.
- Type
- boolean
(static) isError(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
- `true` if the specified value is of Error type.
- Type
- boolean
(static) isFunction(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
- `true` if the specified value is Function.
- Type
- boolean
(static) isFunctionOrGeneratorFunction(value) → {boolean}
- Description:
- Checks if the specified value is a function or a generator function.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
- `true` if the specified value is a function or a generator function.
- Type
- boolean
(static) isGeneratorFunction(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
- `true` if the specified value is a generator function.
- Type
- boolean
(static) isIntegral(value, additionalPredicateopt) → {boolean}
- Description:
- Checks if the value is an integer (number or bigint), optionally applying a custom predicate.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
* | The value to test. | ||
additionalPredicate |
function |
<optional> |
null
|
Additional test to apply to the value. |
Returns:
- `true` if the value is integral number and passed the test against the additional predicate (if it was specified) .
- Type
- boolean
(static) isIterable(value) → {boolean}
- Description:
- Checks if the specified value is iterable (has a `[Symbol.iterator]` method).
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
- `true` if the specified value is iterable (has a `[Symbol.iterator]` method).
- Type
- boolean
(static) isMap(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
`true` if the value is a Map.
- Type
- boolean
(static) isNotEmpty(value) → {boolean}
- Description:
- Checks if the specified value is not empty. See `isEmpty` for full empty definition.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
`true` if the value is not considered empty.
- Type
- boolean
(static) isNull(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
- `true` if the specified value is null.
- Type
- boolean
(static) isNumber(value, optionsopt) → {boolean}
- Description:
- Checks whether the specified value is a number (primitive or Number object). Excludes NaN and Infinity by default unless explicitly allowed.
- Source:
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
value |
* | The value to test. | ||||||||||||||||
options |
Object |
<optional> |
Properties
|
Returns:
- `true` if the specified value is a number.
- Type
- boolean
(static) isNumeric(value) → {boolean}
- Description:
- Checks if the value is a numeric type (either number or bigint).
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* |
Returns:
- `true` if the value is a numeric type (either number or bigint).
- Type
- boolean
(static) isObject(value) → {boolean}
- Description:
- Checks if the specified value is a non-wrapper object (i.e., not a function, not null, not a boxed primitive). Includes objects like arrays, plain objects, Date, RegExp, etc.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to check. |
Returns:
`true` if it's a real object, excluding primitive wrappers and functions.
- Type
- boolean
(static) isPlainObject(value) → {boolean}
- Description:
- Checks if the specified value is a plain object (i.e., created via `{}` or `new Object()`). This works reliably across realms.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to check. |
Returns:
`true` if it's a plain object.
- Type
- boolean
(static) isPrimitive(value) → {boolean}
- Description:
- Determines whether the specified value is one of the primitive types: string, number, bigint, boolean and symbol (including wrapper type over primitive) This function treats primitives any of the following: string, number, boolean, symbol, bigint and their wrapper String, Number, Boolean.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* |
Returns:
- true if the specified value is one of the primitive types: string, number, bigint, boolean and symbol (including wrapper type over primitive)
- Type
- boolean
(static) isPromise(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
`true` if the value is a Promise.
- Type
- boolean
(static) isRegExp(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
`true` if the value is a RegExp.
- Type
- boolean
(static) isSet(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
`true` if the value is a Set.
- Type
- boolean
(static) isString(value) → {boolean}
- Description:
- Checks if the specified value is a string (primitive or String object).
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
`true` if the specified value is a string.
- Type
- boolean
(static) isSymbol(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
`true` if the specified value is a symbol.
- Type
- boolean
(static) isType(value, typeName) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
typeName |
string | The expected type name. |
Returns:
`true` if the value’s type matches the given name.
- Type
- boolean
(static) isUndefined(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
- `true` if the specified value is undefined.
- Type
- boolean
(static) isUserDefinedClass(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
- `true` if the specified value is user defined class.
- Type
- boolean
(static) isWeakMap(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
`true` if the value is a WeakMap.
- Type
- boolean
(static) isWeakSet(value) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to test. |
Returns:
`true` if the value is a WeakSet.
- Type
- boolean
(static) parseBool(value) → {boolean|undefined}
- Description:
- Parses a string to boolean. If the input is already boolean, returns it. If it's "true" or "false" (case insensitive), converts accordingly.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
value |
* | The value to parse. |
Returns:
- 'true' if the specified value is a string trimmed to literal 'true' (case insensitive) or `false` if it is trimmed to literal 'false' (case insensitive).
- Type
- boolean | undefined
(static) version() → {string}
Returns:
- The semantic version of this library.
- Type
- string
(inner) isClass(fn) → {boolean}
- Description:
- Determines whether the given function is a user defined class constructor. Inspects the function’s string to determine if it's a class constructor.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fn |
* | The function to test. |
Returns:
`true` if the given function is a user defined class constructor.
- Type
- boolean