@@ -19,7 +19,7 @@ how wrapper works for `setTimeout`.
19
19
## Tasks
20
20
21
21
1 . Learn how ` setTimeout ` is wrapped in example: ` framework.js ` . Now we will
22
- try to wrap module fs. We can iterat all of its functions by following code:
22
+ try to wrap module fs. We can iterate all of its functions by following code:
23
23
` for (var key in fs) {...} ` and replace its function with wrapped ones. We need
24
24
a closure function and it should be universal to wrap any function in fs
25
25
interface. The purpose of this example wrapper is to log all calls to the file
@@ -39,11 +39,11 @@ following code:
39
39
```
40
40
This example contains a call to ` fs.readFile ` . In next steps we will change the
41
41
behavior of the code changing ` framework.js ` and wrapping all ` fs ` functions.
42
- Let` s run ` node framework` and make sure that it reads th file displays its
42
+ Let' s run ` node framework ` and make sure that it reads the file and displays its
43
43
length.
44
44
3 . Next step is preparing function ` cloneInterface(interfaceName) ` for cloning
45
45
all keys from given library into new interface. So we can pass its result
46
- (cloned ` fs ` ) to sandbox instead of ` fs ` . Clonning function example:
46
+ (cloned ` fs ` ) to sandbox instead of ` fs ` . Cloning function example:
47
47
48
48
``` JavaScript
49
49
function cloneInterface (anInterface ) {
@@ -55,7 +55,7 @@ all keys from given library into new interface. So we can pass its result
55
55
}
56
56
```
57
57
4 . After that we can add wrapper ` wrapFunction(fnName, fn) ` with 2 arguments:
58
- name of the function and link to a function itself. It returns ` wrapper ` -
58
+ name of the function and link to a function itself. It returns ` wrapper ` —
59
59
closure function. Closure ` wrapper ` is a newly created function with the help
60
60
of functional inheritance, so it will see ` fnName ` , ` fn ` in its context. Thus
61
61
we can pass all arguments from wrapper into original function as you see in
0 commit comments