Vfile

vfile

Virtual file format for text processing.

vfile can be used anywhere where files need a lightweight representation, is a part of unified, a text processing umbrella. Each processors that parse, transform, and compile text, and need a virtual representation of files and a place to store messages about them.

Get it: npm install vfile

Sample usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var vfile = require('vfile')

var file = vfile({path: '~/example.txt', contents: 'Alpha *braavo* charlie.'})

file.path // => '~/example.txt'
file.dirname // => '~'

file.extname = '.md'

file.basename // => 'example.md'

file.basename = 'index.text'

file.history // => ['~/example.txt', '~/example.md', '~/index.text']

file.message('`braavo` is misspelt; did you mean `bravo`?', {
  line: 1,
  column: 8
})

console.log(file.messages)

GIF FTW!

vfile.gif

Suggest a module

Comments