{"id":16302836,"url":"https://github.com/himenon/path-oriented-data-structure","last_synced_at":"2025-04-10T05:58:04.347Z","repository":{"id":51426402,"uuid":"329939959","full_name":"Himenon/path-oriented-data-structure","owner":"Himenon","description":"A composite pattern with a Path-oriented data structure.","archived":false,"fork":false,"pushed_at":"2024-02-04T12:38:37.000Z","size":495,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T04:04:55.931Z","etag":null,"topics":["composite-pattern","data-structure","path-oriented","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/@himenon/path-oriented-data-structure","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Himenon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-15T14:48:48.000Z","updated_at":"2024-02-04T12:34:52.000Z","dependencies_parsed_at":"2024-06-21T04:45:23.750Z","dependency_job_id":"5c5d3348-274b-4f2c-9bb0-3eb9805794ce","html_url":"https://github.com/Himenon/path-oriented-data-structure","commit_stats":{"total_commits":18,"total_committers":5,"mean_commits":3.6,"dds":0.5555555555555556,"last_synced_commit":"769004b431a52369a2a9ac5761ac15c6b6a39b1c"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":"Himenon/template-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Himenon%2Fpath-oriented-data-structure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Himenon%2Fpath-oriented-data-structure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Himenon%2Fpath-oriented-data-structure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Himenon%2Fpath-oriented-data-structure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Himenon","download_url":"https://codeload.github.com/Himenon/path-oriented-data-structure/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248166945,"owners_count":21058480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composite-pattern","data-structure","path-oriented","typescript"],"created_at":"2024-10-10T20:59:05.579Z","updated_at":"2025-04-10T05:58:04.320Z","avatar_url":"https://github.com/Himenon.png","language":"TypeScript","readme":"# @himenon/path-oriented-data-structure\n\nData structure management library that extends Composite Pattern to Path orientation.\n\n## Usage\n\n### Basic Usage\n\n```ts\nimport { Operator, Node } from \"@himenon/path-oriented-data-structure\";\n\nconst operator = new Operator(\"tree\");\n\nconst NODE_KIND_A = \"node_a\" as const;\nconst NODE_KIND_B = \"node_b\" as const;\n\noperator.set(\"a\", new Node(NODE_KIND_A, \"node_a1\"));\noperator.set(\"a/b\", new Node(NODE_KIND_A, \"node_a2\"));\noperator.set(\"a/b/c\", new Node(NODE_KIND_A, \"node_A3\"));\n\noperator.set(\"a\", new Node(NODE_KIND_B, \"node_b1\"));\noperator.set(\"a/b\", new Node(NODE_KIND_B, \"node_b2\"));\noperator.set(\"a/b/c\", new Node(NODE_KIND_B, \"node_b3\"));\n\noperator.getHierarchy(); // Results below\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eResult: operator.getHierarchy()\u003c/summary\u003e\n\u003ccode\u003e\n\u003cpre\u003e\n{\n  \"name\": \".\",\n  \"children\": {\n    \"node_a:a\": {\n      \"name\": \"node_a1\"\n    },\n    \"tree:a\": {\n      \"name\": \"a\",\n      \"children\": {\n        \"node_a:b\": {\n          \"name\": \"node_a2\"\n        },\n        \"tree:b\": {\n          \"name\": \"b\",\n          \"children\": {\n            \"node_a:c\": {\n              \"name\": \"node_A3\"\n            },\n            \"node_b:c\": {\n              \"name\": \"node_b3\"\n            }\n          }\n        },\n        \"node_b:b\": {\n          \"name\": \"node_b2\"\n        }\n      }\n    },\n    \"node_b:a\": {\n      \"name\": \"node_b1\"\n    }\n  }\n}\n\u003c/pre\u003e\n\u003c/code\u003e\n\u003c/details\u003e\n\n### Extended usage of `Node`\n\n```ts\nimport { Operator, Node } from \"@himenon/path-oriented-data-structure\";\n\nexport type KindOfString = \"string\";\nexport type KindOfNumber = \"number\";\nexport type Kind = KindOfNumber | KindOfString;\n\nexport class StringValueNode extends Node\u003cKindOfString\u003e {\n  constructor(name: string, private value: string) {\n    super(\"string\", name);\n  }\n  public getValue(): string {\n    return this.value;\n  }\n  public setValue(value: string): void {\n    this.value = value;\n  }\n}\n\nexport class NumberValueNode extends Node\u003cKindOfNumber\u003e {\n  constructor(name: string, private value: number) {\n    super(\"number\", name);\n  }\n  public getValue(): number {\n    return this.value;\n  }\n}\n\nexport type GetNode\u003cT extends Kind\u003e = T extends KindOfString ? StringValueNode : T extends KindOfNumber ? NumberValueNode : never;\n\n// Type Safe method\nexport const createGetChildByPaths = (operator: Operator\u003cstring\u003e) =\u003e \u003cT extends Kind\u003e(path: string, kind: T): GetNode\u003cT\u003e | undefined =\u003e {\n  return operator.getChildByPaths(path, kind) as GetNode\u003cT\u003e | undefined;\n};\n\nconst operator = new Operator(\"tree\");\n\noperator.set(\"a/b\", new StringValueNode(\"stringValue\", \"hello world\"));\noperator.set(\"a/b\", new NumberValueNode(\"numberValue\", 123455));\n\noperator.getHierarchy(); // Results below\n\nconst getChildByPaths = createGetChildByPaths(operator);\n\ngetChildByPaths(\"a/b\", \"string\"); // ReturnType: StringValueNode | undefined\ngetChildByPaths(\"a/b\", \"number\"); // ReturnType: NumberValueNode | undefined\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eResult: operator.getHierarchy()\u003c/summary\u003e\n\u003ccode\u003e\n\u003cpre\u003e\n{\n  \"name\": \".\",\n  \"children\": {\n    \"tree:a\": {\n      \"name\": \"a\",\n      \"children\": {\n        \"string:b\": {\n          \"name\": \"stringValue\"\n        },\n        \"number:b\": {\n          \"name\": \"numberValue\"\n        }\n      }\n    }\n  }\n}\n\u003c/pre\u003e\n\u003c/code\u003e\n\u003c/details\u003e\n\n## API\n\n### `Operator`\n\n#### `getChildByPaths(path: string, kind: string): Component | undefined`\n\n#### `set(path: string, component: Component): void`\n\n#### `remove(path: string, kind: string): void`\n\n#### `copy(from: string, to: string, kind: string): boolean`\n\n#### `move(from: string, to: string, kind: string): boolean`\n\n#### `getChildPaths(kind: string): string[]`\n\n## LICENCE\n\n[@himenon/path-oriented-data-structure](https://github.com/Himenon/path-oriented-data-structure)・MIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhimenon%2Fpath-oriented-data-structure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhimenon%2Fpath-oriented-data-structure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhimenon%2Fpath-oriented-data-structure/lists"}