Skip to content

words

Import from @varavel/vdl-plugin-sdk/utils/strings.

function words(str): string[];

Splits a string into normalized word tokens.

The function preserves the current tokenization rules used by the SDK: it inserts spaces at camelCase and acronym-to-word boundaries, converts any non-alphanumeric separator to a space, trims the result, and then splits on whitespace.

This makes it suitable for inputs such as camelCase, PascalCase, HTTPServer, snake_case, kebab-case, and mixed separator variants.

Empty or separator-only inputs return an empty array.

Parameters

Parameter Type Description
str string String to tokenize.

Returns

string[]

An array of normalized word tokens.

Example

words("HTTPServer_error-code");
// returns ["HTTP", "Server", "error", "code"]