Version 1.0.2
@stackline/to-vfile
vfile utility to create a vfile from a filepath
Independent maintenance of to-vfile 7.2.4. Original authors and licenses are retained.
Installation
# Preserve existing imports with an npm alias
npm install to-vfile@npm:@stackline/to-vfile@1.0.2
# Or use the scoped package name in your imports
npm install @stackline/to-vfile@1.0.2Node.js: See compatibility notes. Read the compatibility and maintenance notes before migrating.
Usage and API
@stackline/to-vfile
vfile utility to create a vfile from a filepath.
Documentation | npm | Issues | Repository
Current package version: 1.0.2
Why this package?
@stackline/to-vfile is the Stackline-maintained distribution of to-vfile@7.2.4. It is an independent continuation of to-vfile; original authors and licenses remain credited below.
Compatibility
| Item | Value |
|---|---|
| Package | @stackline/to-vfile@1.0.2 |
| API target | to-vfile@7.2.4 |
| Supported Node.js | See supported framework requirements |
| License | MIT |
| Module type | module |
| Main entry | index.js |
| Types | index.d.ts |
| Runtime dependencies | vfile, is-buffer |
Installation
npm install @stackline/to-vfile
Preserve existing imports and plugin resolution with an npm alias:
npm install to-vfile@npm:@stackline/to-vfile
Usage and API reference
to-vfile
vfile utility to read and write to the file system.
Contents
What is this?
This utility places file paths and the file system first.
Where vfile itself focusses on file values (the file contents), this instead
focuses on the file system, which is a common case when working with files.
When should I use this?
Use this if you know there’s a file system and want to use it.
Use vfile if there might not be a file system.
Install
This package is ESM only. In Node.js (version 14.14+ and 16.0+), install with npm:
npm install @stackline/to-vfile
In Deno with esm.sh:
import {toVFile, read, readSync, write, writeSync} from 'https://esm.sh/to-vfile@7'
In browsers with esm.sh:
<script type="module">
import {toVFile, read, readSync, write, writeSync} from 'https://esm.sh/to-vfile@7?bundle'
</script>
Use
import {toVFile, read} from '@stackline/to-vfile'
console.log(toVFile('readme.md'))
console.log(toVFile(new URL('readme.md', import.meta.url)))
console.log(await read('.git/HEAD'))
console.log(await read('.git/HEAD', 'utf8'))
Yields:
VFile {
data: {},
messages: [],
history: [ 'readme.md' ],
cwd: '/Users/tilde/Projects/oss/to-vfile'
}
VFile {
data: {},
messages: [],
history: [ '/Users/tilde/Projects/oss/to-vfile/readme.md' ],
cwd: '/Users/tilde/Projects/oss/to-vfile'
}
VFile {
data: {},
messages: [],
history: [ '.git/HEAD' ],
cwd: '/Users/tilde/Projects/oss/to-vfile',
value: <Buffer 72 65 66 3a 20 72 65 66 73 2f 68 65 61 64 73 2f 6d 61 69 6e 0a>
}
VFile {
data: {},
messages: [],
history: [ '.git/HEAD' ],
cwd: '/Users/tilde/Projects/oss/to-vfile',
value: 'ref: refs/heads/main\n'
}
API
This package exports the identifiers read,
readSync, toVFile,
write, and writeSync.
There is no default export.
toVFile(description)
Create a virtual file from a description.
This is like VFile, but it accepts a file path instead of file cotnents.
If options is a string, URL, or buffer, it’s used as the path.
Otherwise, if it’s a file, that’s returned instead.
Otherwise, the options are passed through to new VFile().
Parameters
description(Compatible, optional) — fath to file, file options, or file itself
Returns
Given file or new file (VFile).
read(description[, options][, callback])
Create a virtual file and read it in, async.
Signatures
(description[, options], Callback): void(description[, options]): Promise<VFile>
Parameters
description(Compatible) — path to file, file options, or file itselfoptions(BufferEncoding,ReadOptions, optional)callback(Callback, optional) — callback called when done
Returns
Nothing when a callback is given, otherwise promise that resolves to given
file or new file (VFile).
readSync(description[, options])
Create a virtual file and read it in, synchronously.
Parameters
description(Compatible) — path to file, file options, or file itselfoptions(BufferEncoding,ReadOptions, optional)
Returns
Given file or new file (VFile).
write(description[, options][, callback])
Create a virtual file and write it, async.
Signatures
(description[, options], Callback): void(description[, options]): Promise<VFile>
Parameters
description(Compatible) — path to file, file options, or file itselfoptions(BufferEncoding,WriteOptions, optional)callback(Callback, optional) — callback called when done
Returns
Nothing when a callback is given, otherwise promise that resolves to given
file or new file (VFile).
writeSync(description[, options])
Create a virtual file and write it, synchronously.
Parameters
description(Compatible) — path to file, file options, or file itselfoptions(BufferEncoding,WriteOptions, optional)
Returns
Given file or new file (VFile).
BufferEncoding
Encodings supported by the buffer class (TypeScript type).
This is a copy of the types from Node and VFile.
Type
type BufferEncoding =
| 'ascii'
| 'utf8'
| 'utf-8'
| 'utf16le'
| 'ucs2'
| 'ucs-2'
| 'base64'
| 'base64url'
| 'latin1'
| 'binary'
| 'hex'
Callback
Callback called after reading or writing a file (TypeScript type).
Parameters
error(Error, optional) — error when reading or writing was not successfulfile(VFile, optional) — file when reading or writing was successful
Returns
Nothing (void).
Compatible
URL to file, path to file, options for file, or actual file (TypeScript type).
Type
type Compatible = Buffer | URL | VFileOptions | VFile | string
See VFileOptions and VFile.
ReadOptions
Configuration for fs.readFile (TypeScript type).
Fields
encoding(BufferEncoding, optional) — encoding to read file as, will turnfile.valueinto a string if passedflag(string, optional) — file system flags to use
WriteOptions
Configuration for fs.writeFile (TypeScript type).
Fields
encoding(BufferEncoding, optional) — encoding to write file asmode(number | string, optional) — file mode (permission and sticky bits) if the file was newly createdflag(string, optional) — file system flags to use
Types
This package is fully typed with TypeScript.
It exports the additional types
BufferEncoding,
Callback,
Compatible,
ReadOptions, and
WriteOptions.
Compatibility
Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. Our projects sometimes work with older versions, but this is not guaranteed.
Contribute
See contributing.md in vfile/.github for ways to
get started.
See support.md for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
License
Credits and original authors
- Original project: to-vfile.
- Titus Wormer.
- Copyright (c) 2015 Titus Wormer tituswormer@gmail.com.
- Stackline maintenance: Alexandro Paixao Marques and Stackline contributors.
Original copyright, license notices and contributor acknowledgements remain part of this distribution. Stackline maintenance does not replace authorship of the original work.
Community and Links
Use this repository's issue tracker for reproducible bugs and feature requests. Join r/Stackline for examples, usage questions and release discussions.
Upstream issues and maintenance review
Upstream and maintenance review
This package maintains to-vfile@7.2.4 under the independent @stackline/to-vfile name.
- Source: https://github.com/vfile/to-vfile/tree/b16947aa2e5cfc08cb8c714452302e44d89bd2e1
- Public npm artifact integrity:
sha512-2eQ+rJ2qGbyw3senPI0qjuM7aut8IYXK6AEoOWb+fJx/mQYzviTckm1wDjq91QYHAPBTYzmdJXxMFA6Mk14mdw==. - Upstream issue evidence checked: 2026-09-29T00:22:17.678004+00:00.
- Original license and author notices are retained.
- The upstream published runtime files and declarations are hash-checked in
.stackline/upstream.json. Any runtime fix is explicitly listed there. - Functional upstream suites run against the source and extracted final package. Development tools were reduced to those used by validation; full source and runtime audits must pass.
- Only direct dependencies of the original Stackline portfolio are in this migration. This is not a claim that all transitive projects are maintained by Stackline.
Issue triage
The queried open-issue list contained no issue entries. This does not establish that the upstream is abandoned or bug-free. No runtime bug fix is claimed for this initial maintenance release.
The evidence query fetched the latest 100 open and 30 closed issue/PR entries and removed PRs. Closed entries were collected for context; this report does not claim an exhaustive historic review.
Release discipline
The source commit, passing CI and CodeQL, reviewed CI tarball hash, npm provenance, normal and aliased installs, and immutable GitHub release are checked before a release is complete. Published versions and tags are never replaced.
Release changes
Changelog
1.0.0
- Start Stackline maintenance of the documented upstream API.
- Preserve and verify published runtime files and TypeScript declarations.
- Run upstream functional suites against both source and the final package.
- Publish the reviewed CI artifact through GitHub Actions with provenance and immutable release evidence.
Release files and references
Package bytes, npm provenance and the immutable GitHub release were verified for this version. Security checks describe the reviewed release; documented compatibility risks and upstream reports are not blanket claims of resolution.