{"id":29629992,"url":"https://github.com/binarymax/jstrees","last_synced_at":"2025-07-21T10:07:58.911Z","repository":{"id":1791641,"uuid":"2715559","full_name":"binarymax/jstrees","owner":"binarymax","description":"Javascript tree data structures","archived":false,"fork":false,"pushed_at":"2015-11-14T12:10:13.000Z","size":124,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-15T12:19:44.297Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://binarymax.com/tree.html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mikestowe/php-ramlMerge","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/binarymax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-11-05T14:36:40.000Z","updated_at":"2023-12-26T18:18:52.000Z","dependencies_parsed_at":"2022-08-19T13:32:36.831Z","dependency_job_id":null,"html_url":"https://github.com/binarymax/jstrees","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/binarymax/jstrees","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarymax%2Fjstrees","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarymax%2Fjstrees/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarymax%2Fjstrees/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarymax%2Fjstrees/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binarymax","download_url":"https://codeload.github.com/binarymax/jstrees/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binarymax%2Fjstrees/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266278418,"owners_count":23904045,"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":[],"created_at":"2025-07-21T10:07:58.466Z","updated_at":"2025-07-21T10:07:58.905Z","avatar_url":"https://github.com/binarymax.png","language":"JavaScript","readme":"#jsTrees\n\nJavascript Tree-themed algorithms\n\n##Tree Generator Example\n\nTree generator uses the tree API and accompanying settings.js to let the user generate simple trees on an html canvas.\nA live example is here: http://www.binarymax.com/tree.html\n\n##tree.js API\n\n### makeNode : Creates a root node.\n\nAll nodes (including root) have the following prototype functions:\t\n * addChild(obj) : Converts an object into a node, and appends it as a child.\n * traverse(callback) : Traverses the tree, leaf nodes first down to root, and executes a callback for each.\n * traverse2(callback) : Traverses the tree, root first up to leaf nodes, and executes a callback for each.\n\n### arrayToTree : Converts a flat array to a tree data structure\n\n###Sample input:\n```\n\tvar ary = [\n\t\t{\"Level\":1,\"Name\":\"a\"},\n\t\t{\"Level\":2,\"Name\":\"b\"},\n\t\t{\"Level\":2,\"Name\":\"c\"},\n\t\t{\"Level\":3,\"Name\":\"d\"},\n\t\t{\"Level\":3,\"Name\":\"e\"},\n\t\t{\"Level\":4,\"Name\":\"f\"},\n\t\t{\"Level\":2,\"Name\":\"g\"},\n\t\t{\"Level\":1,\"Name\":\"h\"},\n\t\t{\"Level\":2,\"Name\":\"i\"},\n\t\t{\"Level\":3,\"Name\":\"j\"},\n\t\t{\"Level\":4,\"Name\":\"k\"},\n\t\t{\"Level\":3,\"Name\":\"l\"},\n\t\t{\"Level\":1,\"Name\":\"m\"},\n\t\t{\"Level\":2,\"Name\":\"n\"}\n\t];\n\t\n\tvar tree = Tree.arrayToTree(ary,function(obj){ return parseInt(obj.Level)||0; });\n\tvar str = \"\";\n\ttree.traverse(function(obj){\n\t\tstr+=\"\\n\";\n\t\tfor(var i=0;i\u003cobj.depth;i++) {\n\t\t\tstr+=\"    |\";\n\t\t}\n\t\tstr+=obj.Name;\n\t});\n\tconsole.log(str);\n```\n\n###Sample output:\n```\n    |a\n    |    |b\n    |    |c\n    |    |    |d\n    |    |    |e\n    |    |    |    |f\n    |    |g\n    |h\n    |    |i\n    |    |    |j\n    |    |    |    |k\n    |    |    |l\n    |m\n    |    |n\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinarymax%2Fjstrees","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinarymax%2Fjstrees","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinarymax%2Fjstrees/lists"}