Ensures that the value begins with substr. If it doesn't, it's prepended.
Install
Install all functions of strman
yarn add strmanor just the ensureLeft function
yarn add strman.ensureleftUsage
import { ensureLeft } from 'strman'
// OR
import ensureLeft from 'strman.ensureleft'Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
value |
String | The input string |
||
substr |
String | The substr to be ensured to be left |
||
caseSensitive |
Boolean |
<optional> |
true | Use case (in-)sensitive matching for determining if |
- Source:
Returns:
The string which is guarenteed to start with substr
- Type
- String
Example
const value = 'Leite'
const substr = 'Daniel '
ensureLeft(value, substr)
// => 'Daniel Leite'