@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
Interfaces
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
orundefined
, it simply proxies thefile.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 asstring
for the compiler not to require useless null checks for the getter. (Hopefully, noone will need to assignnull
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.jsfile.basename = 'file.txt';console.log(file.basename); // file.txtconsole.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 acloneable-readable
stream.Throws when set to any value other than a
Stream
, aBuffer
ornull
.
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); // /testfile.dirname = '/specs';console.log(file.dirname); // /specsconsole.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); // .jsfile.extname = '.txt';console.log(file.extname); // .txtconsole.log(file.path); // /test/file.txt
property history
readonly history: readonly string[];
Array of
file.path
values the Vinyl object has had, fromfile.history[0]
(original) throughfile.history[file.history.length - 1]
(current).file.history
and its elements should normally be treated as read-only and only altered indirectly by settingfile.path
.
property path
path: string;
Gets and sets the absolute pathname string or
undefined
. Setting to a different value appends the new path tofile.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 juststring
, however TypeScript doesn't allow get/set accessors to be of different type. See the comment for thebase
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); // filefile.stem = 'foo';console.log(file.stem); // fooconsole.log(file.path); // /test/foo.js
property symlink
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
oroptions.deep
isfalse
, custom attributes will not be cloned deeply.If
file.contents
is aBuffer
andoptions.contents
isfalse
, theBuffer
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 aBuffer
, otherwisefalse
.
method isDirectory
isDirectory: () => this is File.DirectoryFile;
Returns
true
if the file represents a directory, otherwisefalse
.A file is considered a directory when:
-
file.isNull()
istrue
-file.stat
is an object -file.stat.isDirectory()
returnstrue
When constructing a Vinyl object, pass in a valid
fs.Stats
object viaoptions.stat
. If you are mocking thefs.Stats
object, you may need to stub theisDirectory()
method.
method isNull
isNull: () => this is File.NullFile;
Returns
true
if the file contents arenull
, otherwisefalse
.
method isStream
isStream: () => this is File.StreamFile;
Returns
true
if the file contents are aStream
, otherwisefalse
.
method isSymbolic
isSymbolic: () => this is File.SymbolicFile;
Returns
true
if the file represents a symbolic link, otherwisefalse
.A file is considered symbolic when:
-
file.isNull()
istrue
-file.stat
is an object -file.stat.isSymbolicLink()
returnstrue
When constructing a Vinyl object, pass in a valid
fs.Stats
object viaoptions.stat
. If you are mocking thefs.Stats
object, you may need to stub theisSymbolicLink()
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 oneto 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>
- Updated .
Package analyzed in 1235 ms. - Missing or incorrect documentation? Open an issue for this package.