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

vinyl

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vinyl

A virtual file format

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.5M
decreased by-19.85%
Maintainers
2
Weekly downloads
 
Created

What is vinyl?

The vinyl npm package is a virtual file format used in Node.js streams. It is commonly used in build systems like Gulp to represent files, allowing for easy manipulation and transformation of file contents and metadata.

What are vinyl's main functionalities?

Creating a Vinyl File

This feature allows you to create a new Vinyl file object. The code sample demonstrates how to create a Vinyl file with a specified current working directory, base path, file path, and contents.

const Vinyl = require('vinyl');
const file = new Vinyl({
  cwd: "/",
  base: "/test/",
  path: "/test/file.js",
  contents: Buffer.from("console.log('Hello, world!');")
});
console.log(file);

Reading File Contents

This feature allows you to read the contents of a Vinyl file. The code sample demonstrates how to create a Vinyl file and then read its contents as a string.

const Vinyl = require('vinyl');
const file = new Vinyl({
  cwd: "/",
  base: "/test/",
  path: "/test/file.js",
  contents: Buffer.from("console.log('Hello, world!');")
});
console.log(file.contents.toString());

Checking File Properties

This feature allows you to check various properties of a Vinyl file, such as whether its contents are a buffer, a stream, or null. The code sample demonstrates how to create a Vinyl file and check these properties.

const Vinyl = require('vinyl');
const file = new Vinyl({
  cwd: "/",
  base: "/test/",
  path: "/test/file.js",
  contents: Buffer.from("console.log('Hello, world!');")
});
console.log(file.isBuffer());
console.log(file.isStream());
console.log(file.isNull());

Other packages similar to vinyl

FAQs

Package last updated on 25 Sep 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc