File tree Expand file tree Collapse file tree 3 files changed +26
-24
lines changed
web-app/src/services/state Expand file tree Collapse file tree 3 files changed +26
-24
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import * as React from 'react'
22import * as T from 'typings'
33import { createMachine } from './machine'
44import { useMachine } from '../xstate-react'
5+ import createRouteString from './utils/routeString'
56import logger from '../logger'
67
78interface Output {
@@ -12,29 +13,6 @@ interface Output {
1213
1314declare let acquireVsCodeApi : any
1415
15- export const createRouteString = ( route : object | string ) : string => {
16- if ( typeof route === 'string' ) {
17- return route
18- }
19- const paths : string [ ] = [ ]
20- let current : object | string | undefined = route
21- while ( current ) {
22- // current is final string value
23- if ( typeof current === 'string' ) {
24- paths . push ( current )
25- break
26- }
27-
28- // current is object
29- const next : string = Object . keys ( current ) [ 0 ]
30- paths . push ( next )
31- // @ts -ignore
32- current = current [ next ]
33- }
34-
35- return paths . join ( '.' )
36- }
37-
3816const editor = acquireVsCodeApi ( )
3917const editorSend = ( action : T . Action ) => {
4018 logger ( `TO EXT: "${ action . type } "` )
Original file line number Diff line number Diff line change 1- import { createRouteString } from './useStateMachine '
1+ import createRouteString from './routeString '
22
33describe ( 'route string' , ( ) => {
44 it ( 'should take a single key route' , ( ) => {
Original file line number Diff line number Diff line change 1+ const createRouteString = ( route : object | string ) : string => {
2+ if ( typeof route === 'string' ) {
3+ return route
4+ }
5+ const paths : string [ ] = [ ]
6+ let current : object | string | undefined = route
7+ while ( current ) {
8+ // current is final string value
9+ if ( typeof current === 'string' ) {
10+ paths . push ( current )
11+ break
12+ }
13+
14+ // current is object
15+ const next : string = Object . keys ( current ) [ 0 ]
16+ paths . push ( next )
17+ // @ts -ignore
18+ current = current [ next ]
19+ }
20+
21+ return paths . join ( '.' )
22+ }
23+
24+ export default createRouteString
You can’t perform that action at this time.
0 commit comments