node package manager

vinyl-rw

vinyl-rw

NPM version Downloads Build Status Coverage Status Tip

A file-system aware vinyl file with first-class string support.

Install

$ npm install --save vinyl-rw

Usage

import File from 'vinyl-rw';
 
const foo = new File('foo.txt', 'Lorem ipsum dolor.');
 
console.log(foo.path);
// -> '/Users/smoeller/repos/vinyl-rw/foo.txt' 
 
console.log(foo.contents);
// -> 'Lorem ipsum dolor.' 

API

new File(options, contents)

  • options {String|Object} - Path or options.
  • contents {String|Buffer|Stream} - (default: null) File contents.

.isString() : Boolean

Returns true if file.contents is a string.

.exists() : Promise

Sync: existsSync() : Boolean

Checks whether the file at file.path exists.

.read([options]) : Promise

Sync: readSync([options]) : File

  • options {String|Object} - (default: 'utf8') Encoding or options.

Reads the contents of file.path into file.contents.

.write([options]) : Promise

Sync: writeSync([options]) : File

  • options {String|Object} - (default: 'utf8') Encoding or options.

Writes file.contents as the contents of file.path.

File.isRW(val) : Boolean

  • val {Any} - An object to inspect.

Returns true if val is a VinylRW file.

Contribute

Standards for this project, including tests, code coverage, and semantics are enforced with a build tool. Pull requests must include passing tests with 100% code coverage and no linting errors.

Test

$ npm test

© Shannon Moeller me@shannonmoeller.com (http://shannonmoeller.com)

Licensed under MIT