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-typeofor use yarn:
yarn add custom-typeofUsage
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:
checkisArrayisNotArrayisObjectisNotObjectisBooleanisNotBooleanisStringisNotStringisNumberisNotNumberisStringNumberisNotStringNumberisFunctionisNotFunctionisUndefinedisNotUndefinedisNullisNotNullisTruthyisFalsy
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; // trueisString
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.
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago