You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/src/utils/trim.ts

16 lines
315 B

import { whitespace } from './patterns';
export function trimStart ( str: string ) {
let i = 0;
while ( whitespace.test( str[i] ) ) i += 1;
return str.slice( i );
}
export function trimEnd ( str: string ) {
let i = str.length;
while ( whitespace.test( str[ i - 1 ] ) ) i -= 1;
return str.slice( 0, i );
}