{"name":"to-vfile","version":"7.2.4","description":"vfile utility to create a vfile from a filepath","license":"MIT","keywords":["vfile","vfile-util","util","utility","virtual","file","text","processing","file-path","path"],"repository":{"type":"git","url":"git+https://github.com/vfile/to-vfile.git"},"bugs":{"url":"https://github.com/vfile/to-vfile/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"sideEffects":false,"type":"module","main":"index.js","types":"index.d.ts","dependencies":{"is-buffer":"^2.0.0","vfile":"^5.1.0"},"devDependencies":{"@types/node":"^18.0.0","c8":"^7.0.0","prettier":"^2.0.0","remark-cli":"^11.0.0","remark-preset-wooorm":"^9.0.0","type-coverage":"^2.0.0","typescript":"^4.0.0","xo":"^0.53.0"},"scripts":{"prepack":"npm run build && npm run format","build":"tsc --build --clean && tsc --build && type-coverage","format":"remark . -qfo && prettier . -w --loglevel warn && xo --fix","test-api":"node --conditions development test.js","test-coverage":"c8 --check-coverage --100 --reporter lcov npm run test-api","test":"npm run build && npm run format && npm run test-coverage"},"prettier":{"tabWidth":2,"useTabs":false,"singleQuote":true,"bracketSpacing":false,"semi":false,"trailingComma":"none"},"xo":{"prettier":true,"rules":{"unicorn/prefer-node-protocol":"off"}},"remarkConfig":{"plugins":["preset-wooorm"]},"typeCoverage":{"atLeast":100,"detail":true,"strict":true,"ignoreCatch":true},"gitHead":"b16947aa2e5cfc08cb8c714452302e44d89bd2e1","homepage":"https://github.com/vfile/to-vfile#readme","_id":"to-vfile@7.2.4","_nodeVersion":"19.3.0","_npmVersion":"9.2.0","dist":{"integrity":"sha512-2eQ+rJ2qGbyw3senPI0qjuM7aut8IYXK6AEoOWb+fJx/mQYzviTckm1wDjq91QYHAPBTYzmdJXxMFA6Mk14mdw==","shasum":"b97ecfcc15905ffe020bc975879053928b671378","tarball":"http://registry-npm.ywwl.com/to-vfile/download/to-vfile-7.2.4.tgz","fileCount":7,"unpackedSize":25977,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFh5HfK/+xZLDVFl77WyRNWbtg9mtok5a62vNJk7VIr1AiEA4PWYAYuXR9cGB2JuNrFZq/XCTG3KA3r5UFuQy7JqhGM="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj46XPACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmow4BAAlO0XOoPeUCHgIx8y/3VKy6kO8wR4S01R5ZzmzO+ytk2SNCqT\r\nXWpAvhi56KtNKxmqqzRYLlHuG4owJ1TzlWt1aQA45px0xDzHCdGdrUye3qf6\r\n9MBqQUJun7eIRL16qHw+0MmpxqhEvePFnRiaRDp+NfkmonguAgNhDoGzRB0U\r\no3Sp66yhC10WJWfkc0Zqx7xbYGqkw9N8mrB8eq7+QAhK/rY3LYJCLRfQHMp0\r\nL4rpV4mgTLyoQWEsiALG+zN3mOD/ZATU5JxOM8z4apKf121VpPZl/mr+4uBj\r\nhiiCi5dHd5D1TM7DSwy+drkxV8gwwTCRKRfNIXCzM8bU4IycnqccP3by7ZTz\r\nb4yQrmMfsLoM3GPvRU4hNwEf0SzQf9SUmem+2Q4tJvBmJUCW4H+/IQ+uK45t\r\naVY+KZQrBavSiVmBr1wWUSEfUeTcmeKYcfNCMrHVWxcQtBqD/qqD8MNSBwlV\r\nf+JT5gcOCdUGOTp4F+0R4CtQitvS6AEP52XoBf33piTTVYRDl2jvEtxOvEeq\r\npuj4QFyaRkqOUVrGS/AVAwqhR9OpljzUCY9PgeMq4Xx56ntgHmBcZ6Ta8Y8C\r\nzH8vB79AwxHPvRFmKhi6sEZFocDeK9Tp1XqcyTv/bL3hTGXRXYFx0trBZFh7\r\nadNzERX0D+kBlqrO926J1aDZyxXYbFmDIh8=\r\n=HZuS\r\n-----END PGP SIGNATURE-----\r\n","size":6450,"noattachment":false,"key":"/to-vfile/-/to-vfile-7.2.4.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/to-vfile_7.2.4_1675863503616_0.8621734120464122"},"_hasShrinkwrap":false,"readme":"# to-vfile\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n[vfile][] utility to read and write to the file system.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`toVFile(description)`](#tovfiledescription)\n    *   [`read(description[, options][, callback])`](#readdescription-options-callback)\n    *   [`readSync(description[, options])`](#readsyncdescription-options)\n    *   [`write(description[, options][, callback])`](#writedescription-options-callback)\n    *   [`writeSync(description[, options])`](#writesyncdescription-options)\n    *   [`BufferEncoding`](#bufferencoding)\n    *   [`Callback`](#callback)\n    *   [`Compatible`](#compatible)\n    *   [`ReadOptions`](#readoptions)\n    *   [`WriteOptions`](#writeoptions)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis utility puts the file system first.\nWhere `vfile` itself focusses on file values (the file contents), this instead\nfocuses on the file system, which is a common case when working with *actual*\nfiles from Node.js.\n\n## When should I use this?\n\nUse this if you know there’s a file system and want to use it.\nUse `vfile` if there might not be a file system.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install to-vfile\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {toVFile, read, readSync, write, writeSync} from 'https://esm.sh/to-vfile@8'\n```\n\n## Use\n\n```js\nimport {toVFile, read} from 'to-vfile'\n\nconsole.log(toVFile('readme.md'))\nconsole.log(toVFile(new URL('readme.md', import.meta.url)))\nconsole.log(await read('.git/HEAD'))\nconsole.log(await read('.git/HEAD', 'utf8'))\n```\n\nYields:\n\n```js\nVFile {\n  cwd: '/Users/tilde/Projects/oss/to-vfile',\n  data: {},\n  history: [ 'readme.md' ],\n  messages: []\n}\nVFile {\n  cwd: '/Users/tilde/Projects/oss/to-vfile',\n  data: {},\n  history: [ '/Users/tilde/Projects/oss/to-vfile/readme.md' ],\n  messages: []\n}\nVFile {\n  cwd: '/Users/tilde/Projects/oss/to-vfile',\n  data: {},\n  history: [ '.git/HEAD' ],\n  messages: [],\n  value: <Buffer 72 65 66 3a 20 72 65 66 73 2f 68 65 61 64 73 2f 6d 61 69 6e 0a>\n}\nVFile {\n  cwd: '/Users/tilde/Projects/oss/to-vfile',\n  data: {},\n  history: [ '.git/HEAD' ],\n  messages: [],\n  value: 'ref: refs/heads/main\\n'\n}\n```\n\n## API\n\nThis package exports the identifiers [`read`][api-read],\n[`readSync`][api-read-sync], [`toVFile`][api-to-vfile],\n[`write`][api-write], and [`writeSync`][api-write-sync].\nThere is no default export.\n\n### `toVFile(description)`\n\nCreate a virtual file from a description.\n\nThis is like `VFile`, but it accepts a file path instead of file cotnents.\n\nIf `options` is a string, URL, or buffer, it’s used as the path.\nOtherwise, if it’s a file, that’s returned instead.\nOtherwise, the options are passed through to `new VFile()`.\n\n###### Parameters\n\n*   `description` ([`Compatible`][api-compatible], optional)\n    — fath to file, file options, or file itself\n\n###### Returns\n\nGiven file or new file ([`VFile`][vfile]).\n\n### `read(description[, options][, callback])`\n\nCreate a virtual file and read it in, async.\n\n###### Signatures\n\n*   `(description[, options], Callback): undefined`\n*   `(description[, options]): Promise<VFile>`\n\n###### Parameters\n\n*   `description` ([`Compatible`][api-compatible])\n    — path to file, file options, or file itself\n*   `options` ([`BufferEncoding`][api-buffer-encoding],\n    [`ReadOptions`][api-read-options], optional)\n*   `callback` ([`Callback`][api-callback], optional)\n    — callback called when done\n\n###### Returns\n\nNothing when a callback is given, otherwise [promise][] that resolves to given\nfile or new file ([`VFile`][vfile]).\n\n### `readSync(description[, options])`\n\nCreate a virtual file and read it in, synchronously.\n\n###### Parameters\n\n*   `description` ([`Compatible`][api-compatible])\n    — path to file, file options, or file itself\n*   `options` ([`BufferEncoding`][api-buffer-encoding],\n    [`ReadOptions`][api-read-options], optional)\n\n###### Returns\n\nGiven file or new file ([`VFile`][vfile]).\n\n### `write(description[, options][, callback])`\n\nCreate a virtual file and write it, async.\n\n###### Signatures\n\n*   `(description[, options], Callback): undefined`\n*   `(description[, options]): Promise<VFile>`\n\n###### Parameters\n\n*   `description` ([`Compatible`][api-compatible])\n    — path to file, file options, or file itself\n*   `options` ([`BufferEncoding`][api-buffer-encoding],\n    [`WriteOptions`][api-write-options], optional)\n*   `callback` ([`Callback`][api-callback], optional)\n    — callback called when done\n\n###### Returns\n\nNothing when a callback is given, otherwise [promise][] that resolves to given\nfile or new file ([`VFile`][vfile]).\n\n### `writeSync(description[, options])`\n\nCreate a virtual file and write it, synchronously.\n\n###### Parameters\n\n*   `description` ([`Compatible`][api-compatible])\n    — path to file, file options, or file itself\n*   `options` ([`BufferEncoding`][api-buffer-encoding],\n    [`WriteOptions`][api-write-options], optional)\n\n###### Returns\n\nGiven file or new file ([`VFile`][vfile]).\n\n### `BufferEncoding`\n\nEncodings supported by the buffer class (TypeScript type).\n\nThis is a copy of the types from Node.\n\n###### Type\n\n```ts\ntype BufferEncoding =\n  | 'ascii'\n  | 'base64'\n  | 'base64url'\n  | 'binary'\n  | 'hex'\n  | 'latin1'\n  | 'ucs-2'\n  | 'ucs2'\n  | 'utf-8'\n  | 'utf16le'\n  | 'utf8'\n```\n\n### `Callback`\n\nCallback called after reading or writing a file (TypeScript type).\n\n###### Parameters\n\n*   `error` (`Error`, optional)\n    — error when reading or writing was not successful\n*   `file` ([`VFile`][vfile], optional)\n    — file when reading or writing was successful\n\n###### Returns\n\nNothing (`undefined`).\n\n### `Compatible`\n\nURL to file, path to file, options for file, or actual file (TypeScript type).\n\n###### Type\n\n```ts\ntype Compatible = Uint8Array | URL | VFile | VFileOptions | string\n```\n\nSee [`VFileOptions`][vfile-options] and [`VFile`][vfile].\n\n### `ReadOptions`\n\nConfiguration for `fs.readFile` (TypeScript type).\n\n###### Fields\n\n*   `encoding` ([`BufferEncoding`][api-buffer-encoding], optional)\n    — encoding to read file as, will turn `file.value` into a `string` if passed\n*   `flag` (`string`, optional)\n    — file system flags to use\n\n### `WriteOptions`\n\nConfiguration for `fs.writeFile` (TypeScript type).\n\n###### Fields\n\n*   `encoding` ([`BufferEncoding`][api-buffer-encoding], optional)\n    — encoding to write file as when `file.value` is a `string`\n*   `mode` (`number | string`, optional)\n    — file mode (permission and sticky bits) if the file was newly created\n*   `flag` (`string`, optional)\n    — file system flags to use\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional types\n[`BufferEncoding`][api-buffer-encoding],\n[`Callback`][api-callback],\n[`Compatible`][api-compatible],\n[`ReadOptions`][api-read-options], and\n[`WriteOptions`][api-write-options].\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `vfile@^8`,\ncompatible with Node.js 16.\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`vfile/.github`][health] for ways to\nget started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n<!-- Definitions -->\n\n[build-badge]: https://github.com/vfile/to-vfile/workflows/main/badge.svg\n\n[build]: https://github.com/vfile/to-vfile/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/vfile/to-vfile.svg\n\n[coverage]: https://codecov.io/github/vfile/to-vfile\n\n[downloads-badge]: https://img.shields.io/npm/dm/to-vfile.svg\n\n[downloads]: https://www.npmjs.com/package/to-vfile\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/vfile/vfile/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[contributing]: https://github.com/vfile/.github/blob/main/contributing.md\n\n[support]: https://github.com/vfile/.github/blob/main/support.md\n\n[health]: https://github.com/vfile/.github\n\n[coc]: https://github.com/vfile/.github/blob/main/code-of-conduct.md\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[vfile]: https://github.com/vfile/vfile\n\n[vfile-options]: https://github.com/vfile/vfile#options\n\n[promise]: https://developer.mozilla.org/Web/JavaScript/Reference/Global_Objects/Promise\n\n[api-read]: #readdescription-options-callback\n\n[api-read-sync]: #readsyncdescription-options\n\n[api-to-vfile]: #tovfiledescription\n\n[api-write]: #writedescription-options-callback\n\n[api-write-sync]: #writesyncdescription-options\n\n[api-buffer-encoding]: #bufferencoding\n\n[api-callback]: #callback\n\n[api-compatible]: #compatible\n\n[api-read-options]: #readoptions\n\n[api-write-options]: #writeoptions\n","publish_time":1675863503784,"_cnpm_publish_time":1675863503784,"dist-tags":{"latest":"8.0.0"}}