diff --git a/CHANGELOG.md b/CHANGELOG.md index a48dd892..c19b4d0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@
-## Unreleased (2024-07-07) +## Unreleased (2024-07-13)
@@ -82,6 +82,39 @@ +
+ +#### [@stdlib/string/base/capitalize](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/capitalize) + +
+ +
+ +##### Features + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7) - improve type safety + +
+ + + +
+ +##### BREAKING CHANGES + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): improve type safety +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): The return types are now more specific. This may break existing code that relies on less strict typing, but should not affect most users. To preserve the prior behavior, you can cast the return value to `string` via a type assertion. + +
+ + + +
+ +
+ + +
#### [@stdlib/string/base/for-each-code-point-right](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/for-each-code-point-right) @@ -216,6 +249,39 @@ This release closes the following issue: +
+ +#### [@stdlib/string/base/lowercase](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/lowercase) + +
+ +
+ +##### Features + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7) - improve type safety + +
+ + + +
+ +##### BREAKING CHANGES + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): improve type safety +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): The return types are now more specific. This may break existing code that relies on less strict typing, but should not affect most users. To preserve the prior behavior, you can cast the return value to `string` via a type assertion. + +
+ + + +
+ +
+ + +
#### [@stdlib/string/base/replace-after](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/replace-after) @@ -434,6 +500,105 @@ This release closes the following issue: +
+ +#### [@stdlib/string/base/uncapitalize](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/uncapitalize) + +
+ +
+ +##### Features + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7) - improve type safety + +
+ + + +
+ +##### BREAKING CHANGES + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): improve type safety +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): The return types are now more specific. This may break existing code that relies on less strict typing, but should not affect most users. To preserve the prior behavior, you can cast the return value to `string` via a type assertion. + +
+ + + +
+ +
+ + + +
+ +#### [@stdlib/string/base/uppercase](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/uppercase) + +
+ +
+ +##### Features + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7) - improve type safety + +
+ + + +
+ +##### BREAKING CHANGES + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): improve type safety +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): The return types are now more specific. This may break existing code that relies on less strict typing, but should not affect most users. To preserve the prior behavior, you can cast the return value to `string` via a type assertion. + +
+ + + +
+ +
+ + + +
+ +#### [@stdlib/string/capitalize](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/capitalize) + +
+ +
+ +##### Features + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7) - improve type safety + +
+ + + +
+ +##### BREAKING CHANGES + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): improve type safety +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): The return types are now more specific. This may break existing code that relies on less strict typing, but should not affect most users. To preserve the prior behavior, you can cast the return value to `string` via a type assertion. + +
+ + + +
+ +
+ + +
#### [@stdlib/string/last](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/last) @@ -456,6 +621,39 @@ This release closes the following issue: +
+ +#### [@stdlib/string/lowercase](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/lowercase) + +
+ +
+ +##### Features + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7) - improve type safety + +
+ + + +
+ +##### BREAKING CHANGES + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): improve type safety +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): The return types are now more specific. This may break existing code that relies on less strict typing, but should not affect most users. To preserve the prior behavior, you can cast the return value to `string` via a type assertion. + +
+ + + +
+ +
+ + +
#### [@stdlib/string/replace-before](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/replace-before) @@ -500,6 +698,72 @@ This release closes the following issue: +
+ +#### [@stdlib/string/uncapitalize](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/uncapitalize) + +
+ +
+ +##### Features + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7) - improve type safety + +
+ + + +
+ +##### BREAKING CHANGES + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): improve type safety +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): The return types are now more specific. This may break existing code that relies on less strict typing, but should not affect most users. To preserve the prior behavior, you can cast the return value to `string` via a type assertion. + +
+ + + +
+ +
+ + + +
+ +#### [@stdlib/string/uppercase](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/uppercase) + +
+ +
+ +##### Features + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7) - improve type safety + +
+ + + +
+ +##### BREAKING CHANGES + +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): improve type safety +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): The return types are now more specific. This may break existing code that relies on less strict typing, but should not affect most users. To preserve the prior behavior, you can cast the return value to `string` via a type assertion. + +
+ + + +
+ +
+ + +
@@ -508,6 +772,8 @@ This release closes the following issue: ### BREAKING CHANGES +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): improve type safety +- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7): The return types are now more specific. This may break existing code that relies on less strict typing, but should not affect most users. To preserve the prior behavior, you can cast the return value to `string` via a type assertion. - [`ec1c506`](https://github.com/stdlib-js/stdlib/commit/ec1c5066955fdcc71013805a5c55fc739d29a849): resolve negative index arguments relative to last index - [`ec1c506`](https://github.com/stdlib-js/stdlib/commit/ec1c5066955fdcc71013805a5c55fc739d29a849): resolve negative index arguments relative to last index @@ -596,6 +862,7 @@ A total of 9 people contributed to this release. Thank you to the following cont
+- [`67858b3`](https://github.com/stdlib-js/stdlib/commit/67858b341e920fed871e34ba0d6b6809804916f7) - **feat:** improve type safety _(by Philipp Burckhardt)_ - [`659f752`](https://github.com/stdlib-js/stdlib/commit/659f752db18317bf5fc237fdbcad0d74b61e1ed9) - **style:** add missing spaces _(by Philipp Burckhardt)_ - [`a78f7d1`](https://github.com/stdlib-js/stdlib/commit/a78f7d1b859b6b1d7b0bc0ee4daf76789e3e0910) - **style:** add missing spaces _(by Philipp Burckhardt)_ - [`c3ebfa8`](https://github.com/stdlib-js/stdlib/commit/c3ebfa80e311db338b171ebf8eb5f46bc66e9bf6) - **docs:** update namespace table of contents and address spelling errors _(by Philipp Burckhardt)_ diff --git a/base/capitalize/docs/types/index.d.ts b/base/capitalize/docs/types/index.d.ts index 0a53a322..2e261a40 100644 --- a/base/capitalize/docs/types/index.d.ts +++ b/base/capitalize/docs/types/index.d.ts @@ -18,6 +18,8 @@ // TypeScript Version: 4.1 +type Capitalize = S extends `${infer F}${infer R}` ? `${Uppercase}${R}` : S; + /** * Capitalizes the first character in a string. * @@ -40,7 +42,7 @@ * var out = capitalize( 'Hidden Treasures' ); * // returns 'Hidden Treasures' */ -declare function capitalize( str: string ): string; +declare function capitalize( str: S ): Capitalize; // EXPORTS // diff --git a/base/capitalize/docs/types/test.ts b/base/capitalize/docs/types/test.ts index 072215f8..8644f23a 100644 --- a/base/capitalize/docs/types/test.ts +++ b/base/capitalize/docs/types/test.ts @@ -23,7 +23,11 @@ import capitalize = require( './index' ); // The function returns a string... { - capitalize( 'abc' ); // $ExpectType string + capitalize( 'abc' ); // $ExpectType "Abc" + capitalize( 'beep boop' ); // $ExpectType "Beep boop" + capitalize( 'a' ); // $ExpectType "A" + capitalize( 'A' ); // $ExpectType "A" + capitalize( 'abc' as string ); // $ExpectType string } // The compiler throws an error if the function is provided a value other than a string... diff --git a/base/lowercase/docs/types/index.d.ts b/base/lowercase/docs/types/index.d.ts index d06fef84..b73454a5 100644 --- a/base/lowercase/docs/types/index.d.ts +++ b/base/lowercase/docs/types/index.d.ts @@ -28,7 +28,7 @@ * var str = lowercase( 'bEEp' ); * // returns 'beep' */ -declare function lowercase( str: string ): string; +declare function lowercase( str: S ): Lowercase; // EXPORTS // diff --git a/base/lowercase/docs/types/test.ts b/base/lowercase/docs/types/test.ts index daa8c245..50fbe9a6 100644 --- a/base/lowercase/docs/types/test.ts +++ b/base/lowercase/docs/types/test.ts @@ -23,7 +23,9 @@ import lowercase = require( './index' ); // The function returns a string... { - lowercase( 'abc' ); // $ExpectType string + lowercase( 'ABC' ); // $ExpectType "abc" + lowercase( 'Beep BOOP' ); // $ExpectType "beep boop" + lowercase( 'abc' as string ); // $ExpectType string } // The compiler throws an error if the function is provided a value other than a string... diff --git a/base/uncapitalize/docs/types/index.d.ts b/base/uncapitalize/docs/types/index.d.ts index 31bbdd81..a7860f7e 100644 --- a/base/uncapitalize/docs/types/index.d.ts +++ b/base/uncapitalize/docs/types/index.d.ts @@ -18,6 +18,8 @@ // TypeScript Version: 4.1 +type Uncapitalize = S extends `${infer F}${infer R}` ? `${Lowercase}${R}` : S; + /** * Uncapitalizes the first character of a string. * @@ -40,7 +42,7 @@ * var out = uncapitalize( 'Hidden Treasures' ); * // returns 'hidden Treasures' */ -declare function uncapitalize( str: string ): string; +declare function uncapitalize( str: S ): Uncapitalize; // EXPORTS // diff --git a/base/uncapitalize/docs/types/test.ts b/base/uncapitalize/docs/types/test.ts index bb1a0d2f..197c29a2 100644 --- a/base/uncapitalize/docs/types/test.ts +++ b/base/uncapitalize/docs/types/test.ts @@ -23,7 +23,11 @@ import uncapitalize = require( './index' ); // The function returns a string... { - uncapitalize( 'Last man standing' ); // $ExpectType string + uncapitalize( 'Last man standing' ); // $ExpectType "last man standing" + uncapitalize( 'Hello World!' ); // $ExpectType "hello World!" + uncapitalize( 'BeepBoop' ); // $ExpectType "beepBoop" + uncapitalize( 'A' ); // $ExpectType "a" + uncapitalize( 'foo' as string ); // $ExpectType string } // The compiler throws an error if the function is provided a value other than a string... diff --git a/base/uppercase/docs/types/index.d.ts b/base/uppercase/docs/types/index.d.ts index 6c3eb612..4341559f 100644 --- a/base/uppercase/docs/types/index.d.ts +++ b/base/uppercase/docs/types/index.d.ts @@ -28,7 +28,7 @@ * var str = uppercase( 'bEEp' ); * // returns 'BEEP' */ -declare function uppercase( str: string ): string; +declare function uppercase( str: S ): Uppercase; // EXPORTS // diff --git a/base/uppercase/docs/types/test.ts b/base/uppercase/docs/types/test.ts index 9d327889..beae3f0d 100644 --- a/base/uppercase/docs/types/test.ts +++ b/base/uppercase/docs/types/test.ts @@ -23,7 +23,11 @@ import uppercase = require( './index' ); // The function returns a string... { - uppercase( 'Last man standing' ); // $ExpectType string + uppercase( 'Last man standing' ); // $ExpectType "LAST MAN STANDING" + uppercase( 'Hello World!' ); // $ExpectType "HELLO WORLD!" + uppercase( 'beep' ); // $ExpectType "BEEP" + uppercase( 'BOOP' ); // $ExpectType "BOOP" + uppercase( 'foo' as string ); // $ExpectType string } // The compiler throws an error if the function is provided a value other than a string... diff --git a/capitalize/docs/types/index.d.ts b/capitalize/docs/types/index.d.ts index c559d18c..60c2849f 100644 --- a/capitalize/docs/types/index.d.ts +++ b/capitalize/docs/types/index.d.ts @@ -18,6 +18,8 @@ // TypeScript Version: 4.1 +type Capitalize = S extends `${infer F}${infer R}` ? `${Uppercase}${R}` : S; + /** * Capitalizes the first character in a string. * @@ -40,7 +42,7 @@ * var out = capitalize( 'Hidden Treasures' ); * // returns 'Hidden Treasures' */ -declare function capitalize( str: string ): string; +declare function capitalize( str: S ): Capitalize; // EXPORTS // diff --git a/capitalize/docs/types/test.ts b/capitalize/docs/types/test.ts index 508d191b..621a6c85 100644 --- a/capitalize/docs/types/test.ts +++ b/capitalize/docs/types/test.ts @@ -21,9 +21,13 @@ import capitalize = require( './index' ); // TESTS // -// The function returns a string... +// The function returns a capitalized string... { - capitalize( 'abc' ); // $ExpectType string + capitalize( 'abc' ); // $ExpectType "Abc" + capitalize( 'beep boop' ); // $ExpectType "Beep boop" + capitalize( 'a' ); // $ExpectType "A" + capitalize( 'A' ); // $ExpectType "A" + capitalize( 'abc' as string ); // $ExpectType string } // The compiler throws an error if the function is provided a value other than a string... diff --git a/lowercase/docs/types/index.d.ts b/lowercase/docs/types/index.d.ts index 56d30464..2d0b221e 100644 --- a/lowercase/docs/types/index.d.ts +++ b/lowercase/docs/types/index.d.ts @@ -28,7 +28,7 @@ * var str = lowercase( 'bEEp' ); * // returns 'beep' */ -declare function lowercase( str: string ): string; +declare function lowercase( str: S ): Lowercase; // EXPORTS // diff --git a/lowercase/docs/types/test.ts b/lowercase/docs/types/test.ts index 5e3fcaef..0f9c1455 100644 --- a/lowercase/docs/types/test.ts +++ b/lowercase/docs/types/test.ts @@ -23,7 +23,9 @@ import lowercase = require( './index' ); // The function returns a string... { - lowercase( 'abc' ); // $ExpectType string + lowercase( 'ABC' ); // $ExpectType "abc" + lowercase( 'Beep BOOP' ); // $ExpectType "beep boop" + lowercase( 'abc' as string ); // $ExpectType string } // The compiler throws an error if the function is provided a value other than a string... diff --git a/uncapitalize/docs/types/index.d.ts b/uncapitalize/docs/types/index.d.ts index 0950b30c..3b7c488f 100644 --- a/uncapitalize/docs/types/index.d.ts +++ b/uncapitalize/docs/types/index.d.ts @@ -18,6 +18,8 @@ // TypeScript Version: 4.1 +type Uncapitalize = S extends `${infer F}${infer R}` ? `${Lowercase}${R}` : S; + /** * Uncapitalizes the first character of a string. * @@ -40,7 +42,7 @@ * var out = uncapitalize( 'Hidden Treasures' ); * // returns 'hidden Treasures' */ -declare function uncapitalize( str: string ): string; +declare function uncapitalize( str: S ): Uncapitalize; // EXPORTS // diff --git a/uncapitalize/docs/types/test.ts b/uncapitalize/docs/types/test.ts index 82ca1b0f..b35d326b 100644 --- a/uncapitalize/docs/types/test.ts +++ b/uncapitalize/docs/types/test.ts @@ -23,7 +23,11 @@ import uncapitalize = require( './index' ); // The function returns a string... { - uncapitalize( 'Last man standing' ); // $ExpectType string + uncapitalize( 'Last man standing' ); // $ExpectType "last man standing" + uncapitalize( 'Hello World!' ); // $ExpectType "hello World!" + uncapitalize( 'BeepBoop' ); // $ExpectType "beepBoop" + uncapitalize( 'A' ); // $ExpectType "a" + uncapitalize( 'foo' as string ); // $ExpectType string } // The compiler throws an error if the function is provided a value other than a string... diff --git a/uppercase/docs/types/index.d.ts b/uppercase/docs/types/index.d.ts index c8ea504b..6254b653 100644 --- a/uppercase/docs/types/index.d.ts +++ b/uppercase/docs/types/index.d.ts @@ -28,7 +28,7 @@ * var str = uppercase( 'bEEp' ); * // returns 'BEEP' */ -declare function uppercase( str: string ): string; +declare function uppercase( str: S ): Uppercase; // EXPORTS // diff --git a/uppercase/docs/types/test.ts b/uppercase/docs/types/test.ts index f9d11f96..2cadcfa6 100644 --- a/uppercase/docs/types/test.ts +++ b/uppercase/docs/types/test.ts @@ -23,7 +23,11 @@ import uppercase = require( './index' ); // The function returns a string... { - uppercase( 'Last man standing' ); // $ExpectType string + uppercase( 'Last man standing' ); // $ExpectType "LAST MAN STANDING" + uppercase( 'Hello World!' ); // $ExpectType "HELLO WORLD!" + uppercase( 'beep' ); // $ExpectType "BEEP" + uppercase( 'BOOP' ); // $ExpectType "BOOP" + uppercase( 'foo' as string ); // $ExpectType string } // The compiler throws an error if the function is provided a value other than a string...