Skip to content

Instantly share code, notes, and snippets.

@jsdbroughton
Created February 16, 2020 21:04
Show Gist options
  • Save jsdbroughton/b5fa6ab5fe9dc9af18edcaf4457c0be8 to your computer and use it in GitHub Desktop.
Save jsdbroughton/b5fa6ab5fe9dc9af18edcaf4457c0be8 to your computer and use it in GitHub Desktop.
const parentItems:TreeItem[] = [];
parentKeys.forEach( ( v:string ):void=>{
let parts = v.split( `-` );
while ( uniqueIds.has( lastId ) ) {
lastId += 1;
}
uniqueIds.add( lastId );
let name = parts.pop() || ``;
parentItems.push( {
id: lastId,
key: v,
name,
parentKey: parts.join( `-` )
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment