UNPKG

1.25 kBTypeScriptView Raw
1// Type definitions for write-file-atomic 3.0
2// Project: https://github.com/npm/write-file-atomic
3// Definitions by: BendingBender <https://github.com/BendingBender>
4// Jay Rylan <https://github.com/jayrylan>
5// Piotr Błażejewicz <https://github.com/peterblazejewicz>
6// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7
8/// <reference types="node" />
9
10export = writeFile;
11
12declare function writeFile(filename: string, data: string | Buffer, options: writeFile.Options | BufferEncoding, callback: (error?: Error) => void): void;
13declare function writeFile(filename: string, data: string | Buffer, callback: (error?: Error) => void): void;
14declare function writeFile(filename: string, data: string | Buffer, options?: writeFile.Options | BufferEncoding): Promise<void>;
15
16declare namespace writeFile {
17 function sync(filename: string, data: string | Buffer, options?: Options | BufferEncoding): void;
18
19 interface Options {
20 chown?: {
21 uid: number;
22 gid: number;
23 } | undefined;
24 /**
25 * @default 'utf8'
26 */
27 encoding?: BufferEncoding | undefined;
28 fsync?: boolean | undefined;
29 mode?: number | undefined;
30 }
31}