Socket
Socket
Sign inDemoInstall

vinyl

Package Overview
Dependencies
2
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vinyl

A virtual file format


Version published
Weekly downloads
5.1M
increased by2%
Maintainers
1
Install size
1.13 MB
Created
Weekly downloads
 

Readme

Source

vinyl NPM version Build Status Coveralls Status Dependency Status

Information

Packagevinyl
DescriptionA virtual file format
Node Version>= 0.9

What is this?

Read this for more info about how this plays into the grand scheme of things https://medium.com/@eschoff/3828e8126466

File

var File = require('vinyl');

var coffeeFile = new File({
  cwd: "/",
  base: "/test/",
  path: "/test/file.coffee",
  contents: new Buffer("test = 123")
});

constructor(options)

options.cwd

Type: String
Default: process.cwd()

options.base

Used for relative pathing. Typically where a glob starts.

Type: String
Default: options.cwd

options.path

Full path to the file.

Type: String
Default: null

options.stat

The result of an fs.stat call. See fs.Stats for more information.

Type: fs.Stats
Default: null

options.contents

File contents.

Type: Buffer, Stream, or null
Default: null

isBuffer()

Returns true if file.contents is a Buffer.

isStream()

Returns true if file.contents is a Stream.

isNull()

Returns true if file.contents is null.

clone()

Returns a new File object with all attributes cloned. Custom attributes are deep-cloned.

pipe(stream[, opt])

If file.contents is a Buffer, it will write it to the stream.

If file.contents is a Stream, it will pipe it to the stream.

If file.contents is null, it will do nothing.

If opt.end is false, the destination stream will not be ended (same as node core).

Returns the stream.

inspect()

Returns a pretty String interpretation of the File. Useful for console.log.

relative

Returns path.relative for the file base and file path.

Example:

var file = new File({
  cwd: "/",
  base: "/test/",
  path: "/test/file.coffee"
});

console.log(file.relative); // file.coffee

FAQs

Last updated on 01 Sep 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc