File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,10 @@ const logger = (level = 'info') => {
15
15
} ;
16
16
17
17
const warning = logger ( 'warning' ) ;
18
- warning ( 'Hello' ) ;
18
+ warning ( 'Hello warning' ) ;
19
+
20
+ const error = logger ( 'error' ) ;
21
+ error ( 'Hello error' ) ;
19
22
20
23
const 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 {
7
7
}
8
8
9
9
const factorify =
10
- ( Category ) =>
10
+ ( Entity ) =>
11
11
( ...args ) =>
12
- new Category ( ...args ) ;
12
+ new Entity ( ...args ) ;
13
13
14
14
// Usage
15
15
Original file line number Diff line number Diff line change 3
3
const POOL_SIZE = 1000 ;
4
4
5
5
const 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 ( ) ) ;
8
7
return ( item ) => {
9
8
let res = null ;
10
9
if ( item ) {
@@ -21,9 +20,9 @@ const pool = (factory) => {
21
20
// Usage
22
21
23
22
const factory = ( ) => new Array ( 1000 ) . fill ( 0 ) ;
24
- const arrays = pool ( factory ) ;
23
+ const arrayPool = pool ( factory ) ;
25
24
26
- const a1 = arrays ( ) ;
25
+ const a1 = arrayPool ( ) ;
27
26
const b1 = a1 . map ( ( x , i ) => i ) . reduce ( ( x , y ) => x + y ) ;
28
27
console . log ( b1 ) ;
29
28
You can’t perform that action at this time.
0 commit comments