diff options
Diffstat (limited to 'packages/webapi/src/lib/String.ts')
-rw-r--r-- | packages/webapi/src/lib/String.ts | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/packages/webapi/src/lib/String.ts b/packages/webapi/src/lib/String.ts index 49df3261c..92d39f39a 100644 --- a/packages/webapi/src/lib/String.ts +++ b/packages/webapi/src/lib/String.ts @@ -1,11 +1,18 @@ import * as _ from './utils' export const replaceAll = { - replaceAll(this: string, searchValue: RegExp | string, replaceValue: string | ((substring: string, ...args: any[]) => string)) { + replaceAll( + this: string, + searchValue: RegExp | string, + replaceValue: string | ((substring: string, ...args: any[]) => string) + ) { return _.__object_isPrototypeOf(RegExp.prototype, searchValue) ? this.replace(searchValue as RegExp, replaceValue as string) - : this.replace(new RegExp(_.__string_escapeRegExp(searchValue as string), 'g'), replaceValue as string) - } + : this.replace( + new RegExp(_.__string_escapeRegExp(searchValue as string), 'g'), + replaceValue as string + ) + }, }.replaceAll export const initString = (target: any, exclude: Set<string>) => { @@ -13,10 +20,11 @@ export const initString = (target: any, exclude: Set<string>) => { const Class = target.String || globalThis.String - if (!Class.prototype.replaceAll) Object.defineProperty(Class.prototype, 'replaceAll', { - value: replaceAll, - writable: true, - enumerable: false, - configurable: true - }) + if (!Class.prototype.replaceAll) + Object.defineProperty(Class.prototype, 'replaceAll', { + value: replaceAll, + writable: true, + enumerable: false, + configurable: true, + }) } |