@contextjs/text
Version:
String manipulation utilities for ContextJS applications
40 lines (28 loc) • 1.26 kB
Markdown
# @contextjs/text
[](https://github.com/contextjs/context/actions/workflows/tests.yaml)
[](https://www.npmjs.com/package/@contextjs/text)
[](https://github.com/contextjs/context/blob/main/LICENSE)
> String manipulation utilities for ContextJS applications
## Features
- Chainable, immutable-safe `StringBuilder` implementation
- Efficient string concatenation using segment arrays
- Support for insertion, removal, and replacement
- Fluent `appendFormat`, `appendLine`, `clear`, and `clone` methods
- Implicit string conversion with `Symbol.toPrimitive`
- Test-driven and zero-runtime dependency
## Installation
```bash
npm i @contextjs/text
```
## Usage Example
```typescript
import { StringBuilder } from "@contextjs/text";
const builder = new StringBuilder();
builder
.append("Hello")
.append(", ")
.appendFormat("{0}!", "world");
console.log(builder.toString()); // "Hello, world!"
```
## API Reference
For detailed API documentation, please refer to the [API Reference](https://contextjs.dev/api/text#api-reference).