remove-accents
Advanced tools
Comparing version 0.3.0 to 0.4.0
140
index.js
@@ -1,9 +0,1 @@ | ||
var removeAccents = function(string) { | ||
for( accented in characterMap ) { | ||
string = string.replace( new RegExp(accented, "g"), characterMap[accented] ); | ||
} | ||
return string; | ||
} | ||
var characterMap = { | ||
@@ -18,5 +10,9 @@ "À": "A", | ||
"Ắ": "A", | ||
"Ẳ": "A", | ||
"Ẵ": "A", | ||
"Ặ": "A", | ||
"Æ": "AE", | ||
"Ầ": "A", | ||
"Ằ": "A", | ||
"Ȃ": "A", | ||
"Ç": "C", | ||
@@ -32,2 +28,4 @@ "Ḉ": "C", | ||
"Ḕ": "E", | ||
"Ḝ": "E", | ||
"Ȇ": "E", | ||
"Ì": "I", | ||
@@ -38,2 +36,3 @@ "Í": "I", | ||
"Ḯ": "I", | ||
"Ȋ": "I", | ||
"Ð": "D", | ||
@@ -50,2 +49,3 @@ "Ñ": "N", | ||
"Ṓ": "O", | ||
"Ȏ": "O", | ||
"Ù": "U", | ||
@@ -65,5 +65,9 @@ "Ú": "U", | ||
"ắ": "a", | ||
"ẳ": "a", | ||
"ẵ": "a", | ||
"ặ": "a", | ||
"æ": "ae", | ||
"ầ": "a", | ||
"ằ": "a", | ||
"ȃ": "a", | ||
"ç": "c", | ||
@@ -79,2 +83,4 @@ "ḉ": "c", | ||
"ḕ": "e", | ||
"ḝ": "e", | ||
"ȇ": "e", | ||
"ì": "i", | ||
@@ -85,2 +91,3 @@ "í": "i", | ||
"ḯ": "i", | ||
"ȋ": "i", | ||
"ð": "d", | ||
@@ -97,2 +104,3 @@ "ñ": "n", | ||
"ṓ": "o", | ||
"ȏ": "o", | ||
"ù": "u", | ||
@@ -118,2 +126,4 @@ "ú": "u", | ||
"č": "c", | ||
"C̆": "C", | ||
"c̆": "c", | ||
"Ď": "D", | ||
@@ -147,2 +157,4 @@ "ď": "d", | ||
"ħ": "h", | ||
"Ḫ": "H", | ||
"ḫ": "h", | ||
"Ĩ": "I", | ||
@@ -166,2 +178,4 @@ "ĩ": "i", | ||
"ḱ": "k", | ||
"K̆": "K", | ||
"k̆": "k", | ||
"Ĺ": "L", | ||
@@ -179,2 +193,4 @@ "ĺ": "l", | ||
"ḿ": "m", | ||
"M̆": "M", | ||
"m̆": "m", | ||
"Ń": "N", | ||
@@ -187,2 +203,4 @@ "ń": "n", | ||
"ʼn": "n", | ||
"N̆": "N", | ||
"n̆": "n", | ||
"Ō": "O", | ||
@@ -196,2 +214,4 @@ "ō": "o", | ||
"œ": "oe", | ||
"P̆": "P", | ||
"p̆": "p", | ||
"Ŕ": "R", | ||
@@ -203,2 +223,6 @@ "ŕ": "r", | ||
"ř": "r", | ||
"R̆": "R", | ||
"r̆": "r", | ||
"Ȓ": "R", | ||
"ȓ": "r", | ||
"Ś": "S", | ||
@@ -209,2 +233,4 @@ "ś": "s", | ||
"Ş": "S", | ||
"Ș": "S", | ||
"ș": "s", | ||
"ş": "s", | ||
@@ -215,2 +241,4 @@ "Š": "S", | ||
"ţ": "t", | ||
"ț": "t", | ||
"Ț": "T", | ||
"Ť": "T", | ||
@@ -220,2 +248,4 @@ "ť": "t", | ||
"ŧ": "t", | ||
"T̆": "T", | ||
"t̆": "t", | ||
"Ũ": "U", | ||
@@ -233,2 +263,6 @@ "ũ": "u", | ||
"ų": "u", | ||
"Ȗ": "U", | ||
"ȗ": "u", | ||
"V̆": "V", | ||
"v̆": "v", | ||
"Ŵ": "W", | ||
@@ -238,5 +272,9 @@ "ŵ": "w", | ||
"ẃ": "w", | ||
"X̆": "X", | ||
"x̆": "x", | ||
"Ŷ": "Y", | ||
"ŷ": "y", | ||
"Ÿ": "Y", | ||
"Y̆": "Y", | ||
"y̆": "y", | ||
"Ź": "Z", | ||
@@ -322,4 +360,88 @@ "ź": "z", | ||
"ȕ": "u", | ||
"B̌": "B", | ||
"b̌": "b", | ||
"Č̣": "C", | ||
"č̣": "c", | ||
"Ê̌": "E", | ||
"ê̌": "e", | ||
"F̌": "F", | ||
"f̌": "f", | ||
"Ǧ": "G", | ||
"ǧ": "g", | ||
"Ȟ": "H", | ||
"ȟ": "h", | ||
"J̌": "J", | ||
"ǰ": "j", | ||
"Ǩ": "K", | ||
"ǩ": "k", | ||
"M̌": "M", | ||
"m̌": "m", | ||
"P̌": "P", | ||
"p̌": "p", | ||
"Q̌": "Q", | ||
"q̌": "q", | ||
"Ř̩": "R", | ||
"ř̩": "r", | ||
"Ṧ": "S", | ||
"ṧ": "s", | ||
"V̌": "V", | ||
"v̌": "v", | ||
"W̌": "W", | ||
"w̌": "w", | ||
"X̌": "X", | ||
"x̌": "x", | ||
"Y̌": "Y", | ||
"y̌": "y", | ||
"A̧": "A", | ||
"a̧": "a", | ||
"B̧": "B", | ||
"b̧": "b", | ||
"Ḑ": "D", | ||
"ḑ": "d", | ||
"Ȩ": "E", | ||
"ȩ": "e", | ||
"Ɛ̧": "E", | ||
"ɛ̧": "e", | ||
"Ḩ": "H", | ||
"ḩ": "h", | ||
"I̧": "I", | ||
"i̧": "i", | ||
"Ɨ̧": "I", | ||
"ɨ̧": "i", | ||
"M̧": "M", | ||
"m̧": "m", | ||
"O̧": "O", | ||
"o̧": "o", | ||
"Q̧": "Q", | ||
"q̧": "q", | ||
"U̧": "U", | ||
"u̧": "u", | ||
"X̧": "X", | ||
"x̧": "x", | ||
"Z̧": "Z", | ||
"z̧": "z", | ||
} | ||
module.exports = removeAccents; | ||
var accentsRegex; | ||
function buildRegExp() { | ||
var accentList = []; | ||
for( accented in characterMap ) { | ||
accentList.push(accented); | ||
} | ||
accentsRegex = new RegExp('(' + accentList.join('|') + ')', 'g'); | ||
} | ||
buildRegExp(); | ||
var removeAccents = function(string) { | ||
string = string.replace(accentsRegex, function(match) { | ||
return characterMap[match]; | ||
}) | ||
return string; | ||
} | ||
module.exports = removeAccents; |
{ | ||
"name": "remove-accents", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Converting the accented characters to their corresponding non-accented ASCII characters.", | ||
@@ -38,3 +38,4 @@ "main": "index.js", | ||
"contributors": [ | ||
"tyxla" | ||
"tyxla", | ||
"andreialecu" | ||
], | ||
@@ -45,3 +46,4 @@ "bugs": { | ||
"homepage": "https://github.com/tyxla/remove-accents", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"typings": "./index.d.ts" | ||
} |
@@ -5,5 +5,5 @@ var tape = require('tape'); | ||
tape('remove accents from string', function(t) { | ||
var input = 'ÀÁÂÃÄÅẤẮÆẦẰÇḈÈÉÊËẾḖỀḔÌÍÎÏḮÐÑÒÓÔÕÖØỐṌṒÙÚÛÜÝßàáâãäåấắæầằçḉèéêëếḗềḕìíîïḯñòóôõöøốṍṓùúûüýÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģǴǵĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķḰḱĹĺĻļĽľĿŀŁłḾḿŃńŅņŇňʼnŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵẂẃŶŷŸŹźŻżŽžſƒƠơƯưǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜỨứṸṹǺǻǼǽǾǿðÞþṔṕṤṥX́x́ЃѓЌќA̋a̋E̋e̋I̋i̋ǸǹỒồṐṑỪừẀẁỲỳȀȁȄȅȈȉȌȍȐȑȔȕ'; | ||
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̧'; | ||
var output = removeAccents(input); | ||
var expected = 'AAAAAAAAAEAACCEEEEEEEEIIIIIDNOOOOOOOOOUUUUYsaaaaaaaaaeaacceeeeeeeeiiiiinooooooooouuuuyyAaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGgGgGgGgHhHhIiIiIiIiIiIJijJjKkKkLlLlLlLlllMmNnNnNnnOoOoOoOEoeRrRrRrSsSsSsSsTtTtTtUuUuUuUuUuUuWwWwYyYZzZzZzsfOoUuAaIiOoUuUuUuUuUuUuUuAaAEaeOodTHthPpSsXxГгКкAaEeIiNnOoOoUuWwYyAaEeIiOoRrUu'; | ||
var expected = 'AAAAAAAAAEAACCEEEEEEEEIIIIIDNOOOOOOOOOUUUUYsaaaaaaaaaeaacceeeeeeeeiiiiinooooooooouuuuyyAaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGgGgGgGgHhHhIiIiIiIiIiIJijJjKkKkLlLlLlLlllMmNnNnNnnOoOoOoOEoeRrRrRrSsSsSsSsTtTtTtUuUuUuUuUuUuWwWwYyYZzZzZzsfOoUuAaIiOoUuUuUuUuUuUuUuAaAEaeOodTHthPpSsXxГгКкAaEeIiNnOoOoUuWwYyAaEeIiOoRrUuAAAEaaaeCcHhKkMmNnPpRrTtVvXxYyAEIOaeioRrUustSTBbFfGgHhJjKkMmPpQqSsVvWwXxYyAaBbDdEeEeHhIiIiMmOoQqUuXxZz'; | ||
@@ -22,2 +22,2 @@ t.same( output, expected ); | ||
t.end(); | ||
}); | ||
}); |
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
11316
8
442