Comparing version 5.0.2 to 5.0.3
@@ -10,3 +10,3 @@ 'use strict' | ||
/* Create a virtual file and read it in, asynchronously. */ | ||
// Create a virtual file and read it in, asynchronously. | ||
function read(description, options, callback) { | ||
@@ -52,7 +52,7 @@ var file = vfile(description) | ||
/* Create a virtual file and write it out, asynchronously. */ | ||
// Create a virtual file and write it out, asynchronously. | ||
function write(description, options, callback) { | ||
var file = vfile(description) | ||
/* Weird, right? Otherwise `fs` doesn’t accept it. */ | ||
// Weird, right? Otherwise `fs` doesn’t accept it. | ||
if (!callback && typeof options === 'function') { | ||
@@ -59,0 +59,0 @@ callback = options |
@@ -8,6 +8,5 @@ 'use strict' | ||
/* Create a virtual file from a description. | ||
* If `options` is a string or a buffer, it’s used as the | ||
* path. In all other cases, the options are passed through | ||
* to `vfile()`. */ | ||
// Create a virtual file from a description. If `options` is a string or a | ||
// buffer, it’s used as the path. In all other cases, the options are passed | ||
// through to `vfile()`. | ||
function toVFile(options) { | ||
@@ -14,0 +13,0 @@ if (typeof options === 'string' || buffer(options)) { |
@@ -10,3 +10,3 @@ 'use strict' | ||
/* Create a virtual file and read it in, synchronously. */ | ||
// Create a virtual file and read it in, synchronously. | ||
function readSync(description, options) { | ||
@@ -18,3 +18,3 @@ var file = vfile(description) | ||
/* Create a virtual file and write it out, synchronously. */ | ||
// Create a virtual file and write it out, synchronously. | ||
function writeSync(description, options) { | ||
@@ -21,0 +21,0 @@ var file = vfile(description) |
{ | ||
"name": "to-vfile", | ||
"version": "5.0.2", | ||
"version": "5.0.3", | ||
"description": "Create a vfile from a file-path", | ||
@@ -33,12 +33,12 @@ "license": "MIT", | ||
"browserify": "^16.0.0", | ||
"nyc": "^13.0.0", | ||
"prettier": "^1.12.1", | ||
"nyc": "^14.0.0", | ||
"prettier": "^1.0.0", | ||
"remark-cli": "^6.0.0", | ||
"remark-preset-wooorm": "^4.0.0", | ||
"remark-preset-wooorm": "^5.0.0", | ||
"tape": "^4.0.0", | ||
"tinyify": "^2.4.3", | ||
"xo": "^0.23.0" | ||
"tinyify": "^2.0.0", | ||
"xo": "^0.24.0" | ||
}, | ||
"scripts": { | ||
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix", | ||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix", | ||
"build-bundle": "browserify . -s toVFile > to-vfile.js", | ||
@@ -68,8 +68,2 @@ "build-mangle": "browserify . -s toVFile -p tinyify > to-vfile.min.js", | ||
"esnext": false, | ||
"rules": { | ||
"no-var": "off", | ||
"prefer-arrow-callback": "off", | ||
"object-shorthand": "off", | ||
"unicorn/no-new-buffer": "off" | ||
}, | ||
"ignores": [ | ||
@@ -76,0 +70,0 @@ "to-vfile.js" |
@@ -1,11 +0,19 @@ | ||
# to-vfile [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
# to-vfile | ||
Create a [`vfile`][vfile] from a file-path. Optionally populates them from | ||
the file-system as well. Can write virtual files to file-system too. | ||
[![Build][build-badge]][build] | ||
[![Coverage][coverage-badge]][coverage] | ||
[![Downloads][downloads-badge]][downloads] | ||
[![Sponsors][sponsors-badge]][collective] | ||
[![Backers][backers-badge]][collective] | ||
[![Chat][chat-badge]][chat] | ||
## Installation | ||
Create a [`vfile`][vfile] from a file-path. | ||
Optionally populates them from the file-system as well. | ||
Can write virtual files to file-system too. | ||
## Install | ||
[npm][]: | ||
```bash | ||
```sh | ||
npm install to-vfile | ||
@@ -52,39 +60,45 @@ ``` | ||
Create a virtual file. Works like the [vfile][] constructor, | ||
except when `options` is `string` or `Buffer`, in which case | ||
it’s treated as `{path: options}` instead of `{contents: options}`. | ||
Create a virtual file. | ||
Works like the [vfile][] constructor, except when `options` is `string` or | ||
`Buffer`, in which case it’s treated as `{path: options}` instead of | ||
`{contents: options}`. | ||
### `toVFile.read(options[, encoding][, callback])` | ||
Creates a virtual file from options (`toVFile(options)`), reads the | ||
file from the file-system and populates `file.contents` with the result. | ||
Creates a virtual file from options (`toVFile(options)`), reads the file from | ||
the file-system and populates `file.contents` with the result. | ||
If `encoding` is specified, it’s passed to `fs.readFile`. | ||
If `callback` is given, invokes it with either an error or the populated | ||
virtual file. | ||
If `callback` is not given, returns a [`Promise`][promise] that is | ||
rejected with an error or resolved with the populated virtual file. | ||
If `callback` is given, invokes it with either an error or the populated virtual | ||
file. | ||
If `callback` is not given, returns a [`Promise`][promise] that is rejected with | ||
an error or resolved with the populated virtual file. | ||
### `toVFile.readSync(options[, encoding])` | ||
Like `toVFile.read` but synchronous. Either throws an error or | ||
returns a populated virtual file. | ||
Like `toVFile.read` but synchronous. Either throws an error or returns a | ||
populated virtual file. | ||
### `toVFile.write(options[, fsOptions][, callback])` | ||
Creates a virtual file from `options` (`toVFile(options)`), writes the | ||
file to the file-system. `fsOptions` are passed to `fs.writeFile`. | ||
Creates a virtual file from `options` (`toVFile(options)`), writes the file to | ||
the file-system. | ||
`fsOptions` are passed to `fs.writeFile`. | ||
If `callback` is given, invokes it with an error, if any. | ||
If `callback` is not given, returns a [`Promise`][promise] that is | ||
rejected with an error or resolved without any value. | ||
If `callback` is not given, returns a [`Promise`][promise] that is rejected with | ||
an error or resolved without any value. | ||
### `toVFile.writeSync(options[, fsOptions])` | ||
Like `toVFile.write` but synchronous. Throws an error, if any. | ||
Like `toVFile.write` but synchronous. | ||
Throws an error, if any. | ||
## Contribute | ||
See [`contributing.md` in `vfile/vfile`][contributing] for ways to get started. | ||
See [`contributing.md`][contributing] in [`vfile/.github`][health] for ways to | ||
get started. | ||
See [`support.md`][support] for ways to get help. | ||
This organisation has a [Code of Conduct][coc]. By interacting with this | ||
repository, organisation, or community you agree to abide by its terms. | ||
This project has a [Code of Conduct][coc]. | ||
By interacting with this repository, organisation, or community you agree to | ||
abide by its terms. | ||
@@ -97,12 +111,34 @@ ## License | ||
[travis-badge]: https://img.shields.io/travis/vfile/to-vfile.svg | ||
[build-badge]: https://img.shields.io/travis/vfile/to-vfile.svg | ||
[travis]: https://travis-ci.org/vfile/to-vfile | ||
[build]: https://travis-ci.org/vfile/to-vfile | ||
[codecov-badge]: https://img.shields.io/codecov/c/github/vfile/to-vfile.svg | ||
[coverage-badge]: https://img.shields.io/codecov/c/github/vfile/to-vfile.svg | ||
[codecov]: https://codecov.io/github/vfile/to-vfile | ||
[coverage]: https://codecov.io/github/vfile/to-vfile | ||
[downloads-badge]: https://img.shields.io/npm/dm/to-vfile.svg | ||
[downloads]: https://www.npmjs.com/package/to-vfile | ||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg | ||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg | ||
[collective]: https://opencollective.com/unified | ||
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg | ||
[chat]: https://spectrum.chat/unified/vfile | ||
[npm]: https://docs.npmjs.com/cli/install | ||
[contributing]: https://github.com/vfile/.github/blob/master/contributing.md | ||
[support]: https://github.com/vfile/.github/blob/master/support.md | ||
[health]: https://github.com/vfile/.github | ||
[coc]: https://github.com/vfile/.github/blob/master/code-of-conduct.md | ||
[license]: license | ||
@@ -115,5 +151,1 @@ | ||
[promise]: https://developer.mozilla.org/Web/JavaScript/Reference/Global_Objects/Promise | ||
[contributing]: https://github.com/vfile/vfile/blob/master/contributing.md | ||
[coc]: https://github.com/vfile/vfile/blob/master/code-of-conduct.md |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9922
149
115