v1.3.0 - Organization, tree-shaking, normalization of functions names 🌳
What's changed
🎄 Tree-shaking
This release brings a lot of internal architecture changes to make tree-shaking as easy as possible for the bundlers.
With efforts from all the core contributors we were able to optimize the output of the package and re-organize the whole project to achieve that.
🛡️ 100% coverage
Now every line of string-ts
is covered with tests... and we mean type tests too!
🎁 New methods
3 new methods were added:
🔄 reverse
You can now reverse strings at both runtime and type-level. by @mjuksel
👨👦 upperCase
and lowerCase
Attention, these new methods are different than the native toLowerCase
and toUpperCase
as the existing ones (which already exist in this library) will only change the case of letters in a string and the new methods work similar to the other casing functions, such as camelCase
which will strip separators, split words and join them. So, think of lowerCase
as toLowerCase(delimiterCase("Hello-World...", ' ')) => "hello world"
.
In fact that is the exact implementation of the new lowerCase
at both runtime and type-level.
We are not adding the type utilities for these 2 new methods as they would cause a lot of confusion with the default Lowercase
and Uppercase
from TS. It is easy to build that type utility though:
import { type DelimiterCase } from "string-ts"
type MyLC<T extends string> = Lowercase<DelimiterCase<T, " ">>
type MyUC<T extends string> = Uppercase<DelimiterCase<T, " ">>
👴🏼 Deprecations: Renaming and deprecating old casing utilities
As you could see in the section above, there's a difference in functionality between the native String.prototype.toLowerCase
(which maps to our toLowerCase
) and our own lowerCase
method. That is because most of the casing utilities will rely on the words
function splitting the words of a string, removing the separators and joining the characters in some fashion.
For that reason we decided to rename that second group by removing the to
prefix from those functions. We also deprecated the methods with old names so you want to rename those methods in your project to be prepared for string-ts@v2
:
// Prior to string-ts v1.3
import { toCamelCase, toDelimiterCase, toLowerCase } from 'string-ts'
const data = "Hello-World..."
const a = toCamelCase(data) // "helloWorld"
const b = toLowerCase(data) // "hello-world..."
const c = toDelimiterCase(data, '@') // "Hello@World"
const d = toLowerCase(toDelimiterCase(data, ' ')) // "hello world"
// From string-ts v1.3+
import { camelCase, delimiterCase, toLowerCase, lowerCase } from 'string-ts'
const data = "Hello-World..."
const a = camelCase(data) // "helloWorld"
const b = toLowerCase(data) // "hello-world..."
const c = delimiterCase(data, '@') // "Hello@World"
const d = lowerCase(data, ' ') // "hello world"
⬇️ PRs
- test: internals by @jly36963 in #50
- feat: add lowerCase and upperCase by @jly36963 in #47
- README update by @p9f in #53
- ci: compute code coverage in the CI by @p9f in #57
- chore: Adds contributors to the README by @gustavoguichard in #58
- doc: Update README.md by @p9f in #73
- feat: tree shake by @jly36963 in #52
- refactor: split files by @jly36963 in #56
- test: Improve coverage by @gustavoguichard in #75
- feat: Rename casing functions and deprecate old ones by @gustavoguichard in #76
- test: math by @jly36963 in #77
- feat: add a reverse method by @mjuksel in #74
New Contributors
Full Changelog: v1.2.0...v1.3.0