mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-17 00:41:32 +00:00
Add String#replace & String#replaceAll (#653)
This commit is contained in:
1
std/portable/index.d.ts
vendored
1
std/portable/index.d.ts
vendored
@ -461,6 +461,7 @@ declare class String {
|
||||
padStart(targetLength: i32, padString?: string): string;
|
||||
padEnd(targetLength: i32, padString?: string): string;
|
||||
replace(search: string, replacement: string): string;
|
||||
replaceAll(search: string, replacement: string): string;
|
||||
repeat(count?: i32): string;
|
||||
slice(beginIndex: i32, endIndex?: i32): string;
|
||||
split(separator?: string, limit?: i32): string[];
|
||||
|
@ -196,6 +196,16 @@ String["fromCodePoints"] = function fromCodePoints(arr) {
|
||||
return String.fromCodePoint.apply(String, arr);
|
||||
};
|
||||
|
||||
if (!String.prototype.replaceAll) {
|
||||
Object.defineProperty(String.prototype, "replaceAll", {
|
||||
value: function replaceAll(search, replacment) {
|
||||
var res = this.split(search).join(replacment);
|
||||
if (!search.length) res = replacment + res + replacment;
|
||||
return res;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
globalScope["isInteger"] = Number.isInteger;
|
||||
|
||||
globalScope["isFloat"] = function isFloat(arg) {
|
||||
|
Reference in New Issue
Block a user