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.8 to 0.19.0

lib/sink/SafeSink.js

3

lib/combinator/accumulate.js

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

var cons = require('./build').cons;
var noop = require('../base').noop;

@@ -83,1 +82,3 @@ exports.scan = scan;

};
function noop() {}

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

var combine = require('./combine').combine;
var apply = require('../base').apply;
var apply = require('@most/prelude').apply;

@@ -9,0 +9,0 @@ exports.ap = ap;

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

var dispose = require('../disposable/dispose');
var base = require('../base');
var base = require('@most/prelude');
var invoke = require('../invoke');

@@ -14,0 +14,0 @@

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

var mergeConcurrently = require('./mergeConcurrently').mergeConcurrently;
var map = require('./transform').map;
var mergeMapConcurrently = require('./mergeConcurrently').mergeMapConcurrently;

@@ -23,3 +22,3 @@ exports.concatMap = concatMap;

function concatMap(f, stream) {
return mergeConcurrently(1, map(f, stream));
return mergeMapConcurrently(f, 1, stream);
}

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

var ValueSource = require('../source/ValueSource');
var tryDispose = require('../disposable/dispose').tryDispose;
var SafeSink = require('../sink/SafeSink');
var Pipe = require('../sink/Pipe');
var dispose = require('../disposable/dispose');
var tryEvent = require('../source/tryEvent');
var apply = require('../base').apply;
var isPromise = require('../Promise').isPromise;

@@ -51,37 +53,37 @@ exports.flatMapError = recoverWith;

this.f = f;
this.sink = sink;
this.sink = new SafeSink(sink);
this.scheduler = scheduler;
this.active = true;
this.disposable = source.run(this, scheduler);
}
RecoverWithSink.prototype.event = function(t, x) {
tryEvent.tryEvent(t, x, this.sink);
}
RecoverWithSink.prototype.end = function(t, x) {
tryEvent.tryEnd(t, x, this.sink);
}
RecoverWithSink.prototype.error = function(t, e) {
if(!this.active) {
return;
}
var nextSink = this.sink.disable();
// TODO: forward dispose errors
tryDispose(t, this.disposable, this);
var stream = apply(this.f, e);
this.disposable = stream.source.run(this.sink, this.scheduler);
var result = dispose.tryDispose(t, this.disposable, nextSink);
this.disposable = isPromise(result)
? dispose.promised(this._thenContinue(result, e, nextSink))
: this._continue(this.f, e, nextSink);
};
RecoverWithSink.prototype.event = function(t, x) {
if(!this.active) {
return;
}
tryEvent.tryEvent(t, x, this.sink);
RecoverWithSink.prototype._thenContinue = function(p, x, sink) {
var self = this;
return p.then(function () {
return self._continue(self.f, x, sink);
});
};
RecoverWithSink.prototype.end = function(t, x) {
if(!this.active) {
return;
}
tryEvent.tryEnd(t, x, this.sink);
RecoverWithSink.prototype._continue = function(f, x, sink) {
return f(x).source.run(sink, this.scheduler);
};
RecoverWithSink.prototype.dispose = function() {
this.active = false;
return this.disposable.dispose();
};

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

var mergeConcurrently = require('./mergeConcurrently').mergeConcurrently;
var map = require('./transform').map;
var mergeMapConcurrently = require('./mergeConcurrently').mergeMapConcurrently;

@@ -20,3 +20,3 @@ exports.flatMap = flatMap;

function flatMap(f, stream) {
return join(map(f, stream));
return mergeMapConcurrently(f, Infinity, stream);
}

@@ -23,0 +23,0 @@

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

var dispose = require('../disposable/dispose');
var base = require('../base');
var base = require('@most/prelude');

@@ -13,0 +13,0 @@ var copy = base.copy;

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

var LinkedList = require('../LinkedList');
var identity = require('@most/prelude').id;
exports.mergeConcurrently = mergeConcurrently;
exports.mergeMapConcurrently = mergeMapConcurrently;
function mergeConcurrently(concurrency, stream) {
return new Stream(new MergeConcurrently(concurrency, stream.source));
return mergeMapConcurrently(identity, concurrency, stream);
}
function MergeConcurrently(concurrency, source) {
function mergeMapConcurrently(f, concurrency, stream) {
return new Stream(new MergeConcurrently(f, concurrency, stream.source));
}
function MergeConcurrently(f, concurrency, source) {
this.f = f;
this.concurrency = concurrency;

@@ -22,6 +29,7 @@ this.source = source;

MergeConcurrently.prototype.run = function(sink, scheduler) {
return new Outer(this.concurrency, this.source, sink, scheduler);
return new Outer(this.f, this.concurrency, this.source, sink, scheduler);
};
function Outer(concurrency, source, sink, scheduler) {
function Outer(f, concurrency, source, sink, scheduler) {
this.f = f;
this.concurrency = concurrency;

@@ -51,5 +59,9 @@ this.sink = sink;

this.current.add(innerSink);
innerSink.disposable = stream.source.run(innerSink, this.scheduler);
innerSink.disposable = mapAndRun(this.f, innerSink, this.scheduler, stream);
};
function mapAndRun(f, innerSink, scheduler, stream) {
return f(stream).source.run(innerSink, scheduler);
}
Outer.prototype.end = function(t, x) {

@@ -56,0 +68,0 @@ this.active = false;

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

var runSource = require('../runSource');
var noop = require('../base').noop;

@@ -32,1 +31,3 @@ exports.observe = observe;

}
function noop() {}

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

var dispose = require('../disposable/dispose');
var base = require('../base');
var base = require('@most/prelude');
var invoke = require('../invoke');

@@ -36,3 +36,3 @@

function sampleWith(sampler, stream) {
return new Stream(new Sampler(base.identity, sampler.source, [stream.source]));
return new Stream(new Sampler(base.id, sampler.source, [stream.source]));
}

@@ -82,3 +82,3 @@

Hold.prototype.end = base.noop;
Hold.prototype.end = function () {};
Hold.prototype.error = Pipe.prototype.error;

@@ -85,0 +85,0 @@

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

var dispose = require('../disposable/dispose');
var Map = require('../fusion/Map');

@@ -44,19 +45,35 @@ exports.take = take;

return end <= start ? core.empty()
: new Stream(new Slice(start, end, stream.source));
: new Stream(sliceSource(start, end, stream.source));
}
function sliceSource(start, end, source) {
return source instanceof Map ? commuteMapSlice(start, end, source)
: source instanceof Slice ? fuseSlice(start, end, source)
: new Slice(start, end, source);
}
function commuteMapSlice(start, end, source) {
return Map.create(source.f, sliceSource(start, end, source.source))
}
function fuseSlice(start, end, source) {
start += source.min;
end = Math.min(end + source.min, source.max);
return new Slice(start, end, source.source);
}
function Slice(min, max, source) {
this.skip = min;
this.take = max - min;
this.source = source;
this.min = min;
this.max = max;
}
Slice.prototype.run = function(sink, scheduler) {
return new SliceSink(this.skip, this.take, this.source, sink, scheduler);
return new SliceSink(this.min, this.max - this.min, this.source, sink, scheduler);
};
function SliceSink(skip, take, source, sink, scheduler) {
this.sink = sink;
this.skip = skip;
this.take = take;
this.sink = sink;
this.disposable = dispose.once(source.run(this, scheduler));

@@ -63,0 +80,0 @@ }

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

var Stream = require('../Stream');
var MulticastSource = require('@most/multicast').MulticastSource;
var until = require('./timeslice').takeUntil;
var mergeConcurrently = require('./mergeConcurrently').mergeConcurrently;
var map = require('./transform').map;
var dispose = require('../disposable/dispose')

@@ -21,9 +18,95 @@ exports.switch = switchLatest;

function switchLatest(stream) {
var upstream = new Stream(new MulticastSource(stream.source));
return new Stream(new Switch(stream.source));
}
return mergeConcurrently(1, map(untilNext, upstream));
function Switch(source) {
this.source = source;
}
function untilNext(s) {
return until(upstream, s);
Switch.prototype.run = function(sink, scheduler) {
var switchSink = new SwitchSink(sink, scheduler);
return dispose.all(switchSink, this.source.run(switchSink, scheduler));
};
function SwitchSink(sink, scheduler) {
this.sink = sink;
this.scheduler = scheduler;
this.current = null;
this.ended = false;
}
SwitchSink.prototype.event = function(t, stream) {
this._disposeCurrent(t); // TODO: capture the result of this dispose
this.current = new Segment(t, Infinity, this, this.sink);
this.current.disposable = stream.source.run(this.current, this.scheduler);
};
SwitchSink.prototype.end = function(t, x) {
this.ended = true;
this._checkEnd(t, x);
};
SwitchSink.prototype.error = function(t, e) {
this.ended = true;
this.sink.error(t, e);
};
SwitchSink.prototype.dispose = function() {
return this._disposeCurrent(0);
};
SwitchSink.prototype._disposeCurrent = function(t) {
if(this.current !== null) {
return this.current._dispose(t);
}
};
SwitchSink.prototype._disposeInner = function(t, inner) {
inner._dispose(t); // TODO: capture the result of this dispose
if(inner === this.current) {
this.current = null;
}
};
SwitchSink.prototype._checkEnd = function(t, x) {
if(this.ended && this.current === null) {
this.sink.end(t, x);
}
};
SwitchSink.prototype._endInner = function(t, x, inner) {
this._disposeInner(t, inner);
this._checkEnd(t, x);
};
SwitchSink.prototype._errorInner = function(t, e, inner) {
this._disposeInner(t, inner);
this.sink.error(t, e);
};
function Segment(min, max, outer, sink) {
this.min = min;
this.max = max;
this.outer = outer;
this.sink = sink;
this.disposable = dispose.empty();
}
Segment.prototype.event = function(t, x) {
if(t < this.max) {
this.sink.event(Math.max(t, this.min), x);
}
};
Segment.prototype.end = function(t, x) {
this.outer._endInner(Math.max(t, this.min), x, this);
};
Segment.prototype.error = function(t, e) {
this.outer._errorInner(Math.max(t, this.min), e, this);
};
Segment.prototype._dispose = function(t) {
this.max = t;
dispose.tryDispose(t, this.disposable, this.sink)
};

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

var join = require('../combinator/flatMap').join;
var noop = require('../base').noop;

@@ -117,1 +116,3 @@ exports.during = during;

};
function noop() {}

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

var dispose = require('../disposable/dispose');
var base = require('../base');
var base = require('@most/prelude');
var invoke = require('../invoke');

@@ -14,0 +14,0 @@ var Queue = require('../Queue');

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

var isPromise = require('../Promise').isPromise;
var base = require('../base');
var base = require('@most/prelude');
var map = base.map;
var identity = base.identity;
var identity = base.id;

@@ -14,0 +14,0 @@ exports.tryDispose = tryDispose;

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

var FilterMap = require('./FilterMap');
var base = require('../base');
var base = require('@most/prelude');

@@ -11,0 +11,0 @@ module.exports = Map;

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

var base = require('./../base');
var base = require('@most/prelude');

@@ -8,0 +8,0 @@ module.exports = Scheduler;

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

var fromIterable = require('./fromIterable').fromIterable;
var isArrayLike = require('../base').isArrayLike;
var isArrayLike = require('@most/prelude').isArrayLike;

@@ -11,0 +11,0 @@ exports.from = from;

@@ -6,3 +6,3 @@ /** @license MIT License (c) copyright 2010-2014 original author or authors */

var Stream = require('../Stream');
var base = require('../base');
var base = require('@most/prelude');

@@ -9,0 +9,0 @@ exports.generate = generate;

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

var Stream = require('./lib/Stream');
var base = require('./lib/base');
var base = require('@most/prelude');
var core = require('./lib/source/core');

@@ -9,0 +9,0 @@ var from = require('./lib/source/from').from;

{
"name": "most",
"version": "0.18.8",
"version": "0.19.0",
"description": "Monadic streams",

@@ -47,4 +47,5 @@ "main": "most.js",

"dependencies": {
"@most/multicast": "^1.0.3"
"@most/multicast": "^1.0.3",
"@most/prelude": "^1.1.0"
}
}
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