Ensures that the [value] ends with [substr]. If it doesn't, it's appended.
Install
Install all functions of strman
yarn add strmanor just the ensureRight function
yarn add strman.ensurerightUsage
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 |
- 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'