{"id":18914373,"url":"https://github.com/ashu11-a/truth-table","last_synced_at":"2026-01-23T18:31:27.644Z","repository":{"id":255750443,"uuid":"853361908","full_name":"Ashu11-A/truth-table","owner":"Ashu11-A","description":"Formatters for truth tables","archived":false,"fork":false,"pushed_at":"2025-10-18T05:55:17.000Z","size":200,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T03:41:52.531Z","etag":null,"topics":["abstract-syntax-tree","abstract-syntax-trees","ast","ast-generation","ast-interpreter","ast-parser","ast-transformations","ast-tree","table","table-formatter","truth","truth-table","truth-table-generator","truth-tables"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/truth-table-ast","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/Ashu11-A.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-06T14:00:52.000Z","updated_at":"2025-10-18T05:55:21.000Z","dependencies_parsed_at":"2024-11-11T16:46:43.716Z","dependency_job_id":null,"html_url":"https://github.com/Ashu11-A/truth-table","commit_stats":null,"previous_names":["ashu11-a/truth-table"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/Ashu11-A/truth-table","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ashu11-A%2Ftruth-table","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ashu11-A%2Ftruth-table/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ashu11-A%2Ftruth-table/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ashu11-A%2Ftruth-table/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ashu11-A","download_url":"https://codeload.github.com/Ashu11-A/truth-table/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ashu11-A%2Ftruth-table/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28697428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T17:25:48.045Z","status":"ssl_error","status_checked_at":"2026-01-23T17:25:47.153Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["abstract-syntax-tree","abstract-syntax-trees","ast","ast-generation","ast-interpreter","ast-parser","ast-transformations","ast-tree","table","table-formatter","truth","truth-table","truth-table-generator","truth-tables"],"created_at":"2024-11-08T10:11:11.182Z","updated_at":"2026-01-23T18:31:27.595Z","avatar_url":"https://github.com/Ashu11-A.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# Truth Table\n\n![license-info](https://img.shields.io/github/license/Ashu11-A/Truth-Table?style=for-the-badge\u0026colorA=302D41\u0026colorB=f9e2af\u0026logoColor=f9e2af)\n![stars-infoa](https://img.shields.io/github/stars/Ashu11-A/Truth-Table?colorA=302D41\u0026colorB=f9e2af\u0026style=for-the-badge)\n![Last-Comitt](https://img.shields.io/github/last-commit/Ashu11-A/Truth-Table?style=for-the-badge\u0026colorA=302D41\u0026colorB=b4befe)\n\n![Comitts Year](https://img.shields.io/github/commit-activity/y/Ashu11-A/Truth-Table?style=for-the-badge\u0026colorA=302D41\u0026colorB=f9e2af\u0026logoColor=f9e2af\u0026authorFilter=Ashu11-A\u0026label=COMMIT+ACTIVITY)\n![reposize-info](https://img.shields.io/github/languages/code-size/Ashu11-A/Truth-Table?style=for-the-badge\u0026colorA=302D41\u0026colorB=90dceb)\n\n![npm package minimized gzipped size](https://img.shields.io/bundlejs/size/truth-table-ast?style=for-the-badge\u0026colorA=302D41\u0026colorB=3ac97b)\n\n\u003c/div\u003e\n\n## 🔍 | What can this do?\n\nThis project is based on AST (Abstract Syntax Tree). It can both generate the AST and validate the syntax of the input, transforming it into a consumable data structure to generate any type of representation, such as CSV tables. In case of an error, it is possible to handle the error, allowing the display of the line and column where a syntax error is present. Below is an example of how to work with this library:\n\n## 💫 Main Features:\n\n- Syntax validation and error location reporting\n- Abstract Syntax Tree (AST) generation\n- Support for generating truth tables from parsed logic expressions\n- Flexible output formats (e.g., CSV)\n\n\n## 🚀 | Getting Started\nTo get a local copy up and running, follow these simple steps:\n\nPrerequisites\nNode.js (v20+ recommended)\n\n### Installation\n```sh\nnpm i truth-table-ast\n#OR\nnpm i -g truth-table-ast\n```\n\n## 📚 | Usage\nAfter installing this package globally, you can use the following commands:\n### 📟 | Terminal:\n\n```sh\ntt -p \"p ˅ (p ^ q)\"\n# Or use this if your operating system doesn't detect the package\nnpx truth-table -p \"p ˅ (p ^ q)\" -o table.csv\n```\n\n#### 📄 | Help:\n\n```txt\nUsage: tt [options]\n\n  Options:\n\n   -h --help        Show all available arguments\n   -o --output      File where the truth table will be saved\n   -d --display     How the data will be displayed in the table, supports: boolean, number\n   -t --type        Type of file the table will be saved in (csv | text)\n   -p --proposition Define proposition to generate truth table\n```\n\n### 👨‍💻 | Code:\nHere's an example of how to work with this library:\n```ts\n// ESM:\nimport { AST, Structure, Table } from 'truth-table-ast'\n// Communjs:\n// const { AST, Structure, Table } = require('truth-table-ast')\n\n// In communjs, you'll need to put the code in an anonymous function for the asynchronous functions to work\n// void (async () =\u003e {\n  // code here\n// })()\n\nconst input = 'p ^ (p v ~q)'\nconst parser = new AST(input)\nconst ast = parser.parse()\n\nif (isError(ast)) throw new Error(JSON.stringify(ast, null, 2))\nawait parser.save('ast.json')\n\nconst structure = new Structure(ast).generate()\nawait structure.save('structure.json')\n\nconst table = new Table({\n  structure,\n  display: 'boolean',\n  // type: 'csv'\n})//.create('table.csv')\n\n// const content = table.csv()\n// const content = table.markdown()\n\ntable.type = 'markdown'\nawait table.create('table.md')\n\ntable.type = 'csv'\nawait table.create('table.csv')\n```\n\n## ✨ | Outputs\n\n#### 📜 | AST:\nThe AST (Abstract Syntax Tree) generated from the input of p ^ (p v ~q):\n```json\n[\n  {\n    \"value\": \"p\",\n    \"type\": \"Proposition\",\n    \"negatived\": false,\n    \"loc\": {\n      \"start\": {\n        \"line\": 1,\n        \"column\": 0\n      },\n      \"end\": {\n        \"line\": 1,\n        \"column\": 0\n      }\n    }\n  },\n  {\n    \"type\": \"Operation\",\n    \"value\": \"^\",\n    \"key\": \"Conjunction\",\n    \"loc\": {...}\n  },\n  {\n    \"type\": \"SubExpression\",\n    \"body\": [\n      {\n        \"value\": \"p\",\n        \"type\": \"Proposition\",\n        \"negatived\": false,\n        \"loc\": {...}\n      },\n      {\n        \"type\": \"Operation\",\n        \"value\": \"v\",\n        \"key\": \"Disjunction\",\n        \"loc\": {...}\n      },\n      {\n        \"value\": \"q\",\n        \"type\": \"Proposition\",\n        \"negatived\": true,\n        \"loc\": {...}\n      }\n    ],\n    \"negatived\": false,\n    \"loc\": {...}\n  }\n]\n```\n\n#### 📃 | Structure:\nThe structured data generated from the AST to generate the truth table:\n```json\n[\n  {\n    \"type\": \"Variable\",\n    \"element\": \"p\",\n    \"value\": true,\n    \"column\": 0,\n    \"row\": 0,\n    \"position\": \"0x0\"\n  },\n  {\n    \"type\": \"Variable\",\n    \"element\": \"q\",\n    \"value\": true,\n    \"column\": 1,\n    \"row\": 0,\n    \"position\": \"0x1\"\n  },\n  {\n    \"type\": \"VariableNegative\",\n    \"element\": \"~q\",\n    \"value\": false,\n    \"column\": 2,\n    \"row\": 0,\n    \"position\": \"0x2\"\n  },\n  {\n    \"type\": \"Result\",\n    \"element\": \"(p v ~q)\",\n    \"value\": true,\n    \"column\": 3,\n    \"row\": 0,\n    \"position\": \"0x3\"\n  },\n  {\n    \"type\": \"Result\",\n    \"element\": \"p ^ (p v ~q)\",\n    \"value\": true,\n    \"column\": 4,\n    \"row\": 0,\n    \"position\": \"0x4\"\n  },\n  {...}\n]\n```\n\n#### 📋 | Truth Table:\n|     p      |     q      |     ~q     |  (p v ~q)  |p ^ (p v ~q)|\n|------------|------------|------------|------------|------------|\n|    true    |    true    |   false    |    true    |    true    |\n|    true    |   false    |    true    |    true    |    true    |\n|   false    |    true    |   false    |   false    |   false    |\n|   false    |   false    |    true    |    true    |   false    |\n\n## 🤝 | Contributing\nContributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.\n\n## 📝 | License\nDistributed under the MIT License. See LICENSE.txt for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashu11-a%2Ftruth-table","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashu11-a%2Ftruth-table","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashu11-a%2Ftruth-table/lists"}