From 7ff582495eecef8e404c0597d452b74059bcd701 Mon Sep 17 00:00:00 2001 From: Gustavo Guichard Date: Mon, 21 Aug 2023 12:20:52 -0300 Subject: [PATCH] chore: Add split to README --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index b548270..c71ca19 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 @@ -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'