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.19.1 to 0.19.2

36

lib/combinator/accumulate.js

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

var runSource = require('../runSource');
var cons = require('./build').cons;
var dispose = require('../disposable/dispose');
var PropagateTask = require('../scheduler/PropagateTask');

@@ -23,5 +24,17 @@ exports.scan = scan;

function scan(f, initial, stream) {
return cons(initial, new Stream(new Accumulate(ScanSink, f, initial, stream.source)));
return new Stream(new Scan(f, initial, stream.source));
}
function Scan(f, z, source) {
this.source = source;
this.f = f;
this.value = z;
}
Scan.prototype.run = function(sink, scheduler) {
var d1 = scheduler.asap(PropagateTask.event(this.value, sink));
var d2 = this.source.run(new ScanSink(this.f, this.value, sink), scheduler);
return dispose.all([d1, d2]);
};
function ScanSink(f, z, sink) {

@@ -52,17 +65,16 @@ this.f = f;

function reduce(f, initial, stream) {
return runSource.withDefaultScheduler(noop, new Accumulate(AccumulateSink, f, initial, stream.source));
return runSource.withDefaultScheduler(noop, new Reduce(f, initial, stream.source));
}
function Accumulate(SinkType, f, z, source) {
this.SinkType = SinkType;
function Reduce(f, z, source) {
this.source = source;
this.f = f;
this.value = z;
this.source = source;
}
Accumulate.prototype.run = function(sink, scheduler) {
return this.source.run(new this.SinkType(this.f, this.value, sink), scheduler);
Reduce.prototype.run = function(sink, scheduler) {
return this.source.run(new ReduceSink(this.f, this.value, sink), scheduler);
};
function AccumulateSink(f, z, sink) {
function ReduceSink(f, z, sink) {
this.f = f;

@@ -73,3 +85,3 @@ this.value = z;

AccumulateSink.prototype.event = function(t, x) {
ReduceSink.prototype.event = function(t, x) {
var f = this.f;

@@ -80,5 +92,5 @@ this.value = f(this.value, x);

AccumulateSink.prototype.error = Pipe.prototype.error;
ReduceSink.prototype.error = Pipe.prototype.error;
AccumulateSink.prototype.end = function(t) {
ReduceSink.prototype.end = function(t) {
this.sink.end(t, this.value);

@@ -85,0 +97,0 @@ };

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

ScheduledTask.prototype.dispose = ScheduledTask.prototype.cancel;
function runTask(task) {

@@ -32,0 +34,0 @@ try {

{
"name": "most",
"version": "0.19.1",
"version": "0.19.2",
"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