import { ChromeBookmark } from "./../types/ChromeBookmark" ; type ChromeBookmarksById = { [ id ] : ChromeBookmark ; } ; const withoutChildren = ( bookmark ) => ( { index : bookmark . index , title : bookmark . title , url : bookmark . url , dateGroupModified : bookmark . dateGroupModified , id : bookmark . id , parentId : bookmark . parentId , unmodifiable : bookmark . unmodifiable } ) ; export const parseChromeBookmarks = ( chromeBookmarks ) => { const foldersById = { } ; const bookmarksById = { } ; const parseBookmarkNodes = ( nodes ) => { nodes . forEach ( node => { if ( node . children ) { foldersById [ node . id ] = withoutChildren ( node ) ; parseBookmarkNodes ( node . children ) ; } else { bookmarksById [ node . id ] = node ; } } ) ; } ; parseBookmarkNodes ( chromeBookmarks ) ; return { foldersById , bookmarksById } ; } ;