1 | # Installation
|
2 | > `npm install --save @types/write`
|
3 |
|
4 | # Summary
|
5 | This package contains type definitions for write (https://github.com/jonschlinkert/write).
|
6 |
|
7 | # Details
|
8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/write.
|
9 | ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/write/index.d.ts)
|
10 | ````ts
|
11 | /// <reference types="node" />
|
12 | import * as fs from "fs";
|
13 |
|
14 | type Data = string | Buffer | Uint8Array;
|
15 |
|
16 | interface CommonOptions {
|
17 | newline?: boolean | undefined;
|
18 | overwrite?: boolean | undefined;
|
19 | increment?: boolean | undefined;
|
20 | }
|
21 |
|
22 | type Options =
|
23 | & Omit<fs.WriteFileOptions, "encoding">
|
24 | & Omit<fs.MakeDirectoryOptions, "recursive">
|
25 | & CommonOptions;
|
26 |
|
27 | type CreateWriteStreamOptions = Extract<Parameters<typeof fs.createWriteStream>[1], Record<string, any>>;
|
28 |
|
29 | type StreamOptions =
|
30 | & Omit<CreateWriteStreamOptions, "encoding">
|
31 | & Omit<fs.MakeDirectoryOptions, "recursive">
|
32 | & CommonOptions;
|
33 |
|
34 | interface Result<T extends Data> {
|
35 | path: string;
|
36 | data: T;
|
37 | }
|
38 |
|
39 | type Callback<T extends Data> = (err: Error | null, result?: Result<T>) => any;
|
40 |
|
41 | declare function write<T extends Data>(filepath: string, data: T, options: Options, callback: Callback<T>): void;
|
42 | declare function write<T extends Data>(filepath: string, data: T, callback: Callback<T>): void;
|
43 | declare function write<T extends Data>(filepath: string, data: T, options?: Options): Promise<Result<T>>;
|
44 |
|
45 | declare namespace write {
|
46 | function sync<T extends Data>(filepath: string, data: T, options?: Options): Result<T>;
|
47 |
|
48 | function stream(filepath: string, options?: StreamOptions): fs.WriteStream;
|
49 | }
|
50 |
|
51 | export = write;
|
52 |
|
53 | ````
|
54 |
|
55 | ### Additional Details
|
56 | * Last updated: Tue, 07 Nov 2023 15:11:36 GMT
|
57 | * Dependencies: [@types/node](https://npmjs.com/package/@types/node)
|
58 |
|
59 | # Credits
|
60 | These definitions were written by [Junxiao Shi](https://github.com/yoursunny).
|
61 |
|
\ | No newline at end of file |