@js-types-runtime/string
v2.0.1
Published
Lightweight string type checker
Maintainers
Readme
@js-types-runtime/string
Lightweight string type checker. Zero dependencies.
Installation
npm install @js-types-runtime/stringUsage
import { string } from '@js-types-runtime/string';
string('hello'); // true
string(''); // true
string(42); // false
string(null); // falseAPI
string(value)
Checks if a value is a string.
- value:
unknown - returns:
boolean
TypeScript
This package includes type definitions with a type predicate:
const string: (v: unknown) => v is string;So you get type narrowing:
const x: unknown = 'hello';
if (string(x)) {
x.toUpperCase(); // ✅ x is string
}License
MIT
