This repository was archived by the owner on Feb 20, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ import timeDifference from './timeDifference'
5555import isPrime from './is-prime'
5656import swapElements from './swapElements'
5757import reverse from './reverse'
58+ import removeAccents from './remove-accents'
5859
5960export {
6061 isOdd ,
@@ -114,4 +115,5 @@ export {
114115 isPrime ,
115116 swapElements ,
116117 reverse ,
118+ removeAccents ,
117119}
Original file line number Diff line number Diff line change 1+ export default removeAccents
2+
3+ /**
4+ * Original Source: https://stackoverflow.com/a/37511463/2002514
5+ *
6+ * This method will remove accentuated characters from a string.
7+ *
8+ * @param {String } str - The string to remove accentuated characters from.
9+ * @return {String } - The given string without accentuated characters.
10+ */
11+ function removeAccents ( str ) {
12+ return str . normalize ( 'NFD' ) . replace ( / [ \u0300 - \u036f ] / g, '' )
13+ }
Original file line number Diff line number Diff line change 1+ import test from 'ava'
2+ import { removeAccents } from '../src'
3+
4+ test ( 'remove accentuated characters' , t => {
5+ const original = 'Español: Comí Crème Brulée el sábado'
6+ const expected = 'Espanol: Comi Creme Brulee el sabado'
7+ const actual = removeAccents ( original )
8+ t . deepEqual ( actual , expected )
9+ } )
You can’t perform that action at this time.
0 commit comments