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

cycle-gear

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cycle-gear - npm Package Compare versions

Comparing version 6.0.1 to 7.0.0

5

dist-es2015/index.d.ts

@@ -21,4 +21,5 @@ import { Observable } from 'xstream';

export interface ToothConnector<TActions, TModel, TTooth, TAccumulator> {
reduce: ToothReduce<TActions, TModel, TTooth, TAccumulator>;
init: () => TAccumulator;
fold?: boolean;
reduce?: ToothReduce<TActions, TModel, TTooth, TAccumulator>;
init?: () => TAccumulator;
isolate?: (sources: any, sink: Observable<any>, gear: Gear<TActions, TModel>) => Observable<any>;

@@ -25,0 +26,0 @@ }

21

dist-es2015/index.js

@@ -82,2 +82,14 @@ import { adapt } from '@cycle/run/lib/adapt';

}
const defaultReduce = (acc, [cur, gear]) => (Object.assign({}, acc, { [gear.name || '?']: cur }));
function connectTeeth(teeth, connector) {
const merged = xs.merge(...teeth);
if (connector.fold) {
return merged
.fold(connector.reduce || defaultReduce, connector.init || {});
}
else {
return merged
.map(([cur]) => cur);
}
}
function spinGears(sources, defaultIntent, defaultModel, defaultCatch, teeth, toothFilter, toothView, sourcesWrapper, defaultConnector, connectors) {

@@ -110,11 +122,6 @@ const modelCache = new WeakMap();

}
return teeth.reduce((accum, tooth) => (Object.assign({}, accum, { [tooth]: xs.merge(...views[tooth])
.fold(connectors.has(tooth) ? connectors.get(tooth).reduce : defaultConnector.reduce, connectors.has(tooth) ? connectors.get(tooth).init() : defaultConnector.init()) })), {});
return teeth.reduce((accum, tooth) => (Object.assign({}, accum, { [tooth]: connectTeeth(views[tooth], connectors.get(tooth) || defaultConnector) })), {});
};
}
const defaultDefaultConnector = {
reduce: (acc, [cur, gear]) => (Object.assign({}, acc, { [gear.name || '?']: cur })),
init: () => ({})
};
export function motor(gearbox, { defaultGear = { intent: () => ({}), model: () => xs.of({}), teeth: {} }, defaultFilter = () => true, defaultConnector = defaultDefaultConnector, sourcesWrapper = (sources) => sources, connectors = new Map(), sinkMap = new Map() } = {}) {
export function motor(gearbox, { defaultGear = { intent: () => ({}), model: () => xs.of({}), teeth: {} }, defaultFilter = () => true, defaultConnector = {}, sourcesWrapper = (sources) => sources, connectors = new Map(), sinkMap = new Map() } = {}) {
const { defaultIntent, defaultModel, defaultCatch, teeth, toothFilter, toothView, emptyTeeth } = defaultsAndHelpers(defaultGear, defaultFilter);

@@ -121,0 +128,0 @@ return (sources) => {

@@ -21,4 +21,5 @@ import { Observable } from 'xstream';

export interface ToothConnector<TActions, TModel, TTooth, TAccumulator> {
reduce: ToothReduce<TActions, TModel, TTooth, TAccumulator>;
init: () => TAccumulator;
fold?: boolean;
reduce?: ToothReduce<TActions, TModel, TTooth, TAccumulator>;
init?: () => TAccumulator;
isolate?: (sources: any, sink: Observable<any>, gear: Gear<TActions, TModel>) => Observable<any>;

@@ -25,0 +26,0 @@ }

@@ -144,2 +144,21 @@ "use strict";

exports.pedal = pedal;
var defaultReduce = function (acc, _a) {
var _b = __read(_a, 2), cur = _b[0], gear = _b[1];
return (__assign({}, acc, (_c = {}, _c[gear.name || '?'] = cur, _c)));
var _c;
};
function connectTeeth(teeth, connector) {
var merged = xstream_1.default.merge.apply(xstream_1.default, __spread(teeth));
if (connector.fold) {
return merged
.fold(connector.reduce || defaultReduce, connector.init || {});
}
else {
return merged
.map(function (_a) {
var _b = __read(_a, 1), cur = _b[0];
return cur;
});
}
}
function spinGears(sources, defaultIntent, defaultModel, defaultCatch, teeth, toothFilter, toothView, sourcesWrapper, defaultConnector, connectors) {

@@ -203,3 +222,3 @@ var modelCache = new WeakMap();

return teeth.reduce(function (accum, tooth) {
return (__assign({}, accum, (_a = {}, _a[tooth] = xstream_1.default.merge.apply(xstream_1.default, __spread(views[tooth])).fold(connectors.has(tooth) ? connectors.get(tooth).reduce : defaultConnector.reduce, connectors.has(tooth) ? connectors.get(tooth).init() : defaultConnector.init()), _a)));
return (__assign({}, accum, (_a = {}, _a[tooth] = connectTeeth(views[tooth], connectors.get(tooth) || defaultConnector), _a)));
var _a;

@@ -210,12 +229,4 @@ }, {});

}
var defaultDefaultConnector = {
reduce: function (acc, _a) {
var _b = __read(_a, 2), cur = _b[0], gear = _b[1];
return (__assign({}, acc, (_c = {}, _c[gear.name || '?'] = cur, _c)));
var _c;
},
init: function () { return ({}); }
};
function motor(gearbox, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.defaultGear, defaultGear = _c === void 0 ? { intent: function () { return ({}); }, model: function () { return xstream_1.default.of({}); }, teeth: {} } : _c, _d = _b.defaultFilter, defaultFilter = _d === void 0 ? function () { return true; } : _d, _e = _b.defaultConnector, defaultConnector = _e === void 0 ? defaultDefaultConnector : _e, _f = _b.sourcesWrapper, sourcesWrapper = _f === void 0 ? function (sources) { return sources; } : _f, _g = _b.connectors, connectors = _g === void 0 ? new Map() : _g, _h = _b.sinkMap, sinkMap = _h === void 0 ? new Map() : _h;
var _b = _a === void 0 ? {} : _a, _c = _b.defaultGear, defaultGear = _c === void 0 ? { intent: function () { return ({}); }, model: function () { return xstream_1.default.of({}); }, teeth: {} } : _c, _d = _b.defaultFilter, defaultFilter = _d === void 0 ? function () { return true; } : _d, _e = _b.defaultConnector, defaultConnector = _e === void 0 ? {} : _e, _f = _b.sourcesWrapper, sourcesWrapper = _f === void 0 ? function (sources) { return sources; } : _f, _g = _b.connectors, connectors = _g === void 0 ? new Map() : _g, _h = _b.sinkMap, sinkMap = _h === void 0 ? new Map() : _h;
var _j = defaultsAndHelpers(defaultGear, defaultFilter), defaultIntent = _j.defaultIntent, defaultModel = _j.defaultModel, defaultCatch = _j.defaultCatch, teeth = _j.teeth, toothFilter = _j.toothFilter, toothView = _j.toothView, emptyTeeth = _j.emptyTeeth;

@@ -222,0 +233,0 @@ return function (sources) {

@@ -28,4 +28,5 @@ import { adapt } from '@cycle/run/lib/adapt'

export interface ToothConnector<TActions, TModel, TTooth, TAccumulator> {
reduce: ToothReduce<TActions, TModel, TTooth, TAccumulator>
init: () => TAccumulator
fold?: boolean
reduce?: ToothReduce<TActions, TModel, TTooth, TAccumulator>
init?: () => TAccumulator
isolate?: (sources: any, sink: Observable<any>, gear: Gear<TActions, TModel>) => Observable<any>

@@ -156,2 +157,15 @@ }

const defaultReduce = (acc: any, [cur, gear]: [any, Gear<any, any>]) => ({ ...acc, [gear.name || '?']: cur })
function connectTeeth(teeth: Array<Observable<any>>, connector: ToothConnector<any, any, any, any>) {
const merged = xs.merge(...teeth)
if (connector.fold) {
return merged
.fold(connector.reduce || defaultReduce, connector.init || {})
} else {
return merged
.map(([cur]: [any]) => cur)
}
}
function spinGears(sources: any,

@@ -196,5 +210,3 @@ defaultIntent: (sources: any) => any,

...accum,
[tooth]: xs.merge(...views[tooth])
.fold(connectors.has(tooth) ? connectors.get(tooth)!.reduce : defaultConnector.reduce,
connectors.has(tooth) ? connectors.get(tooth)!.init() : defaultConnector.init())
[tooth]: connectTeeth(views[tooth], connectors.get(tooth) || defaultConnector)
}),

@@ -205,11 +217,6 @@ {})

const defaultDefaultConnector = {
reduce: (acc: any, [cur, gear]: [any, Gear<any, any>]) => ({ ...acc, [gear.name || '?']: cur }),
init: () => ({})
}
export function motor(gearbox: Gearbox, {
defaultGear = { intent: () => ({}), model: () => xs.of({}), teeth: {} as GearTeeth<any> },
defaultFilter = () => true,
defaultConnector = defaultDefaultConnector,
defaultConnector = {},
sourcesWrapper = (sources: any) => sources,

@@ -216,0 +223,0 @@ connectors = new Map(),

{
"name": "cycle-gear",
"version": "6.0.1",
"version": "7.0.0",
"description": "Main function factory for CycleJS",

@@ -5,0 +5,0 @@ "main": "dist/index.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