Skip to content

Commit

Permalink
Merge pull request #220 from gridaco/tree-utils
Browse files Browse the repository at this point in the history
Hierarchy Hotfix
  • Loading branch information
softmarshmallow authored Jul 4, 2023
2 parents a3ac319 + 21fb175 commit 7b4fd8f
Show file tree
Hide file tree
Showing 7 changed files with 954 additions and 407 deletions.
2 changes: 1 addition & 1 deletion editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@radix-ui/react-toast": "^1.1.1",
"@radix-ui/react-toolbar": "^1.0.3",
"@reflect-blocks/figma-embed": "^0.0.5",
"@tree-/q": "^0.0.0",
"@tree-/q": "^0.0.1",
"@use-gesture/react": "^10.2.11",
"@visx/gradient": "^1.7.0",
"@visx/group": "^1.7.0",
Expand Down
18 changes: 10 additions & 8 deletions lib/tree-q/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tree-/q",
"version": "0.0.0",
"version": "0.0.1",
"description": "Tree query utility",
"homepage": "https://github.com/gridaco/code/tree/main/lib/tree-q",
"repository": "https://github.com/gridaco/code",
Expand All @@ -10,15 +10,17 @@
"scripts": {
"clean": "rm -rf dist",
"test": "jest",
"build": "tsc",
"prepack": "yarn run clean && yarn run build"
"build": "tsup",
"prepack": "yarn test && yarn clean && yarn build"
},
"dependencies": {},
"devDependencies": {
"@types/node": "^18.11.18",
"jest": "^29.3.1",
"typescript": "^4.9.4",
"ts-jest": "^29.0.3"
"@types/jest": "^29.5.2",
"@types/node": "^20.3.3",
"jest": "^29.5.0",
"ts-jest": "^29.1.1",
"tsup": "^7.1.0",
"typescript": "^5.1.6"
},
"publishConfig": {
"access": "public"
Expand All @@ -28,4 +30,4 @@
"LICENSE",
"dist"
]
}
}
7 changes: 6 additions & 1 deletion lib/tree-q/path/p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ interface Item {
function p<T extends Item = Item>(id: string, { data }: { data: T }): string[] {
let path: string[] = [];

function search(node: T, currentPath: string[]): boolean {
function search(node: T | undefined | null, currentPath: string[]): boolean {
if (node == null) {
return false;
}

if (node.id === id) {
path = [...currentPath, node.id];
return true;
Expand All @@ -36,6 +40,7 @@ function p<T extends Item = Item>(id: string, { data }: { data: T }): string[] {
return true;
}
}

return false;
}

Expand Down
11 changes: 9 additions & 2 deletions lib/tree-q/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2020",
"module": "commonjs",
"lib": ["es2015", "dom"],
"declaration": true,
Expand All @@ -10,5 +10,12 @@
"baseUrl": ".",
"typeRoots": ["node_modules/@types"]
},
"exclude": ["node_modules", "dist", "test", "**/*.spec.ts", "**/*.test.ts"]
"exclude": [
"node_modules",
"dist",
"test",
"**/*.spec.ts",
"**/*.test.ts",
"tsup.config.ts"
]
}
8 changes: 8 additions & 0 deletions lib/tree-q/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: ["index.ts"],
splitting: false,
sourcemap: true,
clean: true,
});
Loading

1 comment on commit 7b4fd8f

@vercel
Copy link

@vercel vercel bot commented on 7b4fd8f Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.