Skip to content

Commit

Permalink
feat: add ensureSuffix (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaubree authored Jan 24, 2022
1 parent 988fb2b commit ee2c845
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ export function ensurePrefix(prefix: string, str: string) {
return str
}

/**
* Ensure suffix of a string
*
* @category String
*/
export function ensureSuffix(suffix: string, str: string) {
if (!str.endsWith(suffix))
return str + suffix
return str
}

/**
* Dead simple template engine, just like Python's `.format()`
*
Expand Down

0 comments on commit ee2c845

Please sign in to comment.