File tree Expand file tree Collapse file tree 2 files changed +3
-15
lines changed Expand file tree Collapse file tree 2 files changed +3
-15
lines changed Original file line number Diff line number Diff line change @@ -39,22 +39,15 @@ class AsyncGroup {
39
39
}
40
40
}
41
41
42
- function castSegment ( segment : string ) : string | number {
42
+ function castSegment ( segment : string | number ) : string | number {
43
43
return ( typeof segment === 'string' && isArrayIndex ( segment ) )
44
44
? + segment // sneaky op to convert numeric string to number
45
45
: segment ;
46
46
}
47
47
48
- export function castSegments ( segments : Readonly < string | string [ ] > ) {
49
- if ( typeof segments === 'string' ) {
50
- return castSegment ( segments ) ;
51
- }
48
+ export function castSegments ( segments : Readonly < Array < string | number > > ) {
52
49
// Cast number path segments from strings to numbers
53
- return segments . map ( segment =>
54
- Array . isArray ( segment )
55
- ? castSegments ( segment )
56
- : castSegment ( segment )
57
- ) ;
50
+ return segments . map ( segment => castSegment ( segment ) ) ;
58
51
}
59
52
60
53
export function contains ( segments , testSegments ) {
Original file line number Diff line number Diff line change @@ -89,10 +89,5 @@ describe('util', function() {
89
89
expect ( actual ) . to . eql ( [ 'foo' , 3 , 3 ] ) ;
90
90
expect ( actual ) . to . not . equal ( segments ) ; // args not mutated
91
91
} ) ;
92
-
93
- it ( 'handles plain strings' , ( ) => {
94
- expect ( util . castSegments ( 'foo.bar' ) ) . to . eql ( 'foo.bar' ) ;
95
- expect ( util . castSegments ( '6' ) ) . to . eql ( 6 ) ;
96
- } ) ;
97
92
} ) ;
98
93
} ) ;
You can’t perform that action at this time.
0 commit comments