Util function to append string in file

This commit is contained in:
NKumar2
2017-05-01 11:59:48 +05:30
committed by Bugra Cuhadaroglu
parent a38d58506a
commit 2bad7de4e3

View File

@@ -149,6 +149,16 @@ export async function mkdirp(path: string, mode?: number): Promise<boolean> {
return true;
}
export async function createOrAppendFile(path: string, data: string, options?: any): Promise<boolean> {
try {
await nfcall(fs.appendFile, path, data, options);
} catch (err) {
throw new Error(`Not able to append data in file '${path}'`);
}
return true;
}
export function uniqueFilter<T>(keyFn: (t: T) => string): (t: T) => boolean {
const seen: { [key: string]: boolean; } = Object.create(null);