Skip to content

Commit a04cb7e

Browse files
committed
chore: refine README
1 parent c1650ae commit a04cb7e

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

.changeset/new-snakes-rescue.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"typed-string-interpolation": patch
3+
---
4+
5+
Refine readme

README.md

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@
1010
- Options to customize return, pattern matching and sanity checking
1111
- Both ES Module `.mjs` and CommonJS `.cjs` distributions available. Use anywhere!
1212
- Tiny footprint:
13-
- ES Module: `0.462kB` (`773B` unpacked)
14-
- CommonJS: `0.833B` (`1.75kB` unpacked)
13+
- ES Module: `0.46kB` (`0.77kB` unpacked)
14+
- CommonJS: `0.83kB` (`1.75kB` unpacked)
1515

1616
## Motivation
1717

18-
String interpolation/variable substitution (i.e. injecting variables within text) is a really common operation when building single and multilingual applications. Existing string interpolation utilities within the most used `i18n` / `l10n` packages like `i18next` and `formatjs` come with massive overhead while lacking thing like proper TypeScript infer support for the interpolation operation.
18+
String interpolation/variable substitution (i.e. injecting variables within text) is a really common operation when building single and multilingual applications. Existing string interpolation utilities within the most used `i18n` / `l10n` packages like `i18next` and `formatjs` come with massive overhead while lacking proper TypeScript infer support for the interpolation operation.
1919

2020
This package aims to provide a high quality string interpolation "primitive" to use as is or within other localization frameworks and tooling.
2121

2222
## Getting started
2323

24+
Easiest way to get started is to play around with a [React example sandbox](https://codesandbox.io/p/sandbox/typed-string-interpolation-react-example-slpjgp).
25+
26+
> ℹ Note that the library itself is framework agnostic and could be used with anything.
27+
2428
### Install
2529

2630
```bash
@@ -36,35 +40,26 @@ import { stringInterpolation } from "typed-string-interpolation"
3640
const { stringInterpolation } = require("typed-string-interpolation")
3741
```
3842

43+
Returns a `string` when the result can be joined into a string.
44+
3945
```ts
4046
stringInterpolation("hello {{world}}", {
4147
world: "world",
4248
}) // "hello world"
4349
```
4450

45-
Pass in anything you want an get back sane results when interpolation result shouldn't be turned into a `string`:
51+
Returns an array when the result can't be joined into a `string`. This makes it really easy to use the utility with libraries like `react` or anything else.
4652

4753
```tsx
4854
stringInterpolation("hello {{world}} with {{anything}}", {
4955
world: "world",
50-
anything: <span className="bold">anything</span>,
51-
})
52-
```
53-
54-
Returns an array for easy use with libraries like `react` or anything else!
55-
56-
```tsx
57-
const interpolationResult = [
58-
"hello ",
59-
"world",
60-
" with ",
61-
<span className="bold">anything</span>,
62-
]
56+
anything: <strong>anything</strong>,
57+
}) // ["hello ", "world", " with ", <strong>anything</strong>]
6358
```
6459

6560
## TypeScript support
6661

67-
If the string can be joined you'll get back a string. Otherwise a union type within an array is returned based on the passed in variables.
62+
If the string can be joined you'll get back a `string` type. Otherwise a ` type within an array is returned based on the passed in variables.
6863

6964
```ts
7065
stringInterpolation("hello {{world}} with number {{number}}", {
@@ -75,7 +70,7 @@ stringInterpolation("hello {{world}} with number {{number}}", {
7570

7671
```tsx
7772
stringInterpolation("hello {{world}} with number {{number}}", {
78-
world: <span className="bold">world</span>,
73+
world: <strong>world</strong>,
7974
number: 1,
8075
}) // : (string | JSX.Element | number)[]
8176
```
@@ -137,11 +132,11 @@ Turning of sanity checking removes `throw` from:
137132
138133
## Contributing
139134
140-
Easiest way to contribute is to open new issues for API suggestions and fixes.
135+
Easiest way to contribute is to open new issues for API suggestions and bugs.
141136
142137
### Contributing for a release
143138
144-
Basic steps for contributing for a release:
139+
Steps for contributing through a PR:
145140
146141
- Fork `main` on Github and clone fork locally
147142
- `npm ci` to install dependencies
@@ -150,7 +145,7 @@ Basic steps for contributing for a release:
150145
- `npm run test:unit:watch`
151146
- Unit test for types in watch mode:
152147
- `npm run test:unit:types:watch`
153-
- Once all changes are complete create a new release with changeset. This creates a PR that once merged will get released.
148+
- Once all changes are complete create a new release with [changesets](https://github.com/changesets/changesets)
154149
- `npm run changeset`
155-
- Commit and push changes
156-
- Open a pull request for the fork
150+
- Commit and push changes to fork
151+
- Open a pull request against the fork

0 commit comments

Comments
 (0)