Add new query for getting available variables (#52)

* Add new query for getting available variables

* use array for findAllPreviousVariables
This commit is contained in:
Kurt Hutten
2023-03-10 08:35:30 +11:00
committed by GitHub
parent d729ae3990
commit 2bb987b3b5
3 changed files with 102 additions and 4 deletions

View File

@ -335,12 +335,21 @@ export function sketchOnExtrudedFace(
}
}
export const getLastIndex = (pathToNode: PathToNode): number => {
export const getLastIndex = (pathToNode: PathToNode): number =>
splitPathAtLastIndex(pathToNode).index
export function splitPathAtLastIndex(pathToNode: PathToNode): {
path: PathToNode
index: number
} {
const last = pathToNode[pathToNode.length - 1]
if (typeof last === 'number') {
return last
return {
path: pathToNode.slice(0, -1),
index: last,
}
}
return getLastIndex(pathToNode.slice(0, -1))
return splitPathAtLastIndex(pathToNode.slice(0, -1))
}
export function createLiteral(value: string | number): Literal {