Utility submodule containing type checker and helper.
- Since:
- 1.2.0
- License:
- MIT
- Source:
Methods
(package, inner) dropNullAndUndefined(obj) → {Object}
Drops null and undefined values from the input object.
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Object | The input object to filter null and undefined values from. |
- Since:
- 1.0.0
- Source:
Returns:
The filtered object without null and undefined values.
- Type
- Object
(package, inner) getType(x, nameOnlyopt) → {string}
Returns the type of the provided value as a string.
For null values, it returns 'null', and for objects or class instances, Date object for example,
it returns a more detailed type such as '[object Date]'. If the nameOnly set to true,
the returned string will be the name of the object itself, 'Date'.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
x |
any | The value whose type is to be determined. |
||
nameOnly |
boolean |
<optional> |
false | Whether to get the name of the given object or instance of class,
instead the detailed information. This option only works for symbols
that returns |
- Since:
- 1.1.0
- Source:
Returns:
A string representing the type of the value.
- Type
- string
(package, inner) isCallable(x) → {boolean}
Deterimines whether the provided value is a callable (e.g., a function).
Native classes and ES6 classes will give a true value, because they were callable.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
any | The value to be checked. |
- Since:
- 2.0.0
- Source:
Returns:
true if the given value is a callable, otherwise false.
- Type
- boolean
(package, inner) isClass(x) → {boolean}
Determines whether the provided value is a ES6 class.
| Symbol | Value |
|---|---|
class {} |
true |
class A extends B {} |
true |
function () {} |
false |
function () {}.bind() |
false |
() => {} |
false |
{} |
false |
URL |
true |
Parameters:
| Name | Type | Description |
|---|---|---|
x |
any | The value to be checked. |
- Since:
- 2.0.0
- Source:
Returns:
true if the value is a ES6 class, otherwise false.
- Type
- boolean
(package, inner) isNullOrUndefined(x) → {boolean}
Checks if a given value is null or undefined.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
any | The value to check. |
- Since:
- 1.0.0
- Source:
Returns:
true if the value is null or undefined, otherwise false.
- Type
- boolean
(package, inner) isObject(x) → {boolean}
Determines whether the provided value is a non-null object.
This function returns true for any value that is of the object type and is not null,
but it does not guarantee that the object is a plain object ({}).
Parameters:
| Name | Type | Description |
|---|---|---|
x |
any | The value to be checked. |
- Since:
- 1.0.0
- Source:
- See:
-
isPlainObject
Returns:
true if the value is a non-null object, otherwise false.
- Type
- boolean
(package, inner) isPlainObject(x) → {boolean}
Determines whether the provided value is a plain object ({}).
This function returns true only if the value is a non-null object with
a prototype of Object.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
any | The value to be checked. |
- Since:
- 1.1.0
- Source:
- See:
-
isObject
Returns:
true if the value is a plain object, otherwise false.
- Type
- boolean