File tree 1 file changed +6
-6
lines changed
1-js/11-async/06-promisify
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,11 @@ Here it is:
36
36
let loadScriptPromise = function (src ) {
37
37
return new Promise ((resolve , reject ) => {
38
38
loadScript (src, (err , script ) => {
39
- if (err) reject (err)
39
+ if (err) reject (err);
40
40
else resolve (script);
41
41
});
42
- })
43
- }
42
+ });
43
+ };
44
44
45
45
// usage:
46
46
// loadScriptPromise('path/script.js').then(...)
@@ -71,7 +71,7 @@ function promisify(f) {
71
71
f .call (this , ... args); // call the original function
72
72
});
73
73
};
74
- };
74
+ }
75
75
76
76
// usage:
77
77
let loadScriptPromise = promisify (loadScript);
@@ -110,11 +110,11 @@ function promisify(f, manyArgs = false) {
110
110
f .call (this , ... args);
111
111
});
112
112
};
113
- };
113
+ }
114
114
115
115
// usage:
116
116
f = promisify (f, true );
117
- f (... ).then (arrayOfResults => ... , err => ... )
117
+ f (... ).then (arrayOfResults => ... , err => ... );
118
118
` ` `
119
119
120
120
As you can see it's essentially the same as above, but ` resolve` is called with only one or all arguments depending on whether ` manyArgs` is truthy.
You can’t perform that action at this time.
0 commit comments