mirror of https://github.com/sveltejs/svelte
parent
4d4f959f16
commit
5815b2b558
@ -1,3 +1,5 @@
|
|||||||
export const whitespace = /[ \t\r\n]/;
|
export const whitespace = /[ \t\r\n]/;
|
||||||
|
export const startWhitespace = /^[ \t\r\n]*/;
|
||||||
|
export const endWhitespace = /[ \t\r\n]*$/;
|
||||||
|
|
||||||
export const dimensions = /^(?:offset|client)(?:Width|Height)$/;
|
export const dimensions = /^(?:offset|client)(?:Width|Height)$/;
|
||||||
|
|||||||
@ -1,15 +1,9 @@
|
|||||||
import { whitespace } from './patterns';
|
import { startWhitespace, endWhitespace } from './patterns';
|
||||||
|
|
||||||
export function trim_start(str: string) {
|
export function trim_start(str: string) {
|
||||||
let i = 0;
|
return str.replace(startWhitespace, '');
|
||||||
while (whitespace.test(str[i])) i += 1;
|
|
||||||
|
|
||||||
return str.slice(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function trim_end(str: string) {
|
export function trim_end(str: string) {
|
||||||
let i = str.length;
|
return str.replace(endWhitespace, '');
|
||||||
while (whitespace.test(str[i - 1])) i -= 1;
|
|
||||||
|
|
||||||
return str.slice(0, i);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in new issue