custom-typeof v3.0.4
CustomTypeof
Check your types more easily! CustomTypeof
is a JavaScript utility class that provides additional type checking capabilities beyond the built-in typeof operator. CustomTypeof
offer you two way to check your values types.
One is using check
method for check a single value type in more readable way, Rest of them can check n values
Installation
You can install the CustomTypeof
class via npm:
npm install custom-typeof
or use yarn:
yarn add custom-typeof
Usage
To use the CustomTypeof
class, you first need to import it:
const CustomTypeof = require("custom-typeof");
Then, you can create an instance of the class:
const customTypeof = new CustomTypeof();
The CustomTypeof
class provides the following methods:
check
isArray
isNotArray
isObject
isNotObject
isBoolean
isNotBoolean
isString
isNotString
isNumber
isNotNumber
isStringNumber
isNotStringNumber
isFunction
isNotFunction
isUndefined
isNotUndefined
isNull
isNotNull
isTruthy
isFalsy
Except for the check
method, the others can receive multiple values as parameters
Examples
check
const { check } = customTypeof;
check({}).type.isObject; // true
check([]).type.isObject; // false
check([]).type.isNotObject; // true
isString
Checks if a value is an string.
customTypeof.isString(...values);
Parameters:
values
- The values to check.
Returns:
true
if the value is an string, false
otherwise.
isNotString
Checks if a value is not an string.
customTypeof.isNotString(...values);
Parameters:
values
- The values to check.
Returns:
true
if the value is not an string, false
otherwise.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago