File tree Expand file tree Collapse file tree 3 files changed +4
-2
lines changed Expand file tree Collapse file tree 3 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ function Maybe(x) {
55}
66
77Maybe . prototype . map = function ( fn ) {
8- return ( this . x && fn ) ? new Maybe ( fn ( this . x ) ) : new Maybe ( null ) ;
8+ return new Maybe ( this . x && fn ? fn ( this . x ) : null ) ;
99} ;
1010
1111new Maybe ( 5 ) . map ( x => x * 2 ) . map ( console . log ) ;
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
13function maybe ( x ) {
24 return function ( fn ) {
35 if ( x && fn ) {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ api.fp.maybe = x => {
1111 map . ap = fnA => fnA ( fn => api . fp . mapNull ( fn , x ) ) ;
1212 map . chain = fnM => fnM ( x ) ;
1313 return map ;
14- }
14+ } ;
1515
1616api . fp . maybe ( 5 ) ( x => x * 2 ) ( x => ++ x ) ( console . log ) ;
1717api . fp . maybe ( 5 ) ( x => x * 2 ) . ap ( api . fp . maybe ( x => ++ x ) ) ( console . log ) ;
You can’t perform that action at this time.
0 commit comments