Registry / type-stubs / string-utility-types

string-utility-types

JSON →
library2.1.0jsnpmunverified

A TypeScript utility library providing advanced string type manipulations via template literal types. Version 2.1.0 offers types like Split, Join, ReplaceAt, and path matching utilities (MatchesPathPattern, MatchesPathPatternLax) for compile-time string processing. Released under MIT, it is actively maintained with a focus on type safety for routing and string operations. Unlike similar libraries, it provides conservative path pattern matching to avoid false negatives, with explicit documentation of limitations. Recommended for TypeScript projects needing robust string type inference.

npm install string-utility-types
INSTALL
IMPORT
SIG · STRING-UTILITY-TYP
S
string-utility-types
type-stubsjavascriptv2.1.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Split
✓ import { Split } from 'string-utility-types'
✗ import Split from 'string-utility-types'
Use named import; no default export.
Join
✓ import { Join } from 'string-utility-types'
✗ import Join from 'string-utility-types'
Use named import; no default export.
MatchesPathPattern
✓ import { MatchesPathPattern } from 'string-utility-types'
Conservative path matcher; returns true for some non-exact matches.

Demonstrates basic usage of Split, Join, and path matching types from string-utility-types.

import { Split, Join, MatchesPathPattern, MatchesPathPatternLax } from 'string-utility-types'; // Example usage type Path = 'home/user/docs'; type Parts = Split<Path, '/'>; // ['home', 'user', 'docs'] type Rejoined = Join<Parts, '-'>; // 'home-user-docs' type IsMatch = MatchesPathPattern<'/users/123', '/users/:id'>; // true type IsMatchLax = MatchesPathPatternLax<'/users/123', '/users/:id'>; // true // Note: MatchesPathPattern may return true for interpolated strings // e.g., MatchesPathPattern<"/users/${string}", '/users/:id'> is true // Use MatchesPathPatternLax if you know interpolations have no slashes.
Debug
Known issues
gotchaMatchesPathPattern is conservative and may return true for paths that technically could match due to string interpolation (e.g., `${string}` could be `/123/author`).
fix
Use MatchesPathPatternLax if you can guarantee no slashes in interpolations.
affects: >=2.0.0
gotchaMatchesPathPattern only works up to 6 path segments. Beyond that, behavior is undefined.
fix
Break down path patterns or use a different type for longer paths.
affects: >=2.0.0
breakingVersion 2.0.0 removed deprecated types from v1 (e.g., older Split/Join implementations) – updates may break code relying on old signatures.
fix
Update named imports to current API; see migration guide.
affects: 2.0.0
Errors
Common errors & fixes
Type 'Split<...>' does not satisfy the constraint 'string[]'.
Using Split on a non-string type or with invalid delimiter.
fix
Ensure S and Delimiter are string literals, e.g., Split<'a/b', '/'>
Type instantiation is excessively deep and possibly infinite.
Recursive type evaluation on very long strings or deep arrays.
fix
Limit string length or use simpler types; avoid nesting.
Cannot find name 'Split'. Did you mean 'split'?
Using default import instead of named import.
fix
Use 'import { Split } from 'string-utility-types'.
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
30 hits · last 30 days
node
24
OpenAI (training)
2
Amazon
1
Resources
string-utility-types — npm install string-utility-types · libregistry