Socket
Socket
Sign inDemoInstall

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.1.1 to 2.1.2

10

index.js

@@ -1,12 +0,2 @@

/**
* @author Titus Wormer
* @copyright 2015 Titus Wormer
* @license MIT
* @module to-vfile
* @fileoverview Read files from the file-system.
*/
'use strict';
/* Expose. */
module.exports = require('./lib/fs');

22

lib/core.js

@@ -1,30 +0,14 @@

/**
* @author Titus Wormer
* @copyright 2015 Titus Wormer
* @license MIT
* @module to-vfile
* @fileoverview Create virtual files by file-path.
*/
'use strict';
/* Dependencies. */
var buffer = require('is-buffer');
var string = require('x-is-string');
var vfile = require('vfile');
/* Expose. */
module.exports = toVFile;
/**
* Create a virtual file from a description.
/* 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()`.
*
* @param {string|buffer|Object} description - File description.
* @param {Object|string} [options] - `fs.readFile` options.
*/
* to `vfile()`. */
function toVFile(options) {
if (string(options) || buffer(options)) {
if (typeof options === 'string' || buffer(options)) {
options = {path: String(options)};

@@ -31,0 +15,0 @@ }

@@ -1,16 +0,6 @@

/**
* @author Titus Wormer
* @copyright 2015 Titus Wormer
* @license MIT
* @module to-vfile
* @fileoverview Read and write virtual files from the file-system.
*/
'use strict';
/* Dependencies. */
var fs = require('fs');
var vfile = require('./core');
/* Expose. */
module.exports = vfile;

@@ -23,9 +13,3 @@

/**
* Create a virtual file and read it in, asynchronously.
*
* @param {*} description - File description.
* @param {Object|string} [options] - `fs.readFile` options.
* @param {Function} callback - Callback.
*/
/* Create a virtual file and read it in, asynchronously. */
function read(description, options, callback) {

@@ -49,8 +33,3 @@ var file = vfile(description);

/**
* Create a virtual file and read it in, synchronously.
*
* @param {*} description - File description.
* @param {Object|string} [options] - `fs.readFile` options.
*/
/* Create a virtual file and read it in, synchronously. */
function readSync(description, options) {

@@ -62,9 +41,3 @@ var file = vfile(description);

/**
* Create a virtual file and write it out, asynchronously.
*
* @param {*} description - File description.
* @param {Object|string} [options] - `fs.writeFile` options.
* @param {Function} callback - Callback.
*/
/* Create a virtual file and write it out, asynchronously. */
function write(description, options, callback) {

@@ -82,8 +55,3 @@ var file = vfile(description);

/**
* Create a virtual file and write it out, synchronously.
*
* @param {*} description - File description.
* @param {Object|string} [options] - `fs.writeFile` options.
*/
/* Create a virtual file and write it out, synchronously. */
function writeSync(description, options) {

@@ -90,0 +58,0 @@ var file = vfile(description);

30

package.json
{
"name": "to-vfile",
"version": "2.1.1",
"version": "2.1.2",
"description": "Create a vfile from a file-path",

@@ -17,4 +17,3 @@ "license": "MIT",

"is-buffer": "^1.1.4",
"vfile": "^2.0.0",
"x-is-string": "^0.1.0"
"vfile": "^2.0.0"
},

@@ -27,4 +26,4 @@ "main": "index.js",

],
"repository": "https://github.com/wooorm/to-vfile",
"bugs": "https://github.com/wooorm/to-vfile/issues",
"repository": "https://github.com/vfile/to-vfile",
"bugs": "https://github.com/vfile/to-vfile/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",

@@ -35,12 +34,12 @@ "contributors": [

"devDependencies": {
"browserify": "^13.0.1",
"browserify": "^14.0.0",
"esmangle": "^1.0.1",
"nyc": "^8.1.0",
"remark-cli": "^2.0.0",
"remark-preset-wooorm": "^1.0.0",
"nyc": "^11.0.0",
"remark-cli": "^3.0.0",
"remark-preset-wooorm": "^3.0.0",
"tape": "^4.0.0",
"xo": "^0.16.0"
"xo": "^0.18.0"
},
"scripts": {
"build-md": "remark . --quiet --frail",
"build-md": "remark . -qfo",
"build-bundle": "browserify index.js --bare -s toVFile > to-vfile.js",

@@ -62,2 +61,6 @@ "build-mangle": "esmangle to-vfile.js > to-vfile.min.js",

"space": true,
"esnext": false,
"rules": {
"unicorn/no-new-buffer": "off"
},
"ignores": [

@@ -68,5 +71,6 @@ "to-vfile.js"

"remarkConfig": {
"output": true,
"presets": "wooorm"
"plugins": [
"preset-wooorm"
]
}
}
# to-vfile [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
Create a [vfile][] from a file-path. Optionally populates them from
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.

@@ -8,3 +8,3 @@

[npm][npm-install]:
[npm][]:

@@ -15,16 +15,12 @@ ```bash

> **Note:** the file-system stuff is not available in the browser.
> **Note**: the file-system stuff is not available in the browser.
## Usage
Dependencies:
```js
var toVFile = require('to-vfile');
```
var vfile = require('to-vfile');
Create a virtual file by its file-path:
```js
toVFile('readme.md');
console.log(vfile('readme.md'));
console.log(vfile.readSync('.git/HEAD'));
console.log(vfile.readSync('.git/HEAD', 'utf8'));
```

@@ -40,13 +36,2 @@

cwd: '/Users/tilde/projects/oss/to-vfile' }
```
Populate a virtual file:
```js
toVFile.readSync('.git/HEAD', 'utf8');
```
Yields:
```js
VFile {

@@ -57,2 +42,8 @@ data: {},

cwd: '/Users/tilde/projects/oss/to-vfile',
contents: <Buffer 72 65 66 3a 20 72 65 66 73 2f 68 65 61 64 73 2f 6d 61 73 74 65 72 0a> }
VFile {
data: {},
messages: [],
history: [ '.git/HEAD' ],
cwd: '/Users/tilde/projects/oss/to-vfile',
contents: 'ref: refs/heads/master\n' }

@@ -97,11 +88,11 @@ ```

[travis-badge]: https://img.shields.io/travis/wooorm/to-vfile.svg
[travis-badge]: https://img.shields.io/travis/vfile/to-vfile.svg
[travis]: https://travis-ci.org/wooorm/to-vfile
[travis]: https://travis-ci.org/vfile/to-vfile
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/to-vfile.svg
[codecov-badge]: https://img.shields.io/codecov/c/github/vfile/to-vfile.svg
[codecov]: https://codecov.io/github/wooorm/to-vfile
[codecov]: https://codecov.io/github/vfile/to-vfile
[npm-install]: https://docs.npmjs.com/cli/install
[npm]: https://docs.npmjs.com/cli/install

@@ -112,2 +103,2 @@ [license]: LICENSE

[vfile]: https://github.com/wooorm/vfile
[vfile]: https://github.com/vfile/vfile
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