function isString
isString(s: unknown): s is string

Type guard to check if a value is a string.

Handles both string primitives and String objects.

Examples

Type narrowing

import { isString } from "jsr:@j50n/proc";

const value: unknown = "hello";
if (isString(value)) {
  // TypeScript knows value is string here
  console.log(value.toUpperCase());
}

Parameters

s: unknown

The value to check.

Return Type

s is string

True if the value is a string.

Usage

import { isString } from ".";