File tree Expand file tree Collapse file tree 5 files changed +220
-192
lines changed Expand file tree Collapse file tree 5 files changed +220
-192
lines changed Original file line number Diff line number Diff line change
1
+ coverage /
2
+ nlcst-normalize.js
3
+ nlcst-normalize.min.js
Original file line number Diff line number Diff line change 1
- 'use strict' ;
1
+ 'use strict'
2
2
3
- var toString = require ( 'nlcst-to-string' ) ;
3
+ var toString = require ( 'nlcst-to-string' )
4
4
5
- module . exports = normalize ;
5
+ module . exports = normalize
6
6
7
- var ALL = / [ - ' ] / g;
8
- var DASH = / - / g;
9
- var APOSTROPHE = / ’ / g;
10
- var QUOTE = '\'' ;
11
- var EMPTY = '' ;
7
+ var ALL = / [ - ' ] / g
8
+ var DASH = / - / g
9
+ var APOSTROPHE = / ’ / g
10
+ var QUOTE = "'"
11
+ var EMPTY = ''
12
12
13
13
/* Normalize `value`. */
14
14
function normalize ( value , options ) {
15
- var settings = options || { } ;
16
- var allowApostrophes = settings . allowApostrophes ;
17
- var allowDashes = settings . allowDashes ;
15
+ var settings = options || { }
16
+ var allowApostrophes = settings . allowApostrophes
17
+ var allowDashes = settings . allowDashes
18
18
var result = ( typeof value === 'string' ? value : toString ( value ) )
19
19
. toLowerCase ( )
20
- . replace ( APOSTROPHE , QUOTE ) ;
20
+ . replace ( APOSTROPHE , QUOTE )
21
21
22
22
if ( allowApostrophes && allowDashes ) {
23
- return result ;
23
+ return result
24
24
}
25
25
26
26
if ( allowApostrophes ) {
27
- return result . replace ( DASH , EMPTY ) ;
27
+ return result . replace ( DASH , EMPTY )
28
28
}
29
29
30
30
if ( allowDashes ) {
31
- return result . replace ( QUOTE , EMPTY ) ;
31
+ return result . replace ( QUOTE , EMPTY )
32
32
}
33
33
34
- return result . replace ( ALL , EMPTY ) ;
34
+ return result . replace ( ALL , EMPTY )
35
35
}
Original file line number Diff line number Diff line change 22
22
"browserify" : " ^16.0.0" ,
23
23
"esmangle" : " ^1.0.0" ,
24
24
"nyc" : " ^11.0.0" ,
25
+ "prettier" : " ^1.12.1" ,
25
26
"remark-cli" : " ^5.0.0" ,
26
27
"remark-preset-wooorm" : " ^4.0.0" ,
27
28
"tape" : " ^4.0.0" ,
28
29
"xo" : " ^0.20.0"
29
30
},
30
31
"scripts" : {
31
- "build-md " : " remark . --quiet --frail --output " ,
32
+ "format " : " remark . -qfo && prettier --write '**/*.js' && xo --fix " ,
32
33
"build-bundle" : " browserify index.js --bare -s nlcstNormalize > nlcst-normalize.js" ,
33
34
"build-mangle" : " esmangle nlcst-normalize.js > nlcst-normalize.min.js" ,
34
- "build" : " npm run build-md && npm run build-bundle && npm run build-mangle" ,
35
- "lint" : " xo" ,
36
- "test-api" : " node test.js" ,
35
+ "build" : " npm run build-bundle && npm run build-mangle" ,
36
+ "test-api" : " node test" ,
37
37
"test-coverage" : " nyc --reporter lcov tape test.js" ,
38
- "test" : " npm run build && npm run lint && npm run test-coverage"
38
+ "test" : " npm run format && npm run build && npm run test-coverage"
39
39
},
40
40
"nyc" : {
41
41
"check-coverage" : true ,
42
42
"lines" : 100 ,
43
43
"functions" : 100 ,
44
44
"branches" : 100
45
45
},
46
+ "prettier" : {
47
+ "tabWidth" : 2 ,
48
+ "useTabs" : false ,
49
+ "singleQuote" : true ,
50
+ "bracketSpacing" : false ,
51
+ "semi" : false ,
52
+ "trailingComma" : " none"
53
+ },
46
54
"xo" : {
47
- "space " : true ,
55
+ "prettier " : true ,
48
56
"esnext" : false ,
49
57
"rules" : {
50
58
"guard-for-in" : " off" ,
Original file line number Diff line number Diff line change @@ -13,13 +13,13 @@ npm install nlcst-normalize
13
13
## Usage
14
14
15
15
``` js
16
- var normalize = require (' nlcst-normalize' );
16
+ var normalize = require (' nlcst-normalize' )
17
17
18
- normalize (' Don\' t ' ); // => 'dont'
19
- normalize (' Don’t' ); // => 'dont'
20
- normalize (' Don’t' , {allowApostrophes: true }); // => 'don\'t'
21
- normalize (' Block-level' ); // => 'blocklevel'
22
- normalize (' Block-level' , {allowDashes: true }); // => 'block-level'
18
+ normalize (" Don't " ) // => 'dont'
19
+ normalize (' Don’t' ) // => 'dont'
20
+ normalize (' Don’t' , {allowApostrophes: true }) // => 'don\'t'
21
+ normalize (' Block-level' ) // => 'blocklevel'
22
+ normalize (' Block-level' , {allowDashes: true }) // => 'block-level'
23
23
24
24
normalize ({
25
25
type: ' WordNode' ,
@@ -28,7 +28,7 @@ normalize({
28
28
{type: ' PunctuationNode' , value: ' -' },
29
29
{type: ' TextNode' , value: ' level' }
30
30
]
31
- }); // => 'blocklevel'
31
+ }) // => 'blocklevel'
32
32
```
33
33
34
34
## API
You can’t perform that action at this time.
0 commit comments