summaryrefslogtreecommitdiff
path: root/src/compiler/utils/trim.ts
blob: 1c7388c2cb74196323b59d52d5cedbe35260c46b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { whitespace } from './patterns.js';

export function trim_start(str: string) {
	let i = 0;
	while (whitespace.test(str[i])) i += 1;

	return str.slice(i);
}

export function trim_end(str: string) {
	let i = str.length;
	while (whitespace.test(str[i - 1])) i -= 1;

	return str.slice(0, i);
}