This repository was archived by the owner on Feb 20, 2019. It is now read-only.
File tree 3 files changed +24
-0
lines changed
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'
55
55
import isPrime from './is-prime'
56
56
import swapElements from './swapElements'
57
57
import reverse from './reverse'
58
+ import removeAccents from './remove-accents'
58
59
59
60
export {
60
61
isOdd ,
@@ -114,4 +115,5 @@ export {
114
115
isPrime ,
115
116
swapElements ,
116
117
reverse ,
118
+ removeAccents ,
117
119
}
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