File tree Expand file tree Collapse file tree 5 files changed +29
-29
lines changed Expand file tree Collapse file tree 5 files changed +29
-29
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
3- function cloneInterface ( anInterface ) {
4- const clone = { } ;
5- let key , fn ;
6- for ( key in anInterface ) {
7- fn = anInterface [ key ] ;
8- clone [ key ] = wrapFunction ( fn ) ;
9- }
10- return clone ;
11- }
12-
13- function wrapFunction ( fn ) {
3+ const wrapFunction = fn => {
144 console . log ( 'Wrap function: ' + fn . name ) ;
155 return ( ...args ) => {
166 console . log ( 'Called wrapper for: ' + fn . name ) ;
@@ -33,7 +23,17 @@ function wrapFunction(fn) {
3323 console . dir ( { result } ) ;
3424 return result ;
3525 } ;
36- }
26+ } ;
27+
28+ const cloneInterface = anInterface => {
29+ const clone = { } ;
30+ let key , fn ;
31+ for ( key in anInterface ) {
32+ fn = anInterface [ key ] ;
33+ clone [ key ] = wrapFunction ( fn ) ;
34+ }
35+ return clone ;
36+ } ;
3737
3838// Usage
3939
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- function cloneInterface ( anInterface ) {
4- const clone = { } ;
5- let key , fn ;
6- for ( key in anInterface ) {
7- fn = anInterface [ key ] ;
8- clone [ key ] = wrapFunction ( fn ) ;
9- }
10- return clone ;
11- }
12-
13- function wrapFunction ( fn ) {
3+ const wrapFunction = fn => {
144 console . log ( 'Wrap function: ' + fn . name ) ;
155 return ( ...args ) => {
166 console . log ( 'Called wrapper for: ' + fn . name ) ;
@@ -20,7 +10,17 @@ function wrapFunction(fn) {
2010 console . dir ( { result } ) ;
2111 return result ;
2212 } ;
23- }
13+ } ;
14+
15+ const cloneInterface = anInterface => {
16+ const clone = { } ;
17+ let key , fn ;
18+ for ( key in anInterface ) {
19+ fn = anInterface [ key ] ;
20+ clone [ key ] = wrapFunction ( fn ) ;
21+ }
22+ return clone ;
23+ } ;
2424
2525// Usage
2626
Original file line number Diff line number Diff line change 22
33// Wrapper will prevent call after timeout
44
5- function timeout ( msec , fn ) {
5+ const timeout = ( msec , fn ) => {
66 let timer = setTimeout ( ( ) => {
77 if ( timer ) console . log ( 'Function timedout' ) ;
88 timer = null ;
@@ -14,7 +14,7 @@ function timeout(msec, fn) {
1414 return fn ( ...args ) ;
1515 }
1616 } ;
17- }
17+ } ;
1818
1919// Usage
2020
Original file line number Diff line number Diff line change 22
33// Wrapper will prevent call after timeout
44
5- function timeout ( msec , fn ) {
5+ const timeout = ( msec , fn ) => {
66 let timer = setTimeout ( ( ) => {
77 if ( timer ) console . log ( 'Function timedout' ) ;
88 timer = null ;
@@ -14,7 +14,7 @@ function timeout(msec, fn) {
1414 return fn ( ...args ) ;
1515 }
1616 } ;
17- }
17+ } ;
1818
1919// Usage
2020
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ const wrap = (func) => {
1515 return ;
1616 }
1717 const res = fn ( ...args ) ;
18- counter ++
18+ counter ++ ;
1919 return res ;
2020 } ;
2121
You can’t perform that action at this time.
0 commit comments