@types/write
TypeScript icon, indicating that this package has built-in type declarations

2.0.4 • Public • Published

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

/// <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

Credits

These definitions were written by Junxiao Shi.

Versions

Current Tags

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.4
    2,763
  • 2.0.3
    3
  • 2.0.2
    10
  • 2.0.1
    772
  • 2.0.0
    136

Package Sidebar

Install

npm i @types/write

Weekly Downloads

3,684

Version

2.0.4

License

MIT

Unpacked Size

5.19 kB

Total Files

5

Last publish

Collaborators

  • types