vinyl-rw
An extended Vinyl class that defaults to working with strings and has the ability to read and write to the file system.
Install
$ npm install --save vinyl-rw
Usage
; const foo = 'foo.txt' 'Lorem ipsum.'; console;// -> '/Users/smoeller/repos/vinyl-rw/foo.txt' console;// -> 'Lorem ipsum.'
API
Extends the Vinyl API with the following:
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.
'foo.txt' ; // -> true
.read([options]) : Promise
Sync: readSync([options]) : File
options
{String|Object}
- (default:'utf8'
) Encoding or options.
Reads the contents of file.path
into file.contents
.
'foo.txt' ; // -> 'Lorem ipsum.'
.write([options]) : Promise
Sync: writeSync([options]) : File
options
{String|Object}
- (default:'utf8'
) Encoding or options.
Writes file.contents
as the contents of file.path
.
'foo.txt' 'Lorem ipsum.' ; // -> '/Users/smoeller/repos/vinyl-rw/foo.txt'
File.isRW(val) : Boolean
val
{Any}
- An object to inspect.
Returns true
if val
is a VinylRW file.
const vinyl = ;const file = ; console;// -> false console;// -> true
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