mirror of https://github.com/sveltejs/svelte
parent
4d4f959f16
commit
5815b2b558
@ -1,3 +1,5 @@
|
||||
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)$/;
|
||||
|
||||
@ -1,15 +1,9 @@
|
||||
import { whitespace } from './patterns';
|
||||
import { startWhitespace, endWhitespace } from './patterns';
|
||||
|
||||
export function trim_start(str: string) {
|
||||
let i = 0;
|
||||
while (whitespace.test(str[i])) i += 1;
|
||||
|
||||
return str.slice(i);
|
||||
return str.replace(startWhitespace, '');
|
||||
}
|
||||
|
||||
export function trim_end(str: string) {
|
||||
let i = str.length;
|
||||
while (whitespace.test(str[i - 1])) i -= 1;
|
||||
|
||||
return str.slice(0, i);
|
||||
return str.replace(endWhitespace, '');
|
||||
}
|
||||
|
||||
Loading…
Reference in new issue