-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.js
More file actions
40 lines (29 loc) · 822 Bytes
/
Copy pathUtils.js
File metadata and controls
40 lines (29 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var promisify = (fn, ctx, ...args) => {
//console.log('first arguement is: '+ fn);
console.log('second arguement is: '+ ctx);
console.log('third arguement is: '+ args);
if (!ctx) {
console.log("not ctxxxx");
ctx = fn;
}
return new Promise((resolve, reject) => {
console.log('reject is: '+ reject)
console.log('resolve is: '+ resolve)
args.push((err, data) => {
if (err) {
console.log('err is: '+ err)
reject(err);
}
else {
console.log('data is: '+ data)
resolve(data);
}
});
console.log('args is: '+ args)
console.log('ctx is: '+ ctx)
fn.apply(ctx, args)
});
};
module.exports = {
promisify
};