mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-10-27 12:21:19 +08:00
Add readFile promise wrapper
This commit is contained in:
1 parent
2910d80558
commit
98cd5ba776
1 file changed
+12
@@ -37,4 +37,16 @@ module DT {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function readFile(target: string): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(target, 'utf-8', (err, contents: string) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(contents);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user