We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e81d671 commit fa18d4aCopy full SHA for fa18d4a
docs/async.md
@@ -287,14 +287,14 @@ JavaScript语言是传值调用,它的Thunk函数含义有所不同。在JavaS
287
fs.readFile(fileName, callback);
288
289
// Thunk版本的readFile(单参数版本)
290
-var readFileThunk = Thunk(fileName);
291
-readFileThunk(callback);
292
-
293
var Thunk = function (fileName){
294
return function (callback){
295
return fs.readFile(fileName, callback);
296
};
297
+
+var readFileThunk = Thunk(fileName);
+readFileThunk(callback);
298
```
299
300
上面代码中,fs模块的readFile方法是一个多参数函数,两个参数分别为文件名和回调函数。经过转换器处理,它变成了一个单参数函数,只接受回调函数作为参数。这个单参数版本,就叫做Thunk函数。
0 commit comments