@cycle/core
Advanced tools
Comparing version 6.0.1 to 6.0.2
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Cycle = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
let Rx = require(`rx`); | ||
(function (global){ | ||
"use strict"; | ||
var Rx = (typeof window !== "undefined" ? window['Rx'] : typeof global !== "undefined" ? global['Rx'] : null); | ||
function makeSinkProxies(drivers) { | ||
let sinkProxies = {}; | ||
for (let name in drivers) { | ||
if (drivers.hasOwnProperty(name)) { | ||
sinkProxies[name] = new Rx.ReplaySubject(1); | ||
var sinkProxies = {}; | ||
for (var _name in drivers) { | ||
if (drivers.hasOwnProperty(_name)) { | ||
sinkProxies[_name] = new Rx.ReplaySubject(1); | ||
} | ||
@@ -15,6 +18,6 @@ } | ||
function callDrivers(drivers, sinkProxies) { | ||
let sources = {}; | ||
for (let name in drivers) { | ||
if (drivers.hasOwnProperty(name)) { | ||
sources[name] = drivers[name](sinkProxies[name], name); | ||
var sources = {}; | ||
for (var _name2 in drivers) { | ||
if (drivers.hasOwnProperty(_name2)) { | ||
sources[_name2] = drivers[_name2](sinkProxies[_name2], _name2); | ||
} | ||
@@ -26,5 +29,5 @@ } | ||
function attachDisposeToSinks(sinks, replicationSubscription) { | ||
Object.defineProperty(sinks, `dispose`, { | ||
Object.defineProperty(sinks, "dispose", { | ||
enumerable: false, | ||
value: () => { | ||
value: function value() { | ||
replicationSubscription.dispose(); | ||
@@ -38,5 +41,5 @@ } | ||
return function dispose() { | ||
for (let name in sources) { | ||
if (sources.hasOwnProperty(name) && typeof sources[name].dispose === `function`) { | ||
sources[name].dispose(); | ||
for (var _name3 in sources) { | ||
if (sources.hasOwnProperty(_name3) && typeof sources[_name3].dispose === "function") { | ||
sources[_name3].dispose(); | ||
} | ||
@@ -48,3 +51,3 @@ } | ||
function attachDisposeToSources(sources) { | ||
Object.defineProperty(sources, `dispose`, { | ||
Object.defineProperty(sources, "dispose", { | ||
enumerable: false, | ||
@@ -57,3 +60,3 @@ value: makeDisposeSources(sources) | ||
function logToConsoleError(err) { | ||
let target = err.stack || err; | ||
var target = err.stack || err; | ||
if (console && console.error) { | ||
@@ -65,8 +68,8 @@ console.error(target); | ||
function replicateMany(observables, subjects) { | ||
return Rx.Observable.create(observer => { | ||
let subscription = new Rx.CompositeDisposable(); | ||
setTimeout(() => { | ||
for (let name in observables) { | ||
if (observables.hasOwnProperty(name) && subjects.hasOwnProperty(name) && !subjects[name].isDisposed) { | ||
subscription.add(observables[name].doOnError(logToConsoleError).subscribe(subjects[name].asObserver())); | ||
return Rx.Observable.create(function (observer) { | ||
var subscription = new Rx.CompositeDisposable(); | ||
setTimeout(function () { | ||
for (var _name4 in observables) { | ||
if (observables.hasOwnProperty(_name4) && subjects.hasOwnProperty(_name4) && !subjects[_name4].isDisposed) { | ||
subscription.add(observables[_name4].doOnError(logToConsoleError).subscribe(subjects[_name4].asObserver())); | ||
} | ||
@@ -79,3 +82,3 @@ } | ||
subscription.dispose(); | ||
for (let x in subjects) { | ||
for (var x in subjects) { | ||
if (subjects.hasOwnProperty(x)) { | ||
@@ -90,3 +93,3 @@ subjects[x].dispose(); | ||
function isObjectEmpty(obj) { | ||
for (let key in obj) { | ||
for (var key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
@@ -100,22 +103,22 @@ return false; | ||
function run(main, drivers) { | ||
if (typeof main !== `function`) { | ||
throw new Error(`First argument given to Cycle.run() must be the 'main' ` + `function.`); | ||
if (typeof main !== "function") { | ||
throw new Error("First argument given to Cycle.run() must be the 'main' " + "function."); | ||
} | ||
if (typeof drivers !== `object` || drivers === null) { | ||
throw new Error(`Second argument given to Cycle.run() must be an object ` + `with driver functions as properties.`); | ||
if (typeof drivers !== "object" || drivers === null) { | ||
throw new Error("Second argument given to Cycle.run() must be an object " + "with driver functions as properties."); | ||
} | ||
if (isObjectEmpty(drivers)) { | ||
throw new Error(`Second argument given to Cycle.run() must be an object ` + `with at least one driver function declared as a property.`); | ||
throw new Error("Second argument given to Cycle.run() must be an object " + "with at least one driver function declared as a property."); | ||
} | ||
let sinkProxies = makeSinkProxies(drivers); | ||
let sources = callDrivers(drivers, sinkProxies); | ||
let sinks = main(sources); | ||
let subscription = replicateMany(sinks, sinkProxies).subscribe(); | ||
let sinksWithDispose = attachDisposeToSinks(sinks, subscription); | ||
let sourcesWithDispose = attachDisposeToSources(sources); | ||
var sinkProxies = makeSinkProxies(drivers); | ||
var sources = callDrivers(drivers, sinkProxies); | ||
var sinks = main(sources); | ||
var subscription = replicateMany(sinks, sinkProxies).subscribe(); | ||
var sinksWithDispose = attachDisposeToSinks(sinks, subscription); | ||
var sourcesWithDispose = attachDisposeToSources(sources); | ||
return { sources: sourcesWithDispose, sinks: sinksWithDispose }; | ||
} | ||
let Cycle = { | ||
var Cycle = { | ||
/** | ||
@@ -140,3 +143,3 @@ * Takes a `main` function and circularly connects it to the given collection | ||
*/ | ||
run | ||
run: run | ||
}; | ||
@@ -146,3 +149,4 @@ | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}]},{},[1])(1) | ||
}); |
{ | ||
"name": "@cycle/core", | ||
"version": "6.0.1", | ||
"version": "6.0.2", | ||
"author": "Andre Staltz", | ||
@@ -5,0 +5,0 @@ "description": "A fully reactive JavaScript framework for Human-Computer Interaction", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34977
530
5