@types/vinyl

  • Version 2.0.12
  • Published
  • 13.3 kB
  • 2 dependencies
  • MIT license

Install

npm i @types/vinyl
yarn add @types/vinyl
pnpm add @types/vinyl

Overview

TypeScript definitions for vinyl

Index

Variables

variable File

let File: FileConstructor;

    Interfaces

    interface BufferFile

    interface BufferFile extends File {}

      property contents

      contents: Buffer;

        method isDirectory

        isDirectory: () => this is never;

          method isNull

          isNull: () => this is never;

            method isStream

            isStream: () => this is never;

              method isSymbolic

              isSymbolic: () => this is never;

                interface DirectoryFile

                interface DirectoryFile extends NullFile {}

                  method isSymbolic

                  isSymbolic: () => this is never;

                    interface File

                    interface File {}

                      property base

                      base: string;
                      • Gets and sets base directory. Used for relative pathing (typically where a glob starts). When null or undefined, it simply proxies the file.cwd property. Will always be normalized and have trailing separators removed.

                        Throws when set to any value other than non-empty strings or null/undefined.

                        The setter's type is actually string | null | undefined, but TypeScript doesn't allow get/set accessors to be of different type. The property is declared as string for the compiler not to require useless null checks for the getter. (Hopefully, noone will need to assign null to this property.)

                      property basename

                      basename: string;
                      • Gets and sets the basename of file.path.

                        Throws when file.path is not set.

                        Example:

                        var file = new File({
                        cwd: '/',
                        base: '/test/',
                        path: '/test/file.js'
                        });
                        console.log(file.basename); // file.js
                        file.basename = 'file.txt';
                        console.log(file.basename); // file.txt
                        console.log(file.path); // /test/file.txt

                      property contents

                      contents: Buffer | NodeJS.ReadableStream | null;
                      • Gets and sets the contents of the file. If set to a Stream, it is wrapped in a cloneable-readable stream.

                        Throws when set to any value other than a Stream, a Buffer or null.

                      property cwd

                      cwd: string;
                      • Gets and sets current working directory. Will always be normalized and have trailing separators removed.

                        Throws when set to any value other than non-empty strings.

                      property dirname

                      dirname: string;
                      • Gets and sets the dirname of file.path. Will always be normalized and have trailing separators removed.

                        Throws when file.path is not set.

                        Example:

                        var file = new File({
                        cwd: '/',
                        base: '/test/',
                        path: '/test/file.js'
                        });
                        console.log(file.dirname); // /test
                        file.dirname = '/specs';
                        console.log(file.dirname); // /specs
                        console.log(file.path); // /specs/file.js

                      property extname

                      extname: string;
                      • Gets and sets extname of file.path.

                        Throws when file.path is not set.

                        Example:

                        var file = new File({
                        cwd: '/',
                        base: '/test/',
                        path: '/test/file.js'
                        });
                        console.log(file.extname); // .js
                        file.extname = '.txt';
                        console.log(file.extname); // .txt
                        console.log(file.path); // /test/file.txt

                      property history

                      readonly history: readonly string[];
                      • Array of file.path values the Vinyl object has had, from file.history[0] (original) through file.history[file.history.length - 1] (current). file.history and its elements should normally be treated as read-only and only altered indirectly by setting file.path.

                      property path

                      path: string;
                      • Gets and sets the absolute pathname string or undefined. Setting to a different value appends the new path to file.history. If set to the same value as the current path, it is ignored. All new values are normalized and have trailing separators removed.

                        Throws when set to any value other than a string.

                        The getter is actually of type string | undefined whereas the setter is just string, however TypeScript doesn't allow get/set accessors to be of different type. See the comment for the base properties.

                      property relative

                      relative: string;
                      • Gets the result of path.relative(file.base, file.path).

                        Throws when set or when file.path is not set.

                        Example:

                        var file = new File({
                        cwd: '/',
                        base: '/test/',
                        path: '/test/file.js'
                        });
                        console.log(file.relative); // file.js

                      property stat

                      stat: fs.Stats | null;

                        property stem

                        stem: string;
                        • Gets and sets stem (filename without suffix) of file.path.

                          Throws when file.path is not set.

                          Example:

                          var file = new File({
                          cwd: '/',
                          base: '/test/',
                          path: '/test/file.js'
                          });
                          console.log(file.stem); // file
                          file.stem = 'foo';
                          console.log(file.stem); // foo
                          console.log(file.path); // /test/foo.js
                        symlink: string | null;
                        • Gets and sets the path where the file points to if it's a symbolic link. Will always be normalized and have trailing separators removed.

                          Throws when set to any value other than a string.

                        method clone

                        clone: (
                        opts?:
                        | { contents?: boolean | undefined; deep?: boolean | undefined }
                        | boolean
                        ) => this;
                        • Returns a new Vinyl object with all attributes cloned.

                          __By default custom attributes are cloned deeply.__

                          If options or options.deep is false, custom attributes will not be cloned deeply.

                          If file.contents is a Buffer and options.contents is false, the Buffer reference will be reused instead of copied.

                        method inspect

                        inspect: () => string;
                        • Returns a formatted-string interpretation of the Vinyl object. Automatically called by node's console.log.

                        method isBuffer

                        isBuffer: () => this is File.BufferFile;
                        • Returns true if the file contents are a Buffer, otherwise false.

                        method isDirectory

                        isDirectory: () => this is File.DirectoryFile;
                        • Returns true if the file represents a directory, otherwise false.

                          A file is considered a directory when:

                          - file.isNull() is true - file.stat is an object - file.stat.isDirectory() returns true

                          When constructing a Vinyl object, pass in a valid fs.Stats object via options.stat. If you are mocking the fs.Stats object, you may need to stub the isDirectory() method.

                        method isNull

                        isNull: () => this is File.NullFile;
                        • Returns true if the file contents are null, otherwise false.

                        method isStream

                        isStream: () => this is File.StreamFile;
                        • Returns true if the file contents are a Stream, otherwise false.

                        method isSymbolic

                        isSymbolic: () => this is File.SymbolicFile;
                        • Returns true if the file represents a symbolic link, otherwise false.

                          A file is considered symbolic when:

                          - file.isNull() is true - file.stat is an object - file.stat.isSymbolicLink() returns true

                          When constructing a Vinyl object, pass in a valid fs.Stats object via options.stat. If you are mocking the fs.Stats object, you may need to stub the isSymbolicLink() method.

                        method pipe

                        pipe: <T extends NodeJS.WritableStream>(
                        stream: T,
                        opts?: { end?: boolean | undefined }
                        ) => T;
                        • Deprecated

                          This method was removed in v2.0. If file.contents is a Buffer, it will write it to the stream. If file.contents is a Stream, it will pipe it to the stream. If file.contents is null, it will do nothing.

                        index signature

                        [customProperty: string]: any;

                          interface NullFile

                          interface NullFile extends File {}

                            property contents

                            contents: null;

                              method isBuffer

                              isBuffer: () => this is never;

                                method isDirectory

                                isDirectory: () => this is DirectoryFile;

                                  method isStream

                                  isStream: () => this is never;

                                    method isSymbolic

                                    isSymbolic: () => this is SymbolicFile;

                                      interface StreamFile

                                      interface StreamFile extends File {}

                                        property contents

                                        contents: NodeJS.ReadableStream;

                                          method isBuffer

                                          isBuffer: () => this is never;

                                            method isDirectory

                                            isDirectory: () => this is never;

                                              method isNull

                                              isNull: () => this is never;

                                                method isSymbolic

                                                isSymbolic: () => this is never;

                                                  interface SymbolicFile

                                                  interface SymbolicFile extends NullFile {}

                                                    method isDirectory

                                                    isDirectory: () => this is never;

                                                      Package Files (1)

                                                      Dependencies (2)

                                                      Dev Dependencies (0)

                                                      No dev dependencies.

                                                      Peer Dependencies (0)

                                                      No peer dependencies.

                                                      Badge

                                                      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/vinyl.

                                                      • Markdown
                                                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/vinyl)
                                                      • HTML
                                                        <a href="https://www.jsdocs.io/package/@types/vinyl"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>