{"id":17808282,"url":"https://github.com/loaderb0t/node-terminal-simulator","last_synced_at":"2025-03-17T15:30:55.249Z","repository":{"id":42102064,"uuid":"383789721","full_name":"LoaderB0T/node-terminal-simulator","owner":"LoaderB0T","description":"Simulate and assert the terminal output including many special ANSI codes","archived":false,"fork":false,"pushed_at":"2025-03-10T23:11:33.000Z","size":375,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T23:12:40.982Z","etag":null,"topics":["ansi","assert","codes","emulate","emulator","escape","node","nodejs","simulate","simulator","string","terminal","test"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LoaderB0T.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-07-07T12:23:29.000Z","updated_at":"2025-03-10T23:11:37.000Z","dependencies_parsed_at":"2023-01-29T01:30:39.836Z","dependency_job_id":"f90b5f3e-b751-4fea-b7f7-e8087413849b","html_url":"https://github.com/LoaderB0T/node-terminal-simulator","commit_stats":{"total_commits":100,"total_committers":3,"mean_commits":"33.333333333333336","dds":"0.18000000000000005","last_synced_commit":"a591d6e421ef9e2014b911bcb3022b1a3cb9e09c"},"previous_names":["loaderb0t/node-terminal-emulator"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoaderB0T%2Fnode-terminal-simulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoaderB0T%2Fnode-terminal-simulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoaderB0T%2Fnode-terminal-simulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoaderB0T%2Fnode-terminal-simulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LoaderB0T","download_url":"https://codeload.github.com/LoaderB0T/node-terminal-simulator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243865616,"owners_count":20360473,"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":["ansi","assert","codes","emulate","emulator","escape","node","nodejs","simulate","simulator","string","terminal","test"],"created_at":"2024-10-27T15:10:11.086Z","updated_at":"2025-03-17T15:30:54.839Z","avatar_url":"https://github.com/LoaderB0T.png","language":"TypeScript","readme":"[![npm](https://img.shields.io/npm/v/node-terminal-simulator?color=%2300d26a\u0026style=for-the-badge)](https://www.npmjs.com/package/node-terminal-simulator)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/LoaderB0T/node-terminal-simulator/build.yml?branch=main\u0026style=for-the-badge)](https://github.com/LoaderB0T/node-terminal-simulator/actions/workflows/build.yml)\n[![Sonar Quality Gate](https://img.shields.io/sonar/quality_gate/LoaderB0T_node-terminal-simulator?server=https%3A%2F%2Fsonarcloud.io\u0026style=for-the-badge)](https://sonarcloud.io/summary/new_code?id=LoaderB0T_node-terminal-simulator)\n[![bundle size](https://img.shields.io/bundlephobia/minzip/node-terminal-simulator?color=%23FF006F\u0026label=Bundle%20Size\u0026style=for-the-badge)](https://bundlephobia.com/package/node-terminal-simulator)\n\n# node-terminal-simulator\n\nSimulates the behavior of a terminal in NodeJS.\n\n## Motivation 💥\n\nThis small package provides a simple way to simulate the behavior of a terminal in NodeJS. The primary use case is to unit-test libraries or tools that interact with the terminal. It respects many special ANSI escape sequences, like cursor movement or deleting and inserting lines.\n\n## Features 🔥\n\n✅ Simulates the behavior of a terminal in NodeJS.\n\n✅ Supports ANSI escape sequences. (e.g. cursor movement, deleting and inserting lines)\n\n✅ Easily assert the expected current displayed text in the terminal.\n\n✅ Assert the color or style of any character visible in the simulated terminal.\n\n✅ Send keys to the terminal to simulate user input.\n\n✅ Accurately tracks the cursor position.\n\n✅ Assert the lines that are pushed out of the visible terminal area.\n\n✅ Easily extensible with custom escape sequences.\n\n✅ Easily redirect stdout to the simulated terminal.\n\nThis project is by no means complete, but it's a good starting point. Feel free to open an issue or pull request if you have any suggestions for improvements like new escape sequences.\n\n## Limitations ⚠️\n\n🔒 Escape sequences for colors (and other styles) are removed from the output. (You can still assert styles by using the `getStylesAt(line, char)` method on the `Terminal` instance.)\n\n🔒 Some escape sequences are not recognized. (Feel free to contribute 😊)\n\n## Built With 🔧\n\n- [TypeScript](https://www.typescriptlang.org/)\n\n## Usage Example 🚀\n\n```typescript\nimport { Terminal, DO_DELETE_LINE, DO_MOVE_LEFT_FULLY, DO_MOVE_UP } from 'node-terminal-simulator';\n\nconst t = new Terminal([100, 8]);\n\nt.write('This is a test');\n// Output:\n// This is a test\n\nt.write('. Additional new text.'); // Same line\n// Output:\n// This is a test. Additional text.\n\nt.write('\\n'); // New line\nt.write('This is a new line.');\n// Output:\n// This is a test. Additional text.\n// This is a new line.\n\nt.write(DO_MOVE_UP); // \\u001b[A\nt.write(DO_MOVE_LEFT_FULLY); // \\u001b[999D\nt.write('This overwrites the first line.');\n// Output:\n// This overwrites the first line.text.\n// This is a new line.\n\nt.write(DO_DELETE_LINE); // \\u001b[1L\n// Output:\n// This is a new line.\n\nconsole.log(t.text);\n\nassert(t.text === 'This is a new line.', 't.text should be \"This is a new line.\"');\n```\n\nTODO: Add advanced usage examples.\n\n## Contributing 🧑🏻‍💻\n\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\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\".\nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## License 🔑\n\nDistributed under the MIT License. See `LICENSE.txt` for more information.\n\n## Contact 📧\n\nJanik Schumacher - [@LoaderB0T](https://twitter.com/LoaderB0T) - [linkedin](https://www.linkedin.com/in/janikschumacher/)\n\nProject Link: [https://github.com/LoaderB0T/node-terminal-simulator](https://github.com/LoaderB0T/node-terminal-simulator)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floaderb0t%2Fnode-terminal-simulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floaderb0t%2Fnode-terminal-simulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floaderb0t%2Fnode-terminal-simulator/lists"}