1.0.0 • Published 1 year ago

@aaronburt/typeguard-js v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Input Type Checker

This module provides a set of functions to determine the type of the given input. The following functions are available:

isNumber(): returns true if the input is a number, false otherwise.
isString(): returns true if the input is a string, false otherwise.
isBoolean(): returns true if the input is a boolean, false otherwise.
isNull(): returns true if the input is null, false otherwise.
isUndefined(): returns true if the input is undefined, false otherwise.
isSymbol(): returns true if the input is a symbol, false otherwise.
isJSONObject(): returns true if the input is a valid JSON object, false otherwise.

Usage

To use this module, import it and call the desired function with the input as a parameter.

import inputTypeChecker from './inputTypeChecker.js';

const input = 'hello world';
const checker = inputTypeChecker(input);

console.log(checker.isString()); // true
console.log(checker.isNumber()); // false
console.log(checker.isBoolean()); // false
console.log(checker.isNull()); // false
console.log(checker.isUndefined()); // false
console.log(checker.isSymbol()); // false
console.log(checker.isJSONObject()); // false

Install

You need to install typescript and run tsc to generate the ./dist/ folder

License

This project is licensed under the MIT License - see the LICENSE.md file for details.