Skip to content

Commit f6f7471

Browse files
committed
Refactor to improve bundle size
1 parent 8edd612 commit f6f7471

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

index.js

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,18 @@ var toString = require('nlcst-to-string')
44

55
module.exports = normalize
66

7-
var all = /[-']/g
8-
var dash = /-/g
9-
var apostrophe = //g
10-
var singleQuote = /'/g
11-
12-
function normalize(value, options) {
13-
var settings = options || {}
14-
var allowApostrophes = settings.allowApostrophes
15-
var allowDashes = settings.allowDashes
16-
var result = (typeof value === 'string' ? value : toString(value))
7+
function normalize(node, options) {
8+
var value = (typeof node === 'string' ? node : toString(node))
179
.toLowerCase()
18-
.replace(apostrophe, "'")
19-
20-
if (allowApostrophes && allowDashes) {
21-
return result
22-
}
10+
.replace(//g, "'")
2311

24-
if (allowApostrophes) {
25-
return result.replace(dash, '')
12+
if (!options || !options.allowDashes) {
13+
value = value.replace(/-/g, '')
2614
}
2715

28-
if (allowDashes) {
29-
return result.replace(singleQuote, '')
16+
if (!options || !options.allowApostrophes) {
17+
value = value.replace(/'/g, '')
3018
}
3119

32-
return result.replace(all, '')
20+
return value
3321
}

0 commit comments

Comments
 (0)