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'
22
3- var toString = require ( 'nlcst-to-string' ) ;
3+ var toString = require ( 'nlcst-to-string' )
44
5- module . exports = normalize ;
5+ module . exports = normalize
66
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 = ''
1212
1313/* Normalize `value`. */
1414function 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
1818 var result = ( typeof value === 'string' ? value : toString ( value ) )
1919 . toLowerCase ( )
20- . replace ( APOSTROPHE , QUOTE ) ;
20+ . replace ( APOSTROPHE , QUOTE )
2121
2222 if ( allowApostrophes && allowDashes ) {
23- return result ;
23+ return result
2424 }
2525
2626 if ( allowApostrophes ) {
27- return result . replace ( DASH , EMPTY ) ;
27+ return result . replace ( DASH , EMPTY )
2828 }
2929
3030 if ( allowDashes ) {
31- return result . replace ( QUOTE , EMPTY ) ;
31+ return result . replace ( QUOTE , EMPTY )
3232 }
3333
34- return result . replace ( ALL , EMPTY ) ;
34+ return result . replace ( ALL , EMPTY )
3535}
Original file line number Diff line number Diff line change 2222 "browserify" : " ^16.0.0" ,
2323 "esmangle" : " ^1.0.0" ,
2424 "nyc" : " ^11.0.0" ,
25+ "prettier" : " ^1.12.1" ,
2526 "remark-cli" : " ^5.0.0" ,
2627 "remark-preset-wooorm" : " ^4.0.0" ,
2728 "tape" : " ^4.0.0" ,
2829 "xo" : " ^0.20.0"
2930 },
3031 "scripts" : {
31- "build-md " : " remark . --quiet --frail --output " ,
32+ "format " : " remark . -qfo && prettier --write '**/*.js' && xo --fix " ,
3233 "build-bundle" : " browserify index.js --bare -s nlcstNormalize > nlcst-normalize.js" ,
3334 "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" ,
3737 "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"
3939 },
4040 "nyc" : {
4141 "check-coverage" : true ,
4242 "lines" : 100 ,
4343 "functions" : 100 ,
4444 "branches" : 100
4545 },
46+ "prettier" : {
47+ "tabWidth" : 2 ,
48+ "useTabs" : false ,
49+ "singleQuote" : true ,
50+ "bracketSpacing" : false ,
51+ "semi" : false ,
52+ "trailingComma" : " none"
53+ },
4654 "xo" : {
47- "space " : true ,
55+ "prettier " : true ,
4856 "esnext" : false ,
4957 "rules" : {
5058 "guard-for-in" : " off" ,
Original file line number Diff line number Diff line change @@ -13,13 +13,13 @@ npm install nlcst-normalize
1313## Usage
1414
1515``` js
16- var normalize = require (' nlcst-normalize' );
16+ var normalize = require (' nlcst-normalize' )
1717
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'
2323
2424normalize ({
2525 type: ' WordNode' ,
@@ -28,7 +28,7 @@ normalize({
2828 {type: ' PunctuationNode' , value: ' -' },
2929 {type: ' TextNode' , value: ' level' }
3030 ]
31- }); // => 'blocklevel'
31+ }) // => 'blocklevel'
3232```
3333
3434## API
You can’t perform that action at this time.
0 commit comments