VFile

Constructors

new VFile()

new VFile(value?): VFile

Create a new virtual file.

options is treated as:

  • string or Uint8Array{value: options}
  • URL{path: options}
  • VFile — shallow copies its data over to the new file
  • object — all fields are shallow copied over to the new file

Path related fields are set in the following order (least specific to most specific): history, path, basename, stem, extname, dirname.

You cannot set dirname or extname without setting either history, path, basename, or stem too.

Parameters

ParameterTypeDescription
value?null | CompatibleFile value.

Returns

VFile

New instance.

Defined in

node_modules/vfile/lib/index.d.ts:24

Properties

cwd

cwd: string

Base of path (default: process.cwd() or '/' in browsers).

Defined in

node_modules/vfile/lib/index.d.ts:30


data

data: Data

Place to store custom info (default: {}).

It’s OK to store custom data directly on the file but moving it to data is recommended.

Defined in

node_modules/vfile/lib/index.d.ts:39


history

history: string[]

List of file paths the file moved between.

The first is the original path and the last is the current path.

Defined in

node_modules/vfile/lib/index.d.ts:47


map

map: undefined | null | Map

Source map.

This type is equivalent to the RawSourceMap type from the source-map module.

Defined in

node_modules/vfile/lib/index.d.ts:68


messages

messages: VFileMessage[]

List of messages associated with the file.

Defined in

node_modules/vfile/lib/index.d.ts:53


result

result: unknown

Custom, non-string, compiled, representation.

This is used by unified to store non-string results. One example is when turning markdown into React nodes.

Defined in

node_modules/vfile/lib/index.d.ts:77


stored

stored: boolean

Whether a file was saved to disk.

This is used by vfile reporters.

Defined in

node_modules/vfile/lib/index.d.ts:85


value

value: Value

Raw value.

Defined in

node_modules/vfile/lib/index.d.ts:59

Accessors

basename

Get Signature

get basename(): undefined | string

Get the basename (including extname) (example: 'index.min.js').

Returns

undefined | string

Basename.

Set Signature

set basename(basename): void

Set basename (including extname) ('index.min.js').

Cannot contain path separators ('/' on unix, macOS, and browsers, '\' on windows). Cannot be nullified (use file.path = file.dirname instead).

Parameters
ParameterTypeDescription
basenamestringBasename.
Returns

void

Nothing.

Defined in

node_modules/vfile/lib/index.d.ts:105


dirname

Get Signature

get dirname(): undefined | string

Get the parent path (example: '~').

Returns

undefined | string

Dirname.

Set Signature

set dirname(dirname): void

Set the parent path (example: '~').

Cannot be set if there’s no path yet.

Parameters
ParameterTypeDescription
dirnameundefined | stringDirname.
Returns

void

Nothing.

Defined in

node_modules/vfile/lib/index.d.ts:143


extname

Get Signature

get extname(): undefined | string

Get the extname (including dot) (example: '.js').

Returns

undefined | string

Extname.

Set Signature

set extname(extname): void

Set the extname (including dot) (example: '.js').

Cannot contain path separators ('/' on unix, macOS, and browsers, '\' on windows). Cannot be set if there’s no path yet.

Parameters
ParameterTypeDescription
extnameundefined | stringExtname.
Returns

void

Nothing.

Defined in

node_modules/vfile/lib/index.d.ts:163


path

Get Signature

get path(): string

Get the full path (example: '~/index.min.js').

Returns

string

Path.

Set Signature

set path(path): void

Set the full path (example: '~/index.min.js').

Cannot be nullified. You can set a file URL (a URL object with a file: protocol) which will be turned into a path with url.fileURLToPath.

Parameters
ParameterTypeDescription
pathstring | URLPath.
Returns

void

Nothing.

Defined in

node_modules/vfile/lib/index.d.ts:125


stem

Get Signature

get stem(): undefined | string

Get the stem (basename w/o extname) (example: 'index.min').

Returns

undefined | string

Stem.

Set Signature

set stem(stem): void

Set the stem (basename w/o extname) (example: 'index.min').

Cannot contain path separators ('/' on unix, macOS, and browsers, '\' on windows). Cannot be nullified (use file.path = file.dirname instead).

Parameters
ParameterTypeDescription
stemstringStem.
Returns

void

Nothing.

Defined in

node_modules/vfile/lib/index.d.ts:183

Methods

fail()

fail(reason, options)

fail(reason, options?): never

Create a fatal message for reason associated with the file.

The fatal field of the message is set to true (error; file not usable) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
reasonstring
options?null | Options
Returns

never

Never.

Throws

Message.

Defined in

node_modules/vfile/lib/index.d.ts:244

fail(reason, parent, origin)

fail(reason, parent, origin?): never

Create a fatal message for reason associated with the file.

The fatal field of the message is set to true (error; file not usable) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
reasonstring
parentundefined | null | Node | NodeLike
origin?null | string
Returns

never

Never.

Throws

Message.

Defined in

node_modules/vfile/lib/index.d.ts:305

fail(reason, place, origin)

fail(reason, place, origin?): never

Create a fatal message for reason associated with the file.

The fatal field of the message is set to true (error; file not usable) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
reasonstring
placeundefined | null | Position | Point
origin?null | string
Returns

never

Never.

Throws

Message.

Defined in

node_modules/vfile/lib/index.d.ts:366

fail(reason, origin)

fail(reason, origin?): never

Create a fatal message for reason associated with the file.

The fatal field of the message is set to true (error; file not usable) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
reasonstring
origin?null | string
Returns

never

Never.

Throws

Message.

Defined in

node_modules/vfile/lib/index.d.ts:427

fail(cause, parent, origin)

fail(cause, parent, origin?): never

Create a fatal message for reason associated with the file.

The fatal field of the message is set to true (error; file not usable) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
causeError | VFileMessage
parentundefined | null | Node | NodeLike
origin?null | string
Returns

never

Never.

Throws

Message.

Defined in

node_modules/vfile/lib/index.d.ts:488

fail(cause, place, origin)

fail(cause, place, origin?): never

Create a fatal message for reason associated with the file.

The fatal field of the message is set to true (error; file not usable) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
causeError | VFileMessage
placeundefined | null | Position | Point
origin?null | string
Returns

never

Never.

Throws

Message.

Defined in

node_modules/vfile/lib/index.d.ts:549

fail(cause, origin)

fail(cause, origin?): never

Create a fatal message for reason associated with the file.

The fatal field of the message is set to true (error; file not usable) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
causeError | VFileMessage
origin?null | string
Returns

never

Never.

Throws

Message.

Defined in

node_modules/vfile/lib/index.d.ts:610


info()

info(reason, options)

info(reason, options?): VFileMessage

Create an info message for reason associated with the file.

The fatal field of the message is set to undefined (info; change likely not needed) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
reasonstring
options?null | Options
Returns

VFileMessage

Message.

Defined in

node_modules/vfile/lib/index.d.ts:669

info(reason, parent, origin)

info(reason, parent, origin?): VFileMessage

Create an info message for reason associated with the file.

The fatal field of the message is set to undefined (info; change likely not needed) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
reasonstring
parentundefined | null | Node | NodeLike
origin?null | string
Returns

VFileMessage

Message.

Defined in

node_modules/vfile/lib/index.d.ts:728

info(reason, place, origin)

info(reason, place, origin?): VFileMessage

Create an info message for reason associated with the file.

The fatal field of the message is set to undefined (info; change likely not needed) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
reasonstring
placeundefined | null | Position | Point
origin?null | string
Returns

VFileMessage

Message.

Defined in

node_modules/vfile/lib/index.d.ts:787

info(reason, origin)

info(reason, origin?): VFileMessage

Create an info message for reason associated with the file.

The fatal field of the message is set to undefined (info; change likely not needed) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
reasonstring
origin?null | string
Returns

VFileMessage

Message.

Defined in

node_modules/vfile/lib/index.d.ts:846

info(cause, parent, origin)

info(cause, parent, origin?): VFileMessage

Create an info message for reason associated with the file.

The fatal field of the message is set to undefined (info; change likely not needed) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
causeError | VFileMessage
parentundefined | null | Node | NodeLike
origin?null | string
Returns

VFileMessage

Message.

Defined in

node_modules/vfile/lib/index.d.ts:905

info(cause, place, origin)

info(cause, place, origin?): VFileMessage

Create an info message for reason associated with the file.

The fatal field of the message is set to undefined (info; change likely not needed) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
causeError | VFileMessage
placeundefined | null | Position | Point
origin?null | string
Returns

VFileMessage

Message.

Defined in

node_modules/vfile/lib/index.d.ts:964

info(cause, origin)

info(cause, origin?): VFileMessage

Create an info message for reason associated with the file.

The fatal field of the message is set to undefined (info; change likely not needed) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
causeError | VFileMessage
origin?null | string
Returns

VFileMessage

Message.

Defined in

node_modules/vfile/lib/index.d.ts:1023


message()

message(reason, options)

message(reason, options?): VFileMessage

Create a message for reason associated with the file.

The fatal field of the message is set to false (warning; change may be needed) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
reasonstring
options?null | Options
Returns

VFileMessage

Message.

Defined in

node_modules/vfile/lib/index.d.ts:1082

message(reason, parent, origin)

message(reason, parent, origin?): VFileMessage

Create a message for reason associated with the file.

The fatal field of the message is set to false (warning; change may be needed) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
reasonstring
parentundefined | null | Node | NodeLike
origin?null | string
Returns

VFileMessage

Message.

Defined in

node_modules/vfile/lib/index.d.ts:1141

message(reason, place, origin)

message(reason, place, origin?): VFileMessage

Create a message for reason associated with the file.

The fatal field of the message is set to false (warning; change may be needed) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
reasonstring
placeundefined | null | Position | Point
origin?null | string
Returns

VFileMessage

Message.

Defined in

node_modules/vfile/lib/index.d.ts:1200

message(reason, origin)

message(reason, origin?): VFileMessage

Create a message for reason associated with the file.

The fatal field of the message is set to false (warning; change may be needed) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
reasonstring
origin?null | string
Returns

VFileMessage

Message.

Defined in

node_modules/vfile/lib/index.d.ts:1259

message(cause, parent, origin)

message(cause, parent, origin?): VFileMessage

Create a message for reason associated with the file.

The fatal field of the message is set to false (warning; change may be needed) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
causeError | VFileMessage
parentundefined | null | Node | NodeLike
origin?null | string
Returns

VFileMessage

Message.

Defined in

node_modules/vfile/lib/index.d.ts:1318

message(cause, place, origin)

message(cause, place, origin?): VFileMessage

Create a message for reason associated with the file.

The fatal field of the message is set to false (warning; change may be needed) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
causeError | VFileMessage
placeundefined | null | Position | Point
origin?null | string
Returns

VFileMessage

Message.

Defined in

node_modules/vfile/lib/index.d.ts:1377

message(cause, origin)

message(cause, origin?): VFileMessage

Create a message for reason associated with the file.

The fatal field of the message is set to false (warning; change may be needed) and the file field is set to the current file path. The message is added to the messages field on file.

🪦 Note: also has obsolete signatures.

Parameters
ParameterTypeDescription
causeError | VFileMessage
origin?null | string
Returns

VFileMessage

Message.

Defined in

node_modules/vfile/lib/index.d.ts:1436


toString()

toString(encoding?): string

Serialize the file.

Note: which encodings are supported depends on the engine. For info on Node.js, see: <https://nodejs.org/api/util.html#whatwg-supported-encodings\>.

Parameters

ParameterTypeDescription
encoding?null | stringCharacter encoding to understand value as when it’s a Uint8Array (default: 'utf-8').

Returns

string

Serialized file.

Defined in

node_modules/vfile/lib/index.d.ts:1450