@fvilers/is-string
v2.0.0
Published
A TypeScript type guard that validates if the given value is a string
Downloads
6
Maintainers
Readme
@fvilers/is-string
A TypeScript type guard that validates if the given value is a string
Installation
npm install @fvilers/is-string
or
yarn add @fvilers/is-string
ECMAScript module
Starting with version 2.0.0, this library will be published as an ECMAScript module.
Usage
import { isString } from "@fvilers/is-string";
const variable: any = "This is a string";
if (isString(variable)) {
// From here, variable is strongly typed as a string
console.log("Variable is a string with length of", variable.length);
} else {
console.log("Variable is not a string");
}
It will output:
Variable is a string with length of 16