mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Add readFile promise wrapper
This commit is contained in:
@@ -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