From 97618104bdfb8d714f53e73c24704c48905fd785 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 18 Aug 2015 14:58:35 -0700 Subject: [PATCH] Added the '[Symbol.replace]' method to the 'RegExp' interface. --- src/lib/core.d.ts | 8 ++++---- src/lib/es6.d.ts | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index 442921ca5a4..bffdac3a3e2 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -324,9 +324,9 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A String object or string literal that represents the regular expression - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; /** * Replaces text in a string, using a regular expression or search string. @@ -338,9 +338,9 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replaceValue A function that returns the replacement text. + * @param replacer A function that returns the replacement text. */ - replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index 767060f9848..aceac270f88 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -685,6 +685,23 @@ interface RegExp { */ [Symbol.match](str: string): RegExpMatchArray; + /** + * Replaces text in a string, using a regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replaceValue A String object or string literal containing the text to replace for every + * successful match of this regular expression. + */ + [Symbol.replace](string: string, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression. + * @param string A String object or string literal whose contents matching against + * this regular expression will be replaced + * @param replacer A function that returns the replacement text. + */ + [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; + /** * Returns a string indicating the flags of the regular expression in question. This field is read-only. * The characters in this string are sequenced and concatenated in the following order: