mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-24 03:32:58 +03:00
b11fd69e17
* feat(isString): Add isString function * test(isString): Add isString tests * docs(isString): Add and improve docs for isString * Update src/compat/predicate/isString.spec.ts * Update src/compat/predicate/isString.spec.ts * Update src/predicate/index.ts --------- Co-authored-by: Sojin Park <raon0211@gmail.com>
619 B
619 B
isString
Checks if the given value is a string.
This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to string
.
Signature
function isString(value: unknown): value is string;
Parameters
value
(unknown
): The value to test if it is string.
Returns
- (
x is string
): True if the value is a string, otherwise false.
Examples
const value1 = 'abc';
const value2 = 123;
const value3 = true;
console.log(isString(value1)); // true
console.log(isString(value2)); // false
console.log(isString(value3)); // false