diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-07-03 14:10:06 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-07-03 14:10:06 +0200 |
commit | dab9bee4b46aaa1241cdb6b565ddbe0f19137c5e (patch) | |
tree | 7a5b22717797a08c8165bc2346f1204d90f74f31 /util/string.ts | |
parent | 14c31de2f166d9e6d874984cdee5a2876c1ddec5 (diff) |
add utility wrap method
Diffstat (limited to 'util/string.ts')
-rw-r--r-- | util/string.ts | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/util/string.ts b/util/string.ts index bb6bc0f..b362f06 100644 --- a/util/string.ts +++ b/util/string.ts @@ -1,4 +1,5 @@ import { TokenTags, parseTags } from "../language/tags.ts"; +import { Wrapper } from "./wrap.ts"; declare global { interface String { @@ -49,6 +50,9 @@ declare global { /** @summary replace last instance of `searchString` with `replaceValue` */ replaceLast(searchString: string, replaceValue: string): string; + + /** @summary wrap string using Wrapper */ + wrap(wrapper: Wrapper): string; } } @@ -150,3 +154,7 @@ String.prototype.replaceLast = function(find, replace) { return this.substring(0, i) + replace + this.substring(i + find.length); } +String.prototype.wrap = function(wrapper) { + return wrapper[0] + this + wrapper[1]; +} + |