blob: 480cc99a8d81a3a80a1f073d65316cf0272aa634 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import { whitespace } from './patterns.js';
/** Trim whitespace from start of string */
export function trim_start(str: string) {
let i = 0;
while (whitespace.test(str[i])) i += 1;
return str.slice(i);
}
/** Trim whitespace from end of string */
export function trim_end(str: string) {
let i = str.length;
while (whitespace.test(str[i - 1])) i -= 1;
return str.slice(0, i);
}
|