164
*/
165
export function rtrim(haystack: string, needle: string): string {
167
return haystack;
168
}
170
>
const needleLen = needle.length,
171
>
haystackLen = haystack.length;
172
>
173
>
if (needleLen === 1) {
174
>
let end = haystackLen;
175
>
const ch = needle.charCodeAt(0);
176
>
while (end > 0 && haystack.charCodeAt(end - 1) === ch) {
177
end--;
178
}
179
>
return haystack.substring(0, end);
strings.ts
180
>
}
181
182
let offset = haystackLen;
183
>
while (offset > 0 && haystack.endsWith(needle, offset)) {
strings.ts
184
offset -= needleLen;
185
}