File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,7 +15,10 @@ const logger = (level = 'info') => {
1515} ;
1616
1717const warning = logger ( 'warning' ) ;
18- warning ( 'Hello' ) ;
18+ warning ( 'Hello warning' ) ;
19+
20+ const error = logger ( 'error' ) ;
21+ error ( 'Hello error' ) ;
1922
2023const info = logger ( 'info' ) ;
21- info ( 'Hello error ' ) ;
24+ info ( 'Hello info ' ) ;
Original file line number Diff line number Diff line change @@ -7,9 +7,9 @@ class Person {
77}
88
99const factorify =
10- ( Category ) =>
10+ ( Entity ) =>
1111 ( ...args ) =>
12- new Category ( ...args ) ;
12+ new Entity ( ...args ) ;
1313
1414// Usage
1515
Original file line number Diff line number Diff line change 33const POOL_SIZE = 1000 ;
44
55const pool = ( factory ) => {
6- const instance = factory ( ) ;
7- const items = new Array ( POOL_SIZE ) . fill ( instance ) ;
6+ const items = new Array ( POOL_SIZE ) . fill ( null ) . map ( ( ) => factory ( ) ) ;
87 return ( item ) => {
98 let res = null ;
109 if ( item ) {
@@ -21,9 +20,9 @@ const pool = (factory) => {
2120// Usage
2221
2322const factory = ( ) => new Array ( 1000 ) . fill ( 0 ) ;
24- const arrays = pool ( factory ) ;
23+ const arrayPool = pool ( factory ) ;
2524
26- const a1 = arrays ( ) ;
25+ const a1 = arrayPool ( ) ;
2726const b1 = a1 . map ( ( x , i ) => i ) . reduce ( ( x , y ) => x + y ) ;
2827console . log ( b1 ) ;
2928
You can’t perform that action at this time.
0 commit comments