ensureLeft

Ensures that the value begins with substr. If it doesn't, it's prepended.

Install

Install all functions of strman

yarn add strman

or just the ensureLeft function

yarn add strman.ensureleft

Usage

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 value already starts with substr

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'