Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

to-vfile

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

to-vfile - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

46

lib/fs.js

@@ -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);
}

19

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc