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

vfile

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vfile - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

88

index.js

@@ -1,14 +0,3 @@

/**
* @author Titus Wormer
* @copyright 2015 Titus Wormer
* @license MIT
* @module vfile
* @fileoverview Virtual file format to attach additional
* information related to processed input. Similar to
* `wearefractal/vinyl`.
*/
'use strict';
/* Dependencies. */
var path = require('path');

@@ -21,6 +10,4 @@ var has = require('has');

/* Expose. */
module.exports = VFile;
/* Methods. */
var proto = VFile.prototype;

@@ -35,3 +22,5 @@

/* Order of setting (least specific to most). */
/* Order of setting (least specific to most), we need this because
* otherwise `{stem: 'a', path: '~/b.js'}` would throw, as a path
* is needed before a stem can be set. */
var order = [

@@ -46,8 +35,3 @@ 'history',

/**
* Construct a new file.
*
* @constructor
* @param {Object|VFile|string} [options] - File, contents, or config.
*/
/* Construct a new file. */
function VFile(options) {

@@ -95,5 +79,3 @@ var prop;

/**
* Access complete path (`~/index.min.js`).
*/
/* Access full path (`~/index.min.js`). */
Object.defineProperty(proto, 'path', {

@@ -112,5 +94,3 @@ get: function () {

/**
* Access parent path (`~`).
*/
/* Access parent path (`~`). */
Object.defineProperty(proto, 'dirname', {

@@ -126,5 +106,3 @@ get: function () {

/**
* Access basename (`index.min.js`).
*/
/* Access basename (`index.min.js`). */
Object.defineProperty(proto, 'basename', {

@@ -141,5 +119,3 @@ get: function () {

/**
* Access extname (`.js`).
*/
/* Access extname (`.js`). */
Object.defineProperty(proto, 'extname', {

@@ -169,5 +145,3 @@ get: function () {

/**
* Access stem (`index.min`).
*/
/* Access stem (`index.min`). */
Object.defineProperty(proto, 'stem', {

@@ -184,7 +158,3 @@ get: function () {

/**
* Get the value of the file.
*
* @return {string} - Contents.
*/
/* Get the value of the file. */
function toString(encoding) {

@@ -195,12 +165,5 @@ var value = this.contents || '';

/**
* Create a message with `reason` at `position`.
/* Create a message with `reason` at `position`.
* When an error is passed in as `reason`, copies the
* stack. This does not add a message to `messages`.
*
* @param {string|Error} reason - Reason for message.
* @param {Node|Location|Position} [position] - Place of message.
* @param {string} [ruleId] - Category of message.
* @return {VMessage} - Message.
*/
* stack. This does not add a message to `messages`. */
function message(reason, position, ruleId) {

@@ -229,4 +192,2 @@ var filePath = this.path;

location.start = position;
location.end.line = null;
location.end.column = null;
}

@@ -256,8 +217,4 @@ }

/**
* Fail. Creates a vmessage, associates it with the file,
* and throws it.
*
* @throws {VMessage} - Fatal exception.
*/
/* Fail. Creates a vmessage, associates it with the file,
* and throws it. */
function fail() {

@@ -282,12 +239,7 @@ var message = this.message.apply(this, arguments);

/**
* Construct a new file message.
/* Construct a new file message.
*
* Note: We cannot invoke `Error` on the created context,
* as that adds readonly `line` and `column` attributes on
* Safari 9, thus throwing and failing the data.
*
* @constructor
* @param {string} reason - Reason for messaging.
*/
* Safari 9, thus throwing and failing the data. */
function VMessage(reason) {

@@ -301,5 +253,3 @@ this.message = reason;

if (part.indexOf(path.sep) !== -1) {
throw new Error(
'`' + name + '` cannot be a path: did not expect `' + path.sep + '`'
);
throw new Error('`' + name + '` cannot be a path: did not expect `' + path.sep + '`');
}

@@ -318,6 +268,4 @@ }

if (!path) {
throw new Error(
'Setting `' + name + '` requires `path` to be set too'
);
throw new Error('Setting `' + name + '` requires `path` to be set too');
}
}
{
"name": "vfile",
"version": "2.0.0",
"version": "2.0.1",
"description": "Virtual file format for text processing",

@@ -17,7 +17,11 @@ "license": "MIT",

],
"repository": "https://github.com/wooorm/vfile",
"bugs": "https://github.com/wooorm/vfile/issues",
"repository": "https://github.com/vfile/vfile",
"bugs": "https://github.com/vfile/vfile/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
"Denys Dovhan <email@denysdovhan.com>",
"Kyle Mathews <mathews.kyle@gmail.com>",
"Shinnosuke Watanabe <snnskwtnb@gmail.com>",
"Sindre Sorhus <sindresorhus@gmail.com>"
],

@@ -35,16 +39,12 @@ "dependencies": {

"devDependencies": {
"browserify": "^13.0.0",
"browserify": "^14.0.0",
"esmangle": "^1.0.0",
"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-toc": "^3.0.0",
"remark-validate-links": "^4.0.0",
"nyc": "^10.0.0",
"remark-cli": "^2.0.0",
"remark-preset-wooorm": "^1.0.0",
"tape": "^4.4.0",
"xo": "^0.16.0"
"xo": "^0.17.0"
},
"scripts": {
"build-md": "remark . --quiet --frail",
"build-md": "remark . -qfo",
"build-bundle": "browserify index.js -s VFile > vfile.js",

@@ -66,32 +66,9 @@ "build-mangle": "esmangle vfile.js > vfile.min.js",

"space": true,
"rules": {
"guard-for-in": "off",
"max-lines": "off"
},
"ignores": [
"vfile.js",
"vfile.min.js"
"vfile.js"
]
},
"remarkConfig": {
"output": true,
"plugins": {
"comment-config": null,
"github": null,
"lint": {
"heading-increment": false,
"list-item-spacing": false,
"no-missing-blank-lines": false,
"no-duplicate-headings": false
},
"toc": {
"tight": true,
"maxDepth": 3
},
"validate-links": null
},
"settings": {
"bullet": "*"
}
"presets": "wooorm"
}
}

@@ -6,5 +6,2 @@ # ![vfile][]

> A lot has changed recently, other tools may still use the [1.0.0][]
> API.
**VFile** is a virtual file format used by [**unified**][unified],

@@ -19,3 +16,3 @@ a text processing umbrella (it powers [**retext**][retext] for

> **VFile** is different from the excellent [**vinyl**][vinyl]
> in that it has a smaller API, a smaller size, and focusses on
> in that it has a smaller API, a smaller size, and focuses on
> [messages][].

@@ -34,3 +31,4 @@

* [Usage](#usage)
* [List of Utilities](#list-of-utilities)
* [Utilities](#utilities)
* [Reporters](#reporters)
* [API](#api)

@@ -48,3 +46,3 @@ * [VFile(\[options\])](#vfileoptions)

* [vfile.data](#vfiledata)
* [VFile#toString(\[encoding='utf8'\])](#vfiletostringencodingutf8)
* [VFile#toString(\[encoding\])](#vfiletostringencoding)
* [VFile#message(reason\[, position\[, ruleId\]\])](#vfilemessagereason-position-ruleid)

@@ -62,64 +60,74 @@ * [VFile#fail(reason\[, position\[, ruleId\]\])](#vfilefailreason-position-ruleid)

console.log(file.path);
// '~/example.txt'
file.path; //=> '~/example.txt'
file.dirname; //=> '~'
console.log(file.dirname);
// '~'
file.extname = '.md';
console.log(file.basename);
// 'example.md'
file.basename; //=> 'example.md'
file.basename = 'index.text';
console.log(file.history);
// [ '~/example.txt', '~/example.md', '~/index.text' ]
file.history; //=> ['~/example.txt', '~/example.md', '~/index.text']
file.message('`braavo` is misspelt; did you mean `bravo`?', {line: 1, column: 8});
// { [~/index.text:1:8: `braavo` is misspelt; did you mean `bravo`?]
// message: '`braavo` is misspelt; did you mean `bravo`?',
// name: '~/index.text:1:8',
// file: '~/index.text',
// reason: '`braavo` is misspelt; did you mean `bravo`?',
// line: 1,
// column: 8,
// location:
// { start: { line: 1, column: 8 },
// end: { line: null, column: null } },
// ruleId: null,
// source: null,
// fatal: false }
console.log(file.messages);
```
## List of Utilities
Yields:
```js
[ { [~/index.text:1:8: `braavo` is misspelt; did you mean `bravo`?]
message: '`braavo` is misspelt; did you mean `bravo`?',
name: '~/index.text:1:8',
file: '~/index.text',
reason: '`braavo` is misspelt; did you mean `bravo`?',
line: 1,
column: 8,
location: { start: [Object], end: [Object] },
ruleId: null,
source: null,
fatal: false } ]
```
## Utilities
The following list of projects includes tools for working with virtual
files. See [**Unist**][unist] for projects working with nodes.
* [`dustinspecker/convert-vinyl-to-vfile`](https://github.com/dustinspecker/convert-vinyl-to-vfile)
* [`convert-vinyl-to-vfile`](https://github.com/dustinspecker/convert-vinyl-to-vfile)
— Convert from [Vinyl][];
* [`shinnn/is-vfile-message`](https://github.com/shinnn/is-vfile-message)
* [`is-vfile-message`](https://github.com/shinnn/is-vfile-message)
— Check if a value is a `VFileMessage` object;
* [`wooorm/to-vfile`](https://github.com/wooorm/to-vfile)
* [`to-vfile`](https://github.com/vfile/to-vfile)
— Create a virtual file from a file-path (and optionally read it);
* [`wooorm/vfile-find-down`](https://github.com/wooorm/vfile-find-down)
* [`vfile-find-down`](https://github.com/vfile/vfile-find-down)
— Find files by searching the file system downwards;
* [`wooorm/vfile-find-up`](https://github.com/wooorm/vfile-find-up)
* [`vfile-find-up`](https://github.com/vfile/vfile-find-up)
— Find files by searching the file system upwards;
* [`wooorm/vfile-location`](https://github.com/wooorm/vfile-location)
* [`vfile-location`](https://github.com/vfile/vfile-location)
— Convert between line/column- and range-based locations;
* [`wooorm/vfile-statistics`](https://github.com/wooorm/vfile-statistics)
* [`vfile-statistics`](https://github.com/vfile/vfile-statistics)
— Count messages per category;
* [`shinnn/vfile-messages-to-vscode-diagnostics`](https://github.com/shinnn/vfile-messages-to-vscode-diagnostics)
* [`vfile-messages-to-vscode-diagnostics`](https://github.com/shinnn/vfile-messages-to-vscode-diagnostics)
— Convert to VS Code diagnostics;
* [`wooorm/vfile-reporter`](https://github.com/wooorm/vfile-reporter)
— Stylish reporter.
* [`wooorm/vfile-sort`](https://github.com/wooorm/vfile-sort)
* [`vfile-sort`](https://github.com/vfile/vfile-sort)
— Sort messages by line/column;
* [`sindresorhus/vfile-to-eslint`](https://github.com/sindresorhus/vfile-to-eslint)
— Convert VFiles to ESLint formatter compatible output;
* [`sindresorhus/vfile-reporter-pretty`](https://github.com/sindresorhus/vfile-reporter-pretty)
— Pretty reporter;
* [`vfile-to-eslint`](https://github.com/sindresorhus/vfile-to-eslint)
— Convert VFiles to ESLint formatter compatible output.
## Reporters
The following list of projects show linting results for given virtual files.
Reporters _must_ accept `Array.<VFile>` as their first argument, and return
`string`. Reporters _may_ accept other values too, in which case it’s suggested
to stick to `vfile-reporter`s interface.
* [`vfile-reporter`](https://github.com/vfile/vfile-reporter)
— Stylish reporter;
* [`vfile-reporter-json`](https://github.com/vfile/vfile-reporter-json)
— JSON reporter;
* [`vfile-reporter-pretty`](https://github.com/sindresorhus/vfile-reporter-pretty)
— Pretty reporter.
## API

@@ -137,3 +145,3 @@

It’s not possible to either `dirname` or `extname` without setting
It’s not possible to set either `dirname` or `extname` without setting
either `history`, `path`, `basename`, or `stem` as well.

@@ -199,3 +207,3 @@

### `VFile#toString([encoding='utf8'])`
### `VFile#toString([encoding])`

@@ -257,9 +265,9 @@ Convert contents of `vfile` to string. If `contents` is a buffer,

[build-badge]: https://img.shields.io/travis/wooorm/vfile.svg
[build-badge]: https://img.shields.io/travis/vfile/vfile.svg
[build-status]: https://travis-ci.org/wooorm/vfile
[build-status]: https://travis-ci.org/vfile/vfile
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/vfile.svg
[coverage-badge]: https://img.shields.io/codecov/c/github/vfile/vfile.svg
[coverage-status]: https://codecov.io/github/wooorm/vfile
[coverage-status]: https://codecov.io/github/vfile/vfile

@@ -272,3 +280,3 @@ [npm]: https://docs.npmjs.com/cli/install

[vfile]: https://cdn.rawgit.com/wooorm/vfile/master/logo.svg
[vfile]: https://cdn.rawgit.com/vfile/vfile/a20a566/logo.svg

@@ -283,5 +291,5 @@ [unified]: https://github.com/wooorm/unified

[vinyl]: https://github.com/wearefractal/vinyl
[vinyl]: https://github.com/gulpjs/vinyl
[unist]: https://github.com/wooorm/unist#list-of-utilities
[unist]: https://github.com/syntax-tree/unist#list-of-utilities

@@ -291,3 +299,1 @@ [messages]: #vfilemessagereason-position-ruleid

[message]: #vfilemessage
[1.0.0]: https://github.com/wooorm/vfile/tree/d5abd71
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