Socket
Socket
Sign inDemoInstall

vinyl-contents

Package Overview
Dependencies
19
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vinyl-contents

Utility to read the contents of a vinyl file.


Version published
Weekly downloads
321K
increased by3.63%
Maintainers
2
Install size
480 kB
Created
Weekly downloads
 

Changelog

Source

2.0.0 (2022-10-08)

⚠ BREAKING CHANGES

  • Upgrade bl
  • Update vinyl dependency
  • Drop readable-stream & use bl directly (#8)
  • Normalize repository, dropping node <10.13 support

Features

Miscellaneous Chores

  • Normalize repository, dropping node <10.13 support (d40d2b8)

Readme

Source

vinyl-contents

NPM version Downloads Build Status Coveralls Status

Utility to read the contents of a vinyl file.

Usage

/*
  WARNING: This is a very naive plugin implementation
  It is only meant for demonstation purposes.
  For a more complete implementation, see: https://github.com/gulp-community/gulp-pug
*/
var { Transform } = require('streamx');
var pug = require('pug');
var vinylContents = require('vinyl-contents');

function gulpPug(options) {
  return new Transform({
    transform: function (file, cb) {
      vinylContents(file, function (err, contents) {
        if (err) {
          return cb(err);
        }

        if (!contents) {
          return cb();
        }

        file.contents = pug.compile(contents.toString(), options)();
        cb(null, file);
      });
    },
  });
}

API

vinylContents(file, callback)

Warning: Only use this if interacting with a library that can only receive strings or buffers. This loads all streaming contents into memory which can cause unexpected results for your end-users.

Takes a Vinyl file and an error-first callback. Calls the callback with an error if one occur (or if the first argument is not a Vinyl file), or the file contents if no error occurs.

If the Vinyl contents are:

  • A Buffer, will be returned directly.
  • A Stream, will be buffered into a BufferList and returned.
  • Empty, will be undefined.

License

MIT

FAQs

Last updated on 08 Oct 2022

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