Skip to content

Commit b925ba3

Browse files
committed
update text readme
1 parent 469b5e9 commit b925ba3

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

packages/text/README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ List of items:
5454

5555
```bash
5656
npm install @synstack/text
57+
# or
5758
yarn add @synstack/text
59+
# or
60+
pnpm add @synstack/text
5861
```
5962

6063
## Features
@@ -151,7 +154,7 @@ This is a list of items:
151154
- You can infer the value type of the extra object by using a type assertion from `Text.ExtraObject.Infer`
152155

153156
```ts
154-
import { t, tParse, type Text } from "@pairprog/text";
157+
import { t, tParse, type Text } from "@synstack/text";
155158

156159
// @ts-expect-error - The non-matching extra object will be rejected
157160
const textFail: Text.String<{ type: "extra"; value: string }> =
@@ -164,3 +167,46 @@ const text: string & { __extra: { type: "extra"; value: string } } =
164167
console.log(tParse(text));
165168
// ["Hello ", { type: "extra", value: "Hello" }, " World"]
166169
```
170+
171+
### Configuration Options
172+
173+
You can configure text processing behavior using `Text.options()`:
174+
175+
```ts
176+
import { Text } from "@synstack/text";
177+
178+
// Custom join string for arrays
179+
const customText = Text.options({ joinString: " | " });
180+
const result = customText.t`Items: ${["A", "B", "C"]}`;
181+
// "Items: A | B | C"
182+
183+
// Chain options
184+
const text = Text.options()
185+
.options({ joinString: ", " })
186+
.t`List: ${["item1", "item2"]}`;
187+
// "List: item1, item2"
188+
```
189+
190+
191+
## API Reference
192+
193+
### Core Functions
194+
195+
- **`t`** - Main templating function for creating formatted text
196+
- **`tParse`** - Parse text with extra objects back into components
197+
198+
### Classes & Types
199+
200+
- **`Text`** - Main text processing class with configurable options
201+
- **`Text.Options`** - Configuration options interface
202+
- **`Text.String<T>`** - String type with extra object information
203+
- **`Text.ExtraObject.Base`** - Base type for extra objects
204+
- **`TextParseExtraItemException`** - Exception thrown during parsing errors
205+
206+
### Configuration
207+
208+
```ts
209+
type Text.Options = {
210+
joinString?: string; // Default: "\n"
211+
}
212+
```

0 commit comments

Comments
 (0)