File tree Expand file tree Collapse file tree 3 files changed +53
-27
lines changed Expand file tree Collapse file tree 3 files changed +53
-27
lines changed Original file line number Diff line number Diff line change 1- parserOptions :
2- ecmaVersion : 6
31env :
2+ es6 : true
43 node : true
54extends : ' eslint:recommended'
65globals :
7- api : true
8- impress : true
9- global : true
6+ api : false
107rules :
118 indent :
129 - error
7370 ignoreUrls : true
7471 max-nested-callbacks :
7572 - error
76- - max : 5
73+ - max : 7
7774 new-cap :
7875 - error
7976 - newIsCap : true
@@ -141,3 +138,36 @@ rules:
141138 no-use-before-define :
142139 - error
143140 - functions : false
141+ arrow-body-style :
142+ - error
143+ - as-needed
144+ arrow-spacing :
145+ - error
146+ no-confusing-arrow :
147+ - error
148+ - allowParens : true
149+ no-useless-computed-key :
150+ - error
151+ no-useless-rename :
152+ - error
153+ no-var :
154+ - error
155+ object-shorthand :
156+ - error
157+ - always
158+ prefer-arrow-callback :
159+ - error
160+ prefer-const :
161+ - error
162+ prefer-numeric-literals :
163+ - error
164+ prefer-rest-params :
165+ - error
166+ prefer-spread :
167+ - error
168+ rest-spread-spacing :
169+ - error
170+ - never
171+ template-curly-spacing :
172+ - error
173+ - never
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- global . api = { } ;
3+ const fp = { } ;
44
5- api . fp = { } ;
5+ fp . mapNull = ( fn , x ) => ( x ? fn ( x ) : null ) ;
66
7- api . fp . mapNull = ( fn , x ) => x ? fn ( x ) : null ;
8-
9- api . fp . maybe = x => {
10- const map = fn => api . fp . maybe ( api . fp . mapNull ( fn , x ) ) ;
11- map . ap = fnA => fnA ( fn => api . fp . mapNull ( fn , x ) ) ;
7+ fp . maybe = x => {
8+ const map = fn => fp . maybe ( fp . mapNull ( fn , x ) ) ;
9+ map . ap = fnA => fnA ( fn => fp . mapNull ( fn , x ) ) ;
1210 map . chain = fnM => fnM ( x ) ;
1311 return map ;
1412} ;
1513
16- api . fp . maybe ( 5 ) ( x => x * 2 ) ( x => ++ x ) ( console . log ) ;
17- api . fp . maybe ( 5 ) ( x => x * 2 ) . ap ( api . fp . maybe ( x => ++ x ) ) ( console . log ) ;
18- api . fp . maybe ( 5 ) . chain ( x => api . fp . maybe ( x * 2 ) ) ( x => ++ x ) ( console . log ) ;
14+ fp . maybe ( 5 ) ( x => x * 2 ) ( x => ++ x ) ( console . log ) ;
15+ fp . maybe ( 5 ) ( x => x * 2 ) . ap ( fp . maybe ( x => ++ x ) ) ( console . log ) ;
16+ fp . maybe ( 5 ) . chain ( x => fp . maybe ( x * 2 ) ) ( x => ++ x ) ( console . log ) ;
1917
2018const config = {
2119 coords : {
@@ -34,6 +32,6 @@ const addVelocity = velocity => coords => {
3432 return coords ;
3533} ;
3634
37- const coords = api . fp . maybe ( config . coords ) ;
38- const velocity = api . fp . maybe ( config . velocity ) ;
35+ const coords = fp . maybe ( config . coords ) ;
36+ const velocity = fp . maybe ( config . velocity ) ;
3937coords . ap ( velocity ( addVelocity ) ) ( console . log ) ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- global . api = { } ;
3+ const fp = { } ;
44
5- api . fp = { } ;
6-
7- api . fp . path = data => (
5+ fp . path = data => (
86 path => (
9- api . fp . maybe ( path ) ( path => (
7+ fp . maybe ( path ) ( path => (
108 path . split ( '.' ) . reduce (
119 ( prev , key ) => ( prev [ key ] || { } ) ,
1210 ( data || { } )
@@ -15,7 +13,7 @@ api.fp.path = data => (
1513 )
1614) ;
1715
18- api . fp . maybe = x => fn => api . fp . maybe ( x && fn ? fn ( x ) : null ) ;
16+ fp . maybe = x => fn => fp . maybe ( x && fn ? fn ( x ) : null ) ;
1917
2018// Usage example:
2119
4442 config . server . ssl . key &&
4543 config . server . ssl . key . filename
4644) {
47- let fileName = config . server . ssl . key . filename ;
45+ const fileName = config . server . ssl . key . filename ;
4846 fs . readFile ( fileName , ( err , data ) => {
4947 if ( data ) {
5048 console . log ( ) ;
5452
5553// Functional style:
5654
57- api . fp . path ( config ) ( 'server.ssl.key.filename' ) (
55+ fp . path ( config ) ( 'server.ssl.key.filename' ) (
5856 file => fs . readFile ( file , ( err , data ) => {
59- api . fp . maybe ( data ) ( console . log ) ;
57+ fp . maybe ( data ) ( console . log ) ;
6058 } )
6159) ;
You can’t perform that action at this time.
0 commit comments