github radashi-org/radashi v12.8.0

latest releases: v12.9.0, v12.8.1
9 hours ago

New Functions

Add deburr function → PR #449

Normalize accented Latin text into plain ASCII-friendly strings. deburr strips combining marks and expands common extended Latin letters and ligatures, which is useful before slugging, searching, or comparing user-facing text.

  • Removes Unicode combining marks after NFD normalization
  • Handles common Latin characters that do not decompose cleanly, like Æ, ø, ß, and Ł
  • Leaves other characters untouched, so it stays focused on transliterating Latin text
import * as _ from 'radashi'

_.deburr('Crème Brûlée') // => 'Creme Brulee'
_.deburr('Ærøskøbing') // => 'Aeroskobing'
_.deburr('Straße') // => 'Strasse'

Docs / Source / Tests

Add getErrorMessage function → PR #466

Turn unknown caught values into a readable message that is safe to display or log. getErrorMessage returns messages from Error instances and non-empty strings, then falls back to "Unknown error." for empty or unsupported values.

  • Works with Error subclasses such as TypeError
  • Accepts string throws without wrapping them first
  • Keeps arbitrary objects from being treated as errors just because they have a message property
import * as _ from 'radashi'

try {
  throw new Error('Request failed')
} catch (error) {
  _.getErrorMessage(error) // => 'Request failed'
}

_.getErrorMessage('Request failed') // => 'Request failed'
_.getErrorMessage(null) // => 'Unknown error.'

Docs / Source / Tests

Don't miss a new radashi release

NewReleases is sending notifications on new releases.