Skip to content

v1.3.0 - Organization, tree-shaking, normalization of functions names 🌳

Compare
Choose a tag to compare
@gustavoguichard gustavoguichard released this 11 Oct 13:37
· 99 commits to main since this release
a3e2eb8

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

New Contributors

Full Changelog: v1.2.0...v1.3.0