File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export default (userConfiguration = {}) => {
15
15
errorWhenNotFound : true
16
16
} ;
17
17
18
- Object . keys ( userConfiguration ) . forEach ( name => {
18
+ for ( const name in userConfiguration ) {
19
19
const value = userConfiguration [ name ] ;
20
20
21
21
if ( ! ( name in configuration ) ) {
@@ -27,7 +27,7 @@ export default (userConfiguration = {}) => {
27
27
}
28
28
29
29
configuration [ name ] = value ;
30
- } ) ;
30
+ }
31
31
32
32
return configuration ;
33
33
} ;
Original file line number Diff line number Diff line change 1
1
const styleNameIndex = { } ;
2
+ import { trim , filterForTruthy } from './utils' ;
2
3
3
4
export default ( styleNamePropertyValue : string , allowMultiple : boolean ) : Array < string > => {
4
5
let styleNames ;
5
6
6
7
if ( styleNameIndex [ styleNamePropertyValue ] ) {
7
8
styleNames = styleNameIndex [ styleNamePropertyValue ] ;
8
9
} else {
9
- styleNames = styleNamePropertyValue . trim ( ) . split ( ' ' ) . filter ( e => ! ! e ) ;
10
+ styleNames = filterForTruthy ( trim ( styleNamePropertyValue ) . split ( ' ' ) ) ;
10
11
11
12
styleNameIndex [ styleNamePropertyValue ] = styleNames ;
12
13
}
Original file line number Diff line number Diff line change @@ -11,4 +11,19 @@ export function isFunction(func) {
11
11
12
12
export function isArray ( arr ) {
13
13
return Array . isArray ? Array . isArray ( arr ) : Object . prototype . toString . call ( arr ) === '[object Array]' ;
14
- }
14
+ }
15
+
16
+ export function trim ( str ) {
17
+ return String . prototype . trim ? str . trim ( ) : str . replace ( / ^ [ \s \uFEFF \xA0 ] + | [ \s \uFEFF \xA0 ] + $ / g, '' ) ;
18
+ }
19
+
20
+ export function filterForTruthy ( arr ) {
21
+ const results = [ ] ;
22
+ for ( const key in arr ) {
23
+ if ( arr [ key ] ) {
24
+ results . push ( arr [ key ] ) ;
25
+ }
26
+ }
27
+
28
+ return results ;
29
+ }
You can’t perform that action at this time.
0 commit comments