ensureRight

Ensures that the [value] ends with [substr]. If it doesn't, it's appended.

Install

Install all functions of strman

yarn add strman

or just the ensureRight function

yarn add strman.ensureright

Usage

import { ensureRight } from 'strman'
// OR
import ensureRight from 'strman.ensureright'
Parameters:
Name Type Attributes Default Description
value String

The input string

substr String

The substr to be ensured to be right

caseSensitive Boolean <optional>
true

Use case (in-)sensitive matching for determining if value already ends with substr

Source:
Returns:

The string which is guarenteed to start with substr

Type
String
Example
const value = 'Daniel'
const substr = ' Leite'
ensureRight(value, substr)
// => 'Daniel Leite'