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

@cycle/base

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cycle/base - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

test/test-stream-adapter-two.js

16

CHANGELOG.md

@@ -0,1 +1,11 @@

<a name="2.0.1"></a>
## [2.0.1](https://github.com/cyclejs/base/compare/v2.0.0...v2.0.1) (2016-04-05)
### Bug Fixes
* **sources:** automatically adapt sources when isValidStream ([31935c3](https://github.com/cyclejs/base/commit/31935c3))
<a name="2.0.0"></a>

@@ -5,4 +15,8 @@ # [2.0.0](https://github.com/cyclejs/base/compare/v2.0.0...v2.0.0) (2016-04-05)

### Features
* **DriverFunction:** improve DriverFunction signature ([3da5431](https://github.com/cyclejs/base/commit/3da5431))
<a name="1.3.0"></a>

@@ -42,3 +56,1 @@ # [1.3.0](https://github.com/cyclejs/base/compare/v1.2.2...v1.3.0) (2016-04-05)

feat(StreamAdapter): improve typing of makeHoldSubject()

@@ -31,3 +31,9 @@ (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.CycleBase = 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){

if (drivers.hasOwnProperty(name_2)) {
sources[name_2] = drivers[name_2](sinkProxies[name_2].stream, streamAdapter, name_2);
var driverOutput = drivers[name_2](sinkProxies[name_2].stream, streamAdapter, name_2);
var driverStreamAdapter = drivers[name_2].streamAdapter;
if (driverStreamAdapter && driverStreamAdapter.isValidStream(driverOutput)) {
sources[name_2] = streamAdapter.adapt(driverOutput, driverStreamAdapter.streamSubscribe);
} else {
sources[name_2] = driverOutput;
}
}

@@ -34,0 +40,0 @@ }

2

dist/cycle-base.min.js

@@ -1,1 +0,1 @@

(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.CycleBase=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){"use strict";var _typeof2=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(obj){return typeof obj}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol?"symbol":typeof obj};var _typeof=typeof Symbol==="function"&&_typeof2(Symbol.iterator)==="symbol"?function(obj){return typeof obj==="undefined"?"undefined":_typeof2(obj)}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol?"symbol":typeof obj==="undefined"?"undefined":_typeof2(obj)};function makeSinkProxies(drivers,streamAdapter){var sinkProxies={};for(var name_1 in drivers){if(drivers.hasOwnProperty(name_1)){var holdSubject=streamAdapter.makeHoldSubject();var driverStreamAdapter=drivers[name_1].streamAdapter||streamAdapter;var stream=driverStreamAdapter.adapt(holdSubject.stream,streamAdapter.streamSubscribe);sinkProxies[name_1]={stream:stream,observer:holdSubject.observer}}}return sinkProxies}function callDrivers(drivers,sinkProxies,streamAdapter){var sources={};for(var name_2 in drivers){if(drivers.hasOwnProperty(name_2)){sources[name_2]=drivers[name_2](sinkProxies[name_2].stream,streamAdapter,name_2)}}return sources}function replicateMany(sinks,sinkProxies,streamAdapter){var results=Object.keys(sinks).filter(function(name){return!!sinkProxies[name]}).map(function(name){return streamAdapter.streamSubscribe(sinks[name],sinkProxies[name].observer)});var disposeFunctions=results.filter(function(dispose){return typeof dispose==="function"});return function(){disposeFunctions.forEach(function(dispose){return dispose()})}}function disposeSources(sources){for(var k in sources){if(sources.hasOwnProperty(k)&&typeof sources[k].dispose==="function"){sources[k].dispose()}}}var isObjectEmpty=function isObjectEmpty(obj){return Object.keys(obj).length===0};function Cycle(main,drivers,options){if(typeof main!=="function"){throw new Error("First argument given to Cycle must be the 'main' "+"function.")}if((typeof drivers==="undefined"?"undefined":_typeof(drivers))!=="object"||drivers===null){throw new Error("Second argument given to Cycle must be an object "+"with driver functions as properties.")}if(isObjectEmpty(drivers)){throw new Error("Second argument given to Cycle must be an object "+"with at least one driver function declared as a property.")}var streamAdapter=options.streamAdapter;if(!streamAdapter||isObjectEmpty(streamAdapter)){throw new Error("Third argument given to Cycle must be an options object "+"with the streamAdapter key supplied with a valid stream adapter.")}var sinkProxies=makeSinkProxies(drivers,streamAdapter);var sources=callDrivers(drivers,sinkProxies,streamAdapter);var sinks=main(sources);var run=function run(){var disposeReplication=replicateMany(sinks,sinkProxies,streamAdapter);return function(){streamAdapter.dispose(sinks,sinkProxies,sources);disposeSources(sources);disposeReplication()}};return{sinks:sinks,sources:sources,run:run}}Object.defineProperty(exports,"__esModule",{value:true});exports.default=Cycle},{}]},{},[1])(1)});
(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.CycleBase=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){"use strict";var _typeof2=typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"?function(obj){return typeof obj}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol?"symbol":typeof obj};var _typeof=typeof Symbol==="function"&&_typeof2(Symbol.iterator)==="symbol"?function(obj){return typeof obj==="undefined"?"undefined":_typeof2(obj)}:function(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol?"symbol":typeof obj==="undefined"?"undefined":_typeof2(obj)};function makeSinkProxies(drivers,streamAdapter){var sinkProxies={};for(var name_1 in drivers){if(drivers.hasOwnProperty(name_1)){var holdSubject=streamAdapter.makeHoldSubject();var driverStreamAdapter=drivers[name_1].streamAdapter||streamAdapter;var stream=driverStreamAdapter.adapt(holdSubject.stream,streamAdapter.streamSubscribe);sinkProxies[name_1]={stream:stream,observer:holdSubject.observer}}}return sinkProxies}function callDrivers(drivers,sinkProxies,streamAdapter){var sources={};for(var name_2 in drivers){if(drivers.hasOwnProperty(name_2)){var driverOutput=drivers[name_2](sinkProxies[name_2].stream,streamAdapter,name_2);var driverStreamAdapter=drivers[name_2].streamAdapter;if(driverStreamAdapter&&driverStreamAdapter.isValidStream(driverOutput)){sources[name_2]=streamAdapter.adapt(driverOutput,driverStreamAdapter.streamSubscribe)}else{sources[name_2]=driverOutput}}}return sources}function replicateMany(sinks,sinkProxies,streamAdapter){var results=Object.keys(sinks).filter(function(name){return!!sinkProxies[name]}).map(function(name){return streamAdapter.streamSubscribe(sinks[name],sinkProxies[name].observer)});var disposeFunctions=results.filter(function(dispose){return typeof dispose==="function"});return function(){disposeFunctions.forEach(function(dispose){return dispose()})}}function disposeSources(sources){for(var k in sources){if(sources.hasOwnProperty(k)&&typeof sources[k].dispose==="function"){sources[k].dispose()}}}var isObjectEmpty=function isObjectEmpty(obj){return Object.keys(obj).length===0};function Cycle(main,drivers,options){if(typeof main!=="function"){throw new Error("First argument given to Cycle must be the 'main' "+"function.")}if((typeof drivers==="undefined"?"undefined":_typeof(drivers))!=="object"||drivers===null){throw new Error("Second argument given to Cycle must be an object "+"with driver functions as properties.")}if(isObjectEmpty(drivers)){throw new Error("Second argument given to Cycle must be an object "+"with at least one driver function declared as a property.")}var streamAdapter=options.streamAdapter;if(!streamAdapter||isObjectEmpty(streamAdapter)){throw new Error("Third argument given to Cycle must be an options object "+"with the streamAdapter key supplied with a valid stream adapter.")}var sinkProxies=makeSinkProxies(drivers,streamAdapter);var sources=callDrivers(drivers,sinkProxies,streamAdapter);var sinks=main(sources);var run=function run(){var disposeReplication=replicateMany(sinks,sinkProxies,streamAdapter);return function(){streamAdapter.dispose(sinks,sinkProxies,sources);disposeSources(sources);disposeReplication()}};return{sinks:sinks,sources:sources,run:run}}Object.defineProperty(exports,"__esModule",{value:true});exports.default=Cycle},{}]},{},[1])(1)});

@@ -21,3 +21,10 @@ "use strict";

if (drivers.hasOwnProperty(name_2)) {
sources[name_2] = drivers[name_2](sinkProxies[name_2].stream, streamAdapter, name_2);
var driverOutput = drivers[name_2](sinkProxies[name_2].stream, streamAdapter, name_2);
var driverStreamAdapter = drivers[name_2].streamAdapter;
if (driverStreamAdapter && driverStreamAdapter.isValidStream(driverOutput)) {
sources[name_2] = streamAdapter.adapt(driverOutput, driverStreamAdapter.streamSubscribe);
}
else {
sources[name_2] = driverOutput;
}
}

@@ -24,0 +31,0 @@ }

{
"name": "@cycle/base",
"version": "2.0.0",
"version": "2.0.1",
"description": "Base infrastructure for a generic run() function for Cycle.js",

@@ -46,4 +46,5 @@ "license": "MIT",

"rx": "4.0.6",
"rxjs": "^5.0.0-beta.5",
"sinon": "1.17.2",
"tslint": "3.2.2",
"tslint": "3.6.0",
"typescript": "1.8.9",

@@ -89,3 +90,2 @@ "uglify-js": "2.6.1",

"start": "npm install && npm prune",
"changelog-and-commit": "npm run changelog && git diff --quiet --exit-code --cached || git commit -a -m 'chore(CHANGELOG): update CHANGELOG.md'",
"prepublish": "npm run lib",

@@ -96,4 +96,4 @@ "preversion": "npm run dist && git add dist/ && git diff --quiet --exit-code --cached || git commit -a -m 'chore(dist): build dist/'",

"version-major": "npm version major --message 'chore(version): %s'",
"postversion": "npm run changelog-and-commit && npm publish --access=public"
"postversion": "npm publish --access=public"
}
}

@@ -80,3 +80,3 @@ export interface Observer {

if (drivers.hasOwnProperty(name)) {
sources[name] = drivers[name](
const driverOutput = drivers[name](
sinkProxies[name].stream,

@@ -86,2 +86,13 @@ streamAdapter,

);
const driverStreamAdapter = drivers[name].streamAdapter;
if (driverStreamAdapter && driverStreamAdapter.isValidStream(driverOutput)) {
sources[name] = streamAdapter.adapt(
driverOutput,
driverStreamAdapter.streamSubscribe
);
} else {
sources[name] = driverOutput;
}
}

@@ -88,0 +99,0 @@ }

@@ -6,3 +6,5 @@ import {describe, it} from 'mocha'

import * as Rx from 'rx'
import * as RxJS from 'rxjs'
import testStreamAdapter from './test-stream-adapter';
import testStreamAdapterTwo from './test-stream-adapter-two'

@@ -99,2 +101,33 @@ describe('Cycle', function () {

it('should convert sources between stream libraries', function(done) {
function app(sources) {
assert(testStreamAdapterTwo.isValidStream(sources.other))
return {
other: sources.other.switchMap(() => RxJS.Observable.of(10)).startWith(1)
}
}
function driver(sink$) {
assert(testStreamAdapter.isValidStream(sink$))
return sink$.doOnNext(() => {}).map(() => 5)
}
driver.streamAdapter = testStreamAdapter
const {sinks, sources, run} = Cycle(app, {
other: driver
}, {streamAdapter: testStreamAdapterTwo});
sources.other.take(1).subscribe(function(x) {
assert.strictEqual(typeof x, 'number');
assert.strictEqual(x, 5);
});
const dispose = run();
setTimeout(function() {
dispose();
done();
}, 10)
});
it('should run synchronously', function () {

@@ -101,0 +134,0 @@ function app() {

@@ -57,3 +57,3 @@ import {ReplaySubject, Observable} from 'rx';

return (
typeof stream.subscribe === 'function' && // should have .subscribe
typeof stream.subscribeOnNext === 'function' && // should have .subscribe
typeof stream.onValue !== 'function'); // make sure not baconjs

@@ -60,0 +60,0 @@ },

Sorry, the diff of this file is not supported yet

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