🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

stream-from-value

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-from-value

Create streams from (single) arbitrary Javascript values like strings, functions, arrays, etc.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

stream-from-value Dependencies Status Image Build Status Image Coverage Status

Create streams from (single) arbitrary Javascript values like strings, functions, arrays, etc.

npm install stream-from-value --save

Usage

Stream of single String | Buffer

var StreamFromValue = require('stream-from-value');

StreamFromValue('some string')
  .pipe(process.stdout); // output: some string

StreamFromValue(new Buffer('some string'))
  .pipe(process.stdout); // output: some string

Stream of (arbitrary) Javascript Value

var StreamFromValue = require('stream-from-value');

StreamFromValue.obj(['some', 'mixed', 'array', 42]).on('data', function(data){
    console.log(data); // output: [ 'some', 'mixed', 'array', 42 ]
  });

Stream of (single) Gulp File

Gulp files are vinyl files:

npm install vinyl

Test some awsome Gulp plugin:

var StreamFromValue = require('stream-from-value'),
    File = require('vinyl');

var testfile = new File({
      cwd: '/',
      base: '/hello/',
      path: '/hello/world.js',
      contents: new Buffer('console.log("Hello world!");')
    });


StreamFromValue.obj(testfile)
  .pipe(someAwsomeGulpPlugin())
  .on('data', function(file){
    console.log(file.contents.toString()); // dunno what someAwsomeGulpPlugin does :)
  });

API

Class: StreamFromValue

StreamFromValues are Readable streams.

new StreamFromValue(value, [options])

  • value JavaScript value Arbitrary Javascript value like numbers, strings, objects, functions, ...
  • options Object passed through new Readable([options])

Note: The new operator can be omitted.

StreamFromValue#obj(value, [options])

A convenience wrapper for new StreamFromValue(value, {objectMode: true, ...}).

License

Copyright (c) 2014 Michael Mayer

Licensed under the MIT license.

Keywords

readable

FAQs

Package last updated on 11 Jul 2014

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