remove-accents
Advanced tools
Comparing version 0.4.4 to 0.5.0
59
index.js
@@ -17,2 +17,7 @@ var characterMap = { | ||
"Ȃ": "A", | ||
"Ả": "A", | ||
"Ạ": "A", | ||
"Ẩ": "A", | ||
"Ẫ": "A", | ||
"Ậ": "A", | ||
"Ç": "C", | ||
@@ -30,2 +35,8 @@ "Ḉ": "C", | ||
"Ȇ": "E", | ||
"Ẻ": "E", | ||
"Ẽ": "E", | ||
"Ẹ": "E", | ||
"Ể": "E", | ||
"Ễ": "E", | ||
"Ệ": "E", | ||
"Ì": "I", | ||
@@ -37,2 +48,4 @@ "Í": "I", | ||
"Ȋ": "I", | ||
"Ỉ": "I", | ||
"Ị": "I", | ||
"Ð": "D", | ||
@@ -50,2 +63,12 @@ "Ñ": "N", | ||
"Ȏ": "O", | ||
"Ỏ": "O", | ||
"Ọ": "O", | ||
"Ổ": "O", | ||
"Ỗ": "O", | ||
"Ộ": "O", | ||
"Ờ": "O", | ||
"Ở": "O", | ||
"Ỡ": "O", | ||
"Ớ": "O", | ||
"Ợ": "O", | ||
"Ù": "U", | ||
@@ -55,2 +78,7 @@ "Ú": "U", | ||
"Ü": "U", | ||
"Ủ": "U", | ||
"Ụ": "U", | ||
"Ử": "U", | ||
"Ữ": "U", | ||
"Ự": "U", | ||
"Ý": "Y", | ||
@@ -72,2 +100,7 @@ "à": "a", | ||
"ȃ": "a", | ||
"ả": "a", | ||
"ạ": "a", | ||
"ẩ": "a", | ||
"ẫ": "a", | ||
"ậ": "a", | ||
"ç": "c", | ||
@@ -85,2 +118,8 @@ "ḉ": "c", | ||
"ȇ": "e", | ||
"ẻ": "e", | ||
"ẽ": "e", | ||
"ẹ": "e", | ||
"ể": "e", | ||
"ễ": "e", | ||
"ệ": "e", | ||
"ì": "i", | ||
@@ -92,2 +131,4 @@ "í": "i", | ||
"ȋ": "i", | ||
"ỉ": "i", | ||
"ị": "i", | ||
"ð": "d", | ||
@@ -105,2 +146,12 @@ "ñ": "n", | ||
"ȏ": "o", | ||
"ỏ": "o", | ||
"ọ": "o", | ||
"ổ": "o", | ||
"ỗ": "o", | ||
"ộ": "o", | ||
"ờ": "o", | ||
"ở": "o", | ||
"ỡ": "o", | ||
"ớ": "o", | ||
"ợ": "o", | ||
"ù": "u", | ||
@@ -110,2 +161,7 @@ "ú": "u", | ||
"ü": "u", | ||
"ủ": "u", | ||
"ụ": "u", | ||
"ử": "u", | ||
"ữ": "u", | ||
"ự": "u", | ||
"ý": "y", | ||
@@ -232,3 +288,2 @@ "ÿ": "y", | ||
"š": "s", | ||
"ß": "ss", | ||
"Ţ": "T", | ||
@@ -427,3 +482,3 @@ "ţ": "t", | ||
var removeAccents = function(string) { | ||
var removeAccents = function(string) { | ||
return string.replace(allAccents, matcher); | ||
@@ -430,0 +485,0 @@ }; |
{ | ||
"name": "remove-accents", | ||
"version": "0.4.4", | ||
"version": "0.5.0", | ||
"description": "Converting the accented characters to their corresponding non-accented ASCII characters.", | ||
@@ -8,6 +8,6 @@ "main": "index.js", | ||
"devDependencies": { | ||
"tape": "^4.2.2" | ||
"jest": "^29.6.2" | ||
}, | ||
"scripts": { | ||
"test": "tape test.js" | ||
"test": "jest -c=jest.config.js" | ||
}, | ||
@@ -44,3 +44,5 @@ "repository": { | ||
"jsnajdr", | ||
"Alorel" | ||
"Alorel", | ||
"michaelkirk", | ||
"huy-vuong" | ||
], | ||
@@ -47,0 +49,0 @@ "bugs": { |
@@ -9,3 +9,2 @@ # remove-accents | ||
[![Build Status](https://travis-ci.org/tyxla/remove-accents.svg)](https://travis-ci.org/tyxla/remove-accents) | ||
[![Unit tests](https://github.com/tyxla/remove-accents/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/tyxla/remove-accents/actions/workflows/unit-tests.yml) | ||
@@ -20,5 +19,13 @@ | ||
``` js | ||
import removeAccents from 'remove-accents'; | ||
removeAccents(inputString) | ||
``` | ||
Alternatively, you could use the CommonJS syntax to import it: | ||
``` js | ||
const removeAccents = require('remove-accents'); | ||
``` | ||
#### inputString | ||
@@ -33,4 +40,4 @@ | ||
``` js | ||
var input = 'ÀÁÂÃÄÅ'; | ||
var output = removeAccents(input); | ||
const input = 'ÀÁÂÃÄÅ'; | ||
const output = removeAccents(input); | ||
@@ -49,6 +56,6 @@ console.log(output); // AAAAAA | ||
``` js | ||
var accents = require('remove-accents'); | ||
import removeAccents from 'remove-accents'; | ||
console.log(accents.has('ÀÁÂÃÄÅ')); // true | ||
console.log(accents.has('ABC')); // false | ||
console.log(removeAccents.has('ÀÁÂÃÄÅ')); // true | ||
console.log(removeAccents.has('ABC')); // false | ||
``` | ||
@@ -61,5 +68,5 @@ | ||
``` js | ||
var accents = require('remove-accents'); | ||
import removeAccents from 'remove-accents'; | ||
console.log(accents.remove('ÀÁÂÃÄÅ')); // AAAAAA | ||
console.log(removeAccents.remove('ÀÁÂÃÄÅ')); // AAAAAA | ||
``` | ||
@@ -66,0 +73,0 @@ |
61
test.js
@@ -1,50 +0,47 @@ | ||
var tape = require('tape'); | ||
var removeAccents = require('./'); | ||
var removeAccents = require("./"); | ||
tape('remove accents from string', function(t) { | ||
var input = 'ÀÁÂÃÄÅẤẮÆẦẰÇḈÈÉÊËẾḖỀḔÌÍÎÏḮÐÑÒÓÔÕÖØỐṌṒÙÚÛÜÝàáâãäåấắæầằçḉèéêëếḗềḕìíîïḯñòóôõöøốṍṓùúûüýÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģǴǵĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķḰḱĹĺĻļĽľĿŀŁłḾḿŃńŅņŇňʼnŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵẂẃŶŷŸŹźŻżŽžſƒƠơƯưǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜỨứṸṹǺǻǼǽǾǿðÞþṔṕṤṥX́x́ЃѓЌќA̋a̋E̋e̋I̋i̋ǸǹỒồṐṑỪừẀẁỲỳȀȁȄȅȈȉȌȍȐȑȔȕẲẴẶḜẳẵặḝC̆c̆ḪḫK̆k̆M̆m̆N̆n̆P̆p̆R̆r̆T̆t̆V̆v̆X̆x̆Y̆y̆ȂȆȊȎȃȇȋȏȒȓȖȗșțȘȚB̌b̌F̌f̌ǦǧȞȟJ̌ǰǨǩM̌m̌P̌p̌Q̌q̌ṦṧV̌v̌W̌w̌X̌x̌Y̌y̌A̧a̧B̧b̧ḐḑȨȩƐ̧ɛ̧ḨḩI̧i̧Ɨ̧ɨ̧M̧m̧O̧o̧Q̧q̧U̧u̧X̧x̧Z̧z̧ß'; | ||
test("remove accents from string", function () { | ||
var input = | ||
"ÀÁÂÃÄÅẤẮÆẦẰẢẠẨẪẬÇḈÈÉÊËẾḖỀḔẺẼẸỂỄỆÌÍÎÏḮỈỊÐÑÒÓÔÕÖØỐṌṒỎỌỔỖỘỜỞỠỚỢÙÚÛÜỦỤỬỮỰÝàáâãäåấắæầằảạẩẫậçḉèéêëếḗềḕẻẽẹểễệìíîïḯỉịñòóôõöøốṍṓỏọổỗộờởỡớợùúûüủụửữựýÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģǴǵĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķḰḱĹĺĻļĽľĿŀŁłḾḿŃńŅņŇňʼnŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵẂẃŶŷŸŹźŻżŽžſƒƠơƯưǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜỨứṸṹǺǻǼǽǾǿðÞþṔṕṤṥX́x́ЃѓЌќA̋a̋E̋e̋I̋i̋ǸǹỒồṐṑỪừẀẁỲỳȀȁȄȅȈȉȌȍȐȑȔȕẲẴẶḜẳẵặḝC̆c̆ḪḫK̆k̆M̆m̆N̆n̆P̆p̆R̆r̆T̆t̆V̆v̆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rUustSTBbFfGgHhJjKkMmPpQqSsVvWwXxYyAaBbDdEeEeHhIiIiMmOoQqUuXxZz"; | ||
t.same( output, expected ); | ||
t.end(); | ||
expect(output).toBe(expected); | ||
}); | ||
tape('remove cyrillic accents from string', function(t) { | ||
var input = 'ЁёЙй'; | ||
test("remove cyrillic accents from string", function () { | ||
var input = "ЁёЙй"; | ||
var output = removeAccents(input); | ||
var expected = 'ЕеИи'; | ||
var expected = "ЕеИи"; | ||
t.same( output, expected ); | ||
t.end(); | ||
expect(output).toBe(expected); | ||
}); | ||
tape('do not modify non-accented strings', function(t) { | ||
var input = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789.,:;~`!@#$%^&*()-_=+[]{}\'"|\\<>?/eEиИ'; | ||
test("do not modify non-accented strings", function () { | ||
var input = | ||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789.,:;~`!@#$%^&*()-_=+[]{}'\"|\\<>?/eEиИ"; | ||
var output = removeAccents(input); | ||
t.same( output, input ); | ||
t.end(); | ||
expect(output).toBe(input); | ||
}); | ||
tape('.has can detect accents', function(t) { | ||
t.equal(removeAccents.has('À'), true); | ||
t.equal(removeAccents.has('Löwe'), true); | ||
test(".has can detect accents", function () { | ||
expect(removeAccents.has("À")).toBe(true); | ||
expect(removeAccents.has("Löwe")).toBe(true); | ||
t.equal(removeAccents.has('A'), false); | ||
t.equal(removeAccents.has('Panther'), false); | ||
t.end(); | ||
expect(removeAccents.has("A")).toBe(false); | ||
expect(removeAccents.has("Panther")).toBe(false); | ||
}); | ||
tape('.remove method', function(t) { | ||
t.same(removeAccents.toString(), removeAccents.remove.toString()); | ||
test(".remove method", function () { | ||
expect(removeAccents.toString()).toBe(removeAccents.remove.toString()); | ||
t.same(removeAccents.remove('cat'), 'cat'); | ||
t.same(removeAccents.remove('Pokémon'), 'Pokemon'); | ||
t.same(removeAccents.remove('Straße'), 'Strasse'); | ||
t.end(); | ||
expect(removeAccents.remove("cat")).toBe("cat"); | ||
expect(removeAccents.remove("Pokémon")).toBe("Pokemon"); | ||
}); | ||
// See https://github.com/tyxla/remove-accents/issues/12 | ||
test("ß is not accented", function () { | ||
expect(removeAccents.remove("Straße")).toBe("Straße"); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
High entropy strings
Supply chain riskContains high entropy strings. This could be a sign of encrypted data, leaked secrets or obfuscated code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
High entropy strings
Supply chain riskContains high entropy strings. This could be a sign of encrypted data, leaked secrets or obfuscated code.
Found 1 instance in 1 package
13380
528
72