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

kefir-cast

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kefir-cast

Convert various types of streams to Kefir streams.

  • 3.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
increased by19.57%
Maintainers
1
Weekly downloads
 
Created
Source

KefirCast

Circle CI npm version

Converts various types of streams to Kefir streams. This is intended for use by libraries which use Kefir internally, but want to be able to accept streams from other libraries or other versions of Kefir as arguments given by the application.

  • Supports converting RxJS Observables into Kefir streams.
  • Supports converting Bacon.js streams into Kefir streams.
  • Supports converting a Kefir stream created by one instance of the Kefir library into a stream usable by a different instance of a Kefir library. (This smooths over possible issues if the application uses a different version of Kefir.)
  • Casts non-streams into a Kefir stream of one item by using Kefir.constant().

KefirCast is intended for use in nodejs and in browsers via CommonJS bundlers like Browserify. This project is in NPM and can be installed with

npm install kefir-cast

The related project BaconCast exists to convert streams to Bacon.js streams.

Example

Suppose you have a library that exports a single function doStuff, which can take a stream as an argument. By using KefirCast, you can support any RxJS streams, Kefir streams, Bacon.js streams, or constants that your users might pass to you.

var Kefir = require('kefir');
var kefirCast = require('kefir-cast');

module.exports = function doStuff(input) {
  var inputStream = kefirCast(Kefir, input);
  // Log anything that comes through the stream for 5 seconds.
  inputStream.takeUntilBy(Kefir.later(5000)).onValue(function(value) {
    console.log('doStuff received value', value);
  });
};

If you did not use KefirCast, then your users would be required to use the same version of Kefir as you, you wouldn't support RxJS or Bacon streams without more work, and you would have to handle non-stream constant values specially.

API

kefirCast(Kefir, input) takes your Kefir library instance as the first argument, and the input stream or constant to convert into a Kefir stream as the second argument. A Kefir stream compatible with the given Kefir library will be returned.

Keywords

FAQs

Package last updated on 25 Feb 2016

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