File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change 1
1
export const whitespace = / [ \t \r \n ] / ;
2
+ export const startWhitespace = / ^ [ \t \r \n ] * / ;
3
+ export const endWhitespace = / [ \t \r \n ] * $ / ;
2
4
3
5
export const dimensions = / ^ (?: o f f s e t | c l i e n t ) (?: W i d t h | H e i g h t ) $ / ;
Original file line number Diff line number Diff line change 1
- import { whitespace } from './patterns' ;
1
+ import { startWhitespace , endWhitespace } from './patterns' ;
2
2
3
3
export function trim_start ( str : string ) {
4
- let i = 0 ;
5
- while ( whitespace . test ( str [ i ] ) ) i += 1 ;
6
-
7
- return str . slice ( i ) ;
4
+ return str . replace ( startWhitespace , '' ) ;
8
5
}
9
6
10
7
export function trim_end ( str : string ) {
11
- let i = str . length ;
12
- while ( whitespace . test ( str [ i - 1 ] ) ) i -= 1 ;
13
-
14
- return str . slice ( 0 , i ) ;
8
+ return str . replace ( endWhitespace , '' ) ;
15
9
}
You can’t perform that action at this time.
0 commit comments