npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

always-stream

v1.0.0

Published

Create stream from any value - function, array, string, buffer, promise, number, object and etc. Always returns a function that returns Transform Stream, using [through2][].

Downloads

10

Readme

always-stream npmjs.com The MIT License npm downloads

Create stream from any value - function, array, string, buffer, promise, number, object and etc. Always returns a function that returns Transform Stream, using through2.

code climate standard code style travis build status coverage status dependency status

Note: This is just a thin wrapper around callback2stream and value2stream.

Install

npm i always-stream --save

Usage

For more use-cases see the tests

const alwaysStream = require('always-stream')

alwaysStream

Create a stream from any value.

Params

  • val {Mixed}: Any type of value.
  • [opts] {Object|Function=}: Directly passed to value2stream, callback2stream and through2.
  • [Promize] {Function}: Promise constructor to be used when no support for native Promise. Can be 2nd argument.
  • returns {Function}: That when executed, returns TransformStream, using through2

Example

var fs = require('fs')
var toStream = require('always-stream')

var numberStream = toStream(123)
numberStream().on('data', function (val) {
  console.log(val) // => 123
})
var stringStream = toStream('str foo')
stringStream().on('data', function (val) {
  console.log(val) // => 'str foo'
})

var readFile = toStream(fs.readFile)
readFile('package.json', 'utf8')
  .on('data', function (val) {
    var json = JSON.parse(val)
    console.log(json.name) // => 'always-stream'
  })
  .once('error', console.error)
  .once('end', console.error)

// or sync functions
var statFile = toStream(fs.statSync)
statFile('package.json')
  .on('data', function (stats) {
    console.log(stats) // => stat object
  })
  .once('error', console.error)
  .once('end', console.error)

// also works for native functions
// like JSON.parse and JSON.stringify
// by respect optional arguments
var stringifyStream = toStream(JSON.stringify)
stringifyStream({ foo: 'bar' }, null, 2)
  .on('data', function (val) {
    console.log(val) // => '{\n  "foo": "bar"\n}'
  })
  .once('error', console.error)

Related

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github