Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

clean-accents

felipehimself81MIT0.0.1TypeScript support: included

A utility package for removing accents from string and checking if it has accents.

accent, accents, remove, diacritic, clean, formatting, umlaut, grave, circumflex, tilde, diaeresis, acute, c cedilha, string, til, macron, caron, cedilla, breve, ogonek, normalize, unicode, deaccent, strip accents, diacritical marks, text processing, latin letters

readme

clean-accents

Created by felipehimself License

Introduction

A light weight tiny package for cleaning accents from string.

Motivation

Node.js projects can often become overloaded with dependencies, which can lead to performance issues. This package aims to remain as lightweight as possible to help mitigate such problems.

Installation

npm install clean-accents
# or
yarn add clean-accents

Features

function argument return type description
cleanAccents.clean(str) string string returns a given string without accents
cleanAccents.has(str) string boolean returns true if it has accent or false if it doesn't

Usage

Cleaning accents

import { cleanAccents } from "clean-accents";
// or
const { cleanAccents } = require("clean-accents");


const str = `àáâãäåāăąèéêëēėęěìíîïīįòóôõöōőùúûüūůűýÿçćčďğģńñňřśšşťžźżÀÁÂÃÄÅĀĂĄÈÉÊËĒĖĘĚÌÍÎÏĪĮÒÓÔÕÖŌŐÙÚÛÜŪŮŰÝŸÇĆČĎĞĢŃÑŇŘŚŠŞŤŽŹŻ`

const stringWithNoaccent = cleanAccents.clean(str)

console.log(stringWithNoaccent)

// output
aaaaaaaaaeeeeeeeeiiiiiiooooooouuuuuuuyycccdggnnnrssstzzzAAAAAAAAAEEEEEEEEIIIIIIOOOOOOOUUUUUUUYYCCCDGGNNNRSSSTZZZ

Checking if has accents

import { cleanAccents } from "clean-accents";
// or
const { cleanAccents } = require("clean-accents");


const str = `àáâãäåāăąèéêëēėęěìíîïīįòóôõöōőùúûüūůűýÿçćčďğģńñňřśšşťžźżÀÁÂÃÄÅĀĂĄÈÉÊËĒĖĘĚÌÍÎÏĪĮÒÓÔÕÖŌŐÙÚÛÜŪŮŰÝŸÇĆČĎĞĢŃÑŇŘŚŠŞŤŽŹŻ`
const strHasAccent = cleanAccents.has(str)
console.log(strHasAccent) // outputs true

const str2 = 'some random string'
const string2HasAccent = cleanAccents.has(str2)
console.log(string2HasAcent) // outputs false