ensureLeft
Ensures a string starts with a given prefix.
ensureLeft
Signature
typescript
function ensureLeft(str: string, prefix: string): stringParameters
str- The string to checkprefix- The prefix to ensure
Returns
String with prefix guaranteed.
Examples
typescript
import { ensureLeft } from 'strio'
ensureLeft('world', 'hello ')
// "hello world"
ensureLeft('hello world', 'hello ')
// "hello world"
ensureLeft('/path', '/')
// "/path"Related Functions
- ensureRight - Ensure suffix
- stripPrefix - Remove prefix