VFile

Defined in: node_modules/vfile/lib/index.d.ts:1

Constructors

Constructor

new VFile(value?): VFile

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

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?nullCompatible

Returns

VFile

New instance.

Properties

cwd

cwd: string

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

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


data

data: Data

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

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

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


history

history: string[]

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

List of file paths the file moved between.

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


map

map: undefined | null | Map

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

Source map.

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


messages

messages: VFileMessage[]

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

List of messages associated with the file.


result

result: unknown

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

Custom, non-string, compiled, representation.

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


stored

stored: boolean

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

Whether a file was saved to disk.

This is used by vfile reporters.


value

value: Value

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

Raw value.

Accessors

basename

Get Signature

get basename(): undefined | string

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

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

Returns

undefined | string

Basename.

Set Signature

set basename(basename): void

Defined in: node_modules/vfile/lib/index.d.ts:98

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.


dirname

Get Signature

get dirname(): undefined | string

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

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

Returns

undefined | string

Dirname.

Set Signature

set dirname(dirname): void

Defined in: node_modules/vfile/lib/index.d.ts:136

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

Cannot be set if there’s no path yet.

Parameters
ParameterTypeDescription
dirnameundefinedstring
Returns

void

Nothing.


extname

Get Signature

get extname(): undefined | string

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

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

Returns

undefined | string

Extname.

Set Signature

set extname(extname): void

Defined in: node_modules/vfile/lib/index.d.ts:156

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
extnameundefinedstring
Returns

void

Nothing.


path

Get Signature

get path(): string

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

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

Returns

string

Path.

Set Signature

set path(path): void

Defined in: node_modules/vfile/lib/index.d.ts:118

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
pathstringURL
Returns

void

Nothing.


stem

Get Signature

get stem(): undefined | string

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

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

Returns

undefined | string

Stem.

Set Signature

set stem(stem): void

Defined in: node_modules/vfile/lib/index.d.ts:176

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.

Methods

fail()

Call Signature

fail(reason, options?): never

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

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?nullOptions
Returns

never

Throws

Message.

Call Signature

fail(reason, parent, origin?): never

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

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
parentundefinednull
origin?nullstring
Returns

never

Throws

Message.

Call Signature

fail(reason, place, origin?): never

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

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
placeundefinednull
origin?nullstring
Returns

never

Throws

Message.

Call Signature

fail(reason, origin?): never

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

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?nullstring
Returns

never

Throws

Message.

Call Signature

fail(cause, parent, origin?): never

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

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
causeErrorVFileMessage
parentundefinednull
origin?nullstring
Returns

never

Throws

Message.

Call Signature

fail(cause, place, origin?): never

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

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
causeErrorVFileMessage
placeundefinednull
origin?nullstring
Returns

never

Throws

Message.

Call Signature

fail(cause, origin?): never

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

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
causeErrorVFileMessage
origin?nullstring
Returns

never

Throws

Message.


info()

Call Signature

info(reason, options?): VFileMessage

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

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?nullOptions
Returns

VFileMessage

Call Signature

info(reason, parent, origin?): VFileMessage

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

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
parentundefinednull
origin?nullstring
Returns

VFileMessage

Call Signature

info(reason, place, origin?): VFileMessage

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

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
placeundefinednull
origin?nullstring
Returns

VFileMessage

Call Signature

info(reason, origin?): VFileMessage

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

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?nullstring
Returns

VFileMessage

Call Signature

info(cause, parent, origin?): VFileMessage

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

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
causeErrorVFileMessage
parentundefinednull
origin?nullstring
Returns

VFileMessage

Call Signature

info(cause, place, origin?): VFileMessage

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

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
causeErrorVFileMessage
placeundefinednull
origin?nullstring
Returns

VFileMessage

Call Signature

info(cause, origin?): VFileMessage

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

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
causeErrorVFileMessage
origin?nullstring
Returns

VFileMessage


message()

Call Signature

message(reason, options?): VFileMessage

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

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?nullOptions
Returns

VFileMessage

Call Signature

message(reason, parent, origin?): VFileMessage

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

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
parentundefinednull
origin?nullstring
Returns

VFileMessage

Call Signature

message(reason, place, origin?): VFileMessage

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

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
placeundefinednull
origin?nullstring
Returns

VFileMessage

Call Signature

message(reason, origin?): VFileMessage

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

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?nullstring
Returns

VFileMessage

Call Signature

message(cause, parent, origin?): VFileMessage

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

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
causeErrorVFileMessage
parentundefinednull
origin?nullstring
Returns

VFileMessage

Call Signature

message(cause, place, origin?): VFileMessage

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

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
causeErrorVFileMessage
placeundefinednull
origin?nullstring
Returns

VFileMessage

Call Signature

message(cause, origin?): VFileMessage

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

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
causeErrorVFileMessage
origin?nullstring
Returns

VFileMessage


toString()

toString(encoding?): string

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

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?nullstring

Returns

string

Serialized file.