Comparing version 2.0.0 to 2.1.0
@@ -6,3 +6,3 @@ /** | ||
* @module to-vfile | ||
* @fileoverview Read virtual files from the file-system. | ||
* @fileoverview Read and write virtual files from the file-system. | ||
*/ | ||
@@ -19,4 +19,6 @@ | ||
vfile.read = async; | ||
vfile.readSync = sync; | ||
vfile.read = read; | ||
vfile.readSync = readSync; | ||
vfile.write = write; | ||
vfile.writeSync = writeSync; | ||
@@ -26,7 +28,7 @@ /** | ||
* | ||
* @param {string|buffer|Object} description - File description. | ||
* @param {*} description - File description. | ||
* @param {Object|string} [options] - `fs.readFile` options. | ||
* @param {Function} callback - Callback. | ||
*/ | ||
function async(description, options, callback) { | ||
function read(description, options, callback) { | ||
var file = vfile(description); | ||
@@ -52,6 +54,6 @@ | ||
* | ||
* @param {string|buffer|Object} description - File description. | ||
* @param {*} description - File description. | ||
* @param {Object|string} [options] - `fs.readFile` options. | ||
*/ | ||
function sync(description, options) { | ||
function readSync(description, options) { | ||
var file = vfile(description); | ||
@@ -61,1 +63,31 @@ file.contents = fs.readFileSync(file.path, options); | ||
} | ||
/** | ||
* Create a virtual file and write it out, asynchronously. | ||
* | ||
* @param {*} description - File description. | ||
* @param {Object|string} [options] - `fs.writeFile` options. | ||
* @param {Function} callback - Callback. | ||
*/ | ||
function write(description, options, callback) { | ||
var file = vfile(description); | ||
/* Weird, right? Otherwise `fs` doesn’t accept it. */ | ||
if (!callback) { | ||
callback = options; | ||
options = undefined; | ||
} | ||
fs.writeFile(file.path, String(file), options, callback); | ||
} | ||
/** | ||
* Create a virtual file and write it out, synchronously. | ||
* | ||
* @param {*} description - File description. | ||
* @param {Object|string} [options] - `fs.writeFile` options. | ||
*/ | ||
function writeSync(description, options) { | ||
var file = vfile(description); | ||
fs.writeFileSync(file.path, String(file), options); | ||
} |
{ | ||
"name": "to-vfile", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Create a vfile from a file-path", | ||
@@ -36,7 +36,4 @@ "license": "MIT", | ||
"nyc": "^8.1.0", | ||
"remark-cli": "^1.0.0", | ||
"remark-comment-config": "^4.0.0", | ||
"remark-github": "^5.0.0", | ||
"remark-lint": "^4.0.0", | ||
"remark-validate-links": "^4.0.0", | ||
"remark-cli": "^2.0.0", | ||
"remark-preset-wooorm": "^1.0.0", | ||
"tape": "^4.0.0", | ||
@@ -69,12 +66,4 @@ "xo": "^0.16.0" | ||
"output": true, | ||
"plugins": { | ||
"comment-config": null, | ||
"github": null, | ||
"lint": null, | ||
"validate-links": null | ||
}, | ||
"settings": { | ||
"bullet": "*" | ||
} | ||
"presets": "wooorm" | ||
} | ||
} |
# to-vfile [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
Create a [vfile][] from a file-path. Optionally populates them from | ||
the file-system as well. | ||
the file-system as well. Can write virtual files to file-system too. | ||
@@ -77,2 +77,12 @@ ## Installation | ||
### `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`. | ||
Invokes `callback` with an error, if any. | ||
### `toVFile.writeSync(options[, fsOptions])` | ||
Like `toVFile.write` but synchronous. Throws an error, if any. | ||
## License | ||
@@ -79,0 +89,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
8202
7
115
108
0