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

most

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

most - npm Package Compare versions

Comparing version 0.18.6 to 0.18.7

33

lib/combinator/combine.js

@@ -10,3 +10,2 @@ /** @license MIT License (c) copyright 2010-2016 original author or authors */

var IndexSink = require('../sink/IndexSink');
var mergeSources = require('./merge').mergeSources;
var dispose = require('../disposable/dispose');

@@ -18,3 +17,3 @@ var base = require('../base');

//var map = base.map;
var map = base.map;
var tail = base.tail;

@@ -46,5 +45,33 @@

: l === 1 ? transform.map(f, streams[0])
: new Stream(mergeSources(CombineSink, f, streams));
: new Stream(combineSources(f, streams));
}
function combineSources(f, streams) {
return new Combine(f, map(getSource, streams))
}
function getSource(stream) {
return stream.source;
}
function Combine(f, sources) {
this.f = f;
this.sources = sources;
}
Combine.prototype.run = function(sink, scheduler) {
var l = this.sources.length;
var disposables = new Array(l);
var sinks = new Array(l);
var mergeSink = new CombineSink(disposables, sinks, sink, this.f);
for(var indexSink, i=0; i<l; ++i) {
indexSink = sinks[i] = new IndexSink(i, mergeSink);
disposables[i] = this.sources[i].run(indexSink, scheduler);
}
return dispose.all(disposables);
};
function CombineSink(disposables, sinks, sink, f) {

@@ -51,0 +78,0 @@ this.sink = sink;

31

lib/combinator/merge.js

@@ -13,7 +13,6 @@ /** @license MIT License (c) copyright 2010-2016 original author or authors */

var copy = base.copy;
var map = base.map;
var reduce = base.reduce;
exports.merge = merge;
exports.mergeArray = mergeArray;
exports.mergeSources = mergeSources;

@@ -39,16 +38,26 @@ /**

: l === 1 ? streams[0]
: new Stream(mergeSources(MergeSink, void 0, streams));
: new Stream(mergeSources(streams));
}
function mergeSources(Sink, arg, streams) {
return new Merge(Sink, arg, map(getSource, streams))
/**
* This implements fusion/flattening for merge. It will
* fuse adjacent merge operations. For example:
* - a.merge(b).merge(c) effectively becomes merge(a, b, c)
* - merge(a, merge(b, c)) effectively becomes merge(a, b, c)
* It does this by concatenating the sources arrays of
* any nested Merge sources, in effect "flattening" nested
* merge operations into a single merge.
*/
function mergeSources(streams) {
return new Merge(reduce(appendSources, [], streams))
}
function getSource(stream) {
return stream.source;
function appendSources(sources, stream) {
var source = stream.source;
return source instanceof Merge
? sources.concat(source.sources)
: sources.concat(source)
}
function Merge(Sink, arg, sources) {
this.Sink = Sink;
this.arg = arg;
function Merge(sources) {
this.sources = sources;

@@ -62,3 +71,3 @@ }

var mergeSink = new this.Sink(disposables, sinks, sink, this.arg);
var mergeSink = new MergeSink(disposables, sinks, sink);

@@ -65,0 +74,0 @@ for(var indexSink, i=0; i<l; ++i) {

{
"name": "most",
"version": "0.18.6",
"version": "0.18.7",
"description": "Monadic streams",

@@ -5,0 +5,0 @@ "main": "most.js",

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