Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lambdalisue/deno-ansi-escape-code
🦕 Utilities to trim and parse ANSI escape code
https://github.com/lambdalisue/deno-ansi-escape-code
ansi-escape-code deno jsr
Last synced: 3 months ago
JSON representation
🦕 Utilities to trim and parse ANSI escape code
- Host: GitHub
- URL: https://github.com/lambdalisue/deno-ansi-escape-code
- Owner: lambdalisue
- License: mit
- Created: 2022-03-19T15:12:55.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-06T06:04:31.000Z (10 months ago)
- Last Synced: 2024-10-04T15:47:01.106Z (4 months ago)
- Topics: ansi-escape-code, deno, jsr
- Language: TypeScript
- Homepage: https://jsr.io/@lambdalisue/ansi-escape-code
- Size: 26.4 KB
- Stars: 14
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ansi-escape-code
[![jsr](https://img.shields.io/jsr/v/%40lambdalisue/ansi-escape-code?logo=javascript&logoColor=white)](https://jsr.io/@lambdalisue/ansi-escape-code)
[![denoland](https://img.shields.io/github/v/release/lambdalisue/deno-ansi-escape-code?logo=deno&label=denoland)](https://github.com/lambdalisue/deno-ansi-escape-code/releases)
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/ansi_escape_code/mod.ts)
[![Test](https://github.com/lambdalisue/deno-ansi-escape-code/workflows/Test/badge.svg)](https://github.com/lambdalisue/deno-ansi-escape-code/actions?query=workflow%3ATest)Utilities to trim and parse ANSI escape sequence.
[deno]: https://deno.land/
## Usage
```typescript
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { trimAndParse } from "https://deno.land/x/ansi_escape_code/mod.ts";const [trimmed, annotations] = trimAndParse(
"\x1b[1mHe\x1b[30mll\x1b[31mo\x1b[m world",
);assertEquals(trimmed, "Hello world");
assertEquals(annotations, [
{ offset: 0, raw: "\x1b[1m", csi: { sgr: { bold: true } } },
{ offset: 2, raw: "\x1b[30m", csi: { sgr: { foreground: 0 } } },
{ offset: 4, raw: "\x1b[31m", csi: { sgr: { foreground: 1 } } },
{ offset: 5, raw: "\x1b[m", csi: { sgr: { reset: true } } },
]);
```## License
The code follows MIT license written in [LICENSE](./LICENSE). Contributors need
to agree that any modifications sent in this repository follow the license.