@types/write
Version:
TypeScript definitions for write
61 lines (44 loc) • 1.93 kB
Markdown
# Installation
> `npm install --save @types/write`
# Summary
This package contains type definitions for write (https://github.com/jonschlinkert/write).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/write.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/write/index.d.ts)
````ts
/// <reference types="node" />
import * as fs from "fs";
type Data = string | Buffer | Uint8Array;
interface CommonOptions {
newline?: boolean | undefined;
overwrite?: boolean | undefined;
increment?: boolean | undefined;
}
type Options =
& Omit<fs.WriteFileOptions, "encoding">
& Omit<fs.MakeDirectoryOptions, "recursive">
& CommonOptions;
type CreateWriteStreamOptions = Extract<Parameters<typeof fs.createWriteStream>[1], Record<string, any>>;
type StreamOptions =
& Omit<CreateWriteStreamOptions, "encoding">
& Omit<fs.MakeDirectoryOptions, "recursive">
& CommonOptions;
interface Result<T extends Data> {
path: string;
data: T;
}
type Callback<T extends Data> = (err: Error | null, result?: Result<T>) => any;
declare function write<T extends Data>(filepath: string, data: T, options: Options, callback: Callback<T>): void;
declare function write<T extends Data>(filepath: string, data: T, callback: Callback<T>): void;
declare function write<T extends Data>(filepath: string, data: T, options?: Options): Promise<Result<T>>;
declare namespace write {
function sync<T extends Data>(filepath: string, data: T, options?: Options): Result<T>;
function stream(filepath: string, options?: StreamOptions): fs.WriteStream;
}
export = write;
````
### Additional Details
* Last updated: Tue, 07 Nov 2023 15:11:36 GMT
* Dependencies: [@types/node](https://npmjs.com/package/@types/node)
# Credits
These definitions were written by [Junxiao Shi](https://github.com/yoursunny).