https://medium.com/@jsdbroughton/not-as-recursive-as-id-hoped-2f0fc2a30cc7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
namespace CASE.Navis2BCF | |
{ | |
/// <summary> | |
/// Conversion methods between an IFC | |
/// encoded GUID string and a .NET GUID. | |
/// This is a translation of the C code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Function to convert a given Google Spreadsheet [Sheet] into a PDF. | |
* | |
* @param {string} key This is the Id of the Sheet to be converted bothe the DocsList.getId() and the SpreadsheetApp.getId() versions work | |
* @param {string} name [Optional] Intended Filename. If omitted, uses the Sheet filename. | |
* @param {object} options Settings object for the crafting of the PDF. Defaults to A4, no gridline print etc. <pre> | |
* { | |
* format:Enum, | |
* size:Enum, | |
* headers: Bool, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
ActionContext, | |
ActionTree, | |
GetterTree, | |
MutationTree, | |
Module, | |
Store as VuexStore, | |
CommitOptions, | |
DispatchOptions, | |
} from 'vuex' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tree is what is returned post shenanigans. | |
let tree:TreeItem[] = []; | |
// keyMap keeps track of the indexes where parentKeys are found in the keyed but flat array. | |
const keyMap:Map<string, number> = new Map(); | |
treeItemsWithBranches.forEach( ( node ):void => { | |
// nodes with no parents are at root level. | |
// this is not a binary tree, there can be several root level nodes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const keyedItems = treeItems.map( ( item ): TreeItem => { | |
const fieldValues = fieldNames.map( ( field ): string => item.data && item.data[field] ); | |
let parentKey = fieldValues.slice( 0, -1 ).reduce( ( id, field ):string=>{ | |
if ( id && field ) { | |
id += `-` + field; | |
} | |
if ( !id && field ) { | |
id = field; | |
} | |
parentKeys.add( id ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fieldNames = fieldTokens.map( ( field ): string => field.name ); | |
const parentKeys: Set<string> = new Set(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fieldNames = fieldTokens.map( ( field ): string => field.name ); | |
const parentKeys: Set<string> = new Set(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const uniqueIds: Set<number> = new Set(); | |
let lastId = 1; | |
// All treeviewItems | |
treeItems.forEach( ( item ): void => { | |
if ( item && item.data ) { | |
uniqueIds.add( item.data.uniqueId ); | |
lastId += 1; | |
} | |
}); |
NewerOlder