{"name":"to-vfile","version":"7.2.3","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/tape":"^4.0.0","c8":"^7.0.0","prettier":"^2.0.0","remark-cli":"^10.0.0","remark-preset-wooorm":"^9.0.0","rimraf":"^3.0.0","tape":"^5.0.0","type-coverage":"^2.0.0","typescript":"^4.0.0","xo":"^0.47.0"},"scripts":{"prepack":"npm run build && npm run format","build":"rimraf \"{lib/**,}*.d.ts\" && tsc && type-coverage","format":"remark . -qfo && prettier . -w --loglevel warn && xo --fix","test-api":"node test.js","test-coverage":"c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js","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":"4084077798c0c9ab001d8afdf0548abd90fe8333","homepage":"https://github.com/vfile/to-vfile#readme","_id":"to-vfile@7.2.3","_nodeVersion":"17.0.1","_npmVersion":"8.1.0","dist":{"integrity":"sha512-QO0A9aE6Z/YkmQadJ0syxpmNXtcQiu0qAtCKYKD5cS3EfgfFTAXfgLX6AOaBrSfWSek5nfsMf3gBZ9KGVFcLuw==","shasum":"4e54ad10878901703f1a956a33ba4f131c31eef7","tarball":"http://registry-npm.ywwl.com/to-vfile/download/to-vfile-7.2.3.tgz","fileCount":7,"unpackedSize":16465,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh0ZJNCRA9TVsSAnZWagAA6F8P/1R2KBOE3aABBf4N7MIu\nUk6vpOrQ7HsONn1EwrYP6CdoySd13hbS3eLDIo6bZsRCyK0Cc+3/GOH954l1\njbXomc2YayfQ0xZijdCbynPr/IPCxehM/TI+I58xxpf2WsQQnyvyzY1qI5Gx\noLXbyThEeEkIaVOHlTWbmjVQHjKFocBNw05i2OOjEO9VwW2utnJfOviF0oUE\n6XRJdpglDJTNaUL0mqOzdPimlYL36eth8dFSlnTtgUvht8dU4duiBhc8mvNJ\nf7o5kOYAuFh4is1a6uvIyli1e+E16bVWKwQAYyXhH/6DlO6Iz1kyv38Hy5Gn\nmdUebfQpP9tlvxEUKYKfMOLOcfTkj/T90MUqo20awoHpvIhFuG7u55sLVNPR\ntUEjjnMc3lwoSCfFoFtiZST9/A3IDpyA/dLf24mBNH4n+UR7ieaf9S61E1k4\nYKzzKkUsc54JrMA5KTGgz5gTbfQ/qIx9AFHm5R0f5J/xlBmR5RiTBKEdn4Yb\n2mvMfgbRhEsuAjGuWF94WEXi0bpZZ5tQDOT8kzKGImcn3rnA6xL+eFVqISqv\nVWKtaSnBLKHgWKlbY4amVKbzu0OUubXeUU5Qz1QIcMYV/5gKsOThBgYVIqxP\nhlMNKAl/yalELyuGw1uNRBBSKt/yx0wSO/S357YuvzerAbNHiCOxfAZRLChO\nQWC+\r\n=/njs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIASbySPrXoMIvxzevI4rmGD6hMuEKwUoMYTW22DQtvT2AiAM20vDaCD+YVCTx4u1hF56Fkar6oSv1wHySNDJj4VOaQ=="}],"size":4948,"noattachment":false,"key":"/to-vfile/-/to-vfile-7.2.3.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.3_1641124428895_0.008634811965831268"},"_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":1641124429006,"_cnpm_publish_time":1641124429006,"dist-tags":{"latest":"8.0.0"}}