2.0.4 • Published 6 months ago

@types/write v2.0.4

Weekly downloads
58,315
License
MIT
Repository
github
Last release
6 months ago

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

// Type definitions for write 2.0
// Project: https://github.com/jonschlinkert/write
// Definitions by: Junxiao Shi <https://github.com/yoursunny>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.5

/// <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: Fri, 02 Jul 2021 18:06:03 GMT
  • Dependencies: @types/node
  • Global values: none

Credits

These definitions were written by Junxiao Shi.

2.0.3

7 months ago

2.0.2

7 months ago

2.0.4

6 months ago

2.0.1

3 years ago

2.0.0

5 years ago