Skip to content

Commit

Permalink
chore: Add split to README
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavoguichard committed Aug 21, 2023
1 parent de6a799 commit 7ff5824
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ npm install string-ts
- [join](#join)
- [replace](#replace)
- [replaceAll](#replaceall)
- [split](#split)
- [Strongly-typed alternatives to common loosely-typed functions](#strongly-typed-alternatives-to-common-loosely-typed-functions)
- [words](#words)
- [toDelimiterCase](#todelimitercase)
Expand Down Expand Up @@ -169,6 +170,17 @@ const result = replaceAll(str, '-', ' ');
// ^ 'hello world '
```

### split
This function is a strongly-typed counterpart of `String.prototype.split`.

```ts
import { split } from 'string-ts';

const str = 'hello-world' as const;
const result = split(str, '-');
// ^ ['hello', 'world']
```

## Strongly-typed alternatives to common loosely-typed functions

### words
Expand Down Expand Up @@ -371,6 +383,7 @@ St.Words<'hello-world'> // ['hello', 'world']
St.Join<['hello', 'world'], '-'> // 'hello-world'
St.Replace<'hello-world', 'l', '1'> // 'he1lo-world'
St.ReplaceAll<'hello-world', 'l', '1'> // 'he11o-wor1d'
St.Split<'hello-world', '-'> // ['hello', 'world']
St.TrimStart<' hello world '> // 'hello world '
St.TrimEnd<' hello world '> // ' hello world'
St.Trim<' hello world '> // 'hello world'
Expand Down

0 comments on commit 7ff5824

Please sign in to comment.