Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions std/assembly/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,8 @@ declare class String {
trim(): string;
trimLeft(): string;
trimRight(): string;
trimStart(): string;
trimEnd(): string;
padStart(targetLength: i32, padString?: string): string;
padEnd(targetLength: i32, padString?: string): string;
repeat(count?: i32): string;
Expand Down
12 changes: 11 additions & 1 deletion std/assembly/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,17 @@ export class String {
return out;
}

@inline
trimLeft(): String {
return this.trimStart();
}

@inline
trimRight(): String {
return this.trimEnd();
}

trimStart(): String {
assert(this !== null);
var start: isize = 0;
var len: isize = this.length;
Expand All @@ -323,7 +333,7 @@ export class String {
return out;
}

trimRight(): String {
trimEnd(): String {
assert(this !== null);
var len: isize = this.length;
while (
Expand Down
2 changes: 2 additions & 0 deletions std/portable/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ declare class String {
trim(): string;
trimLeft(): string;
trimRight(): string;
trimStart(): string;
trimEnd(): string;
padStart(targetLength: i32, padString?: string): string;
padEnd(targetLength: i32, padString?: string): string;
replace(search: string, replacement: string): string;
Expand Down
10 changes: 5 additions & 5 deletions tests/compiler/std/string.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 80)
(i32.const 345)
(i32.const 355)
(i32.const 4)
)
(unreachable)
Expand Down Expand Up @@ -2876,7 +2876,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 80)
(i32.const 365)
(i32.const 375)
(i32.const 4)
)
(unreachable)
Expand Down Expand Up @@ -3675,7 +3675,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 80)
(i32.const 513)
(i32.const 523)
(i32.const 10)
)
(unreachable)
Expand Down Expand Up @@ -4153,7 +4153,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 80)
(i32.const 385)
(i32.const 395)
(i32.const 4)
)
(unreachable)
Expand Down Expand Up @@ -4189,7 +4189,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 80)
(i32.const 390)
(i32.const 400)
(i32.const 6)
)
(unreachable)
Expand Down
10 changes: 5 additions & 5 deletions tests/compiler/std/string.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -3451,7 +3451,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 80)
(i32.const 345)
(i32.const 355)
(i32.const 4)
)
(unreachable)
Expand Down Expand Up @@ -3601,7 +3601,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 80)
(i32.const 365)
(i32.const 375)
(i32.const 4)
)
(unreachable)
Expand Down Expand Up @@ -4465,7 +4465,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 80)
(i32.const 513)
(i32.const 523)
(i32.const 10)
)
(unreachable)
Expand Down Expand Up @@ -5012,7 +5012,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 80)
(i32.const 385)
(i32.const 395)
(i32.const 4)
)
(unreachable)
Expand Down Expand Up @@ -5047,7 +5047,7 @@
(call $~lib/env/abort
(i32.const 0)
(i32.const 80)
(i32.const 390)
(i32.const 400)
(i32.const 6)
)
(unreachable)
Expand Down
4 changes: 2 additions & 2 deletions tests/parser/string-binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export class ExternalString {
trim(): String { return unreachable(); }

@binding(BindingCall.THIS, [], BindingType.OBJECT_HANDLE)
trimLeft(): String { return unreachable(); }
trimStart(): String { return unreachable(); }

@binding(BindingCall.THIS, [], BindingType.OBJECT_HANDLE)
trimRight(): String { return unreachable(); }
trimEnd(): String { return unreachable(); }

@binding(BindingCall.THIS, [ BindingType.OBJECT_HANDLE ], BindingType.PASS_THRU)
@operator("==")
Expand Down
4 changes: 2 additions & 2 deletions tests/parser/string-binding.ts.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ export class ExternalString {
return unreachable();
}
@binding(BindingCall.THIS, [], BindingType.OBJECT_HANDLE)
trimLeft(): String {
trimStart(): String {
return unreachable();
}
@binding(BindingCall.THIS, [], BindingType.OBJECT_HANDLE)
trimRight(): String {
trimEnd(): String {
return unreachable();
}
@binding(BindingCall.THIS, [BindingType.OBJECT_HANDLE], BindingType.PASS_THRU)
Expand Down