New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

can-stream-kefir

Package Overview
Dependencies
Maintainers
8
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-stream-kefir - npm Package Compare versions

Comparing version 1.0.0-pre.0 to 1.0.0-pre.1

29

can-stream-kefir_test.js
var QUnit = require('steal-qunit');
var canStream = require('can-stream-kefir');
var compute = require('can-compute');
var canReflect = require('can-reflect');
var DefineList = require('can-define/list/list');

@@ -197,1 +198,29 @@

});
QUnit.test('getValueDependencies - stream from compute', function(assert) {
var c = compute(0);
var stream = canStream.toStream(c);
assert.deepEqual(canReflect.getValueDependencies(stream), {
valueDependencies: new Set([c])
});
});
QUnit.test('getValueDependencies - streamedCompute', function(assert) {
var mergeStream;
var c = compute("a");
var letterStream = canStream.toStream(c);
var makeStream = function makeStream(setStream){
return (mergeStream = setStream.merge(letterStream));
};
var streamedCompute = canStream.toCompute(makeStream);
assert.deepEqual(
canReflect.getKeyDependencies(streamedCompute.computeInstance, "change"),
{
valueDependencies: new Set([ mergeStream ])
}
);
});

44

can-stream-kefir.js

@@ -1,5 +0,10 @@

var Kefir = require('kefir');
var Kefir = require('can-kefir');
var compute = require('can-compute');
var canStream = require('can-stream');
var canSymbol = require('can-symbol');
var namespace = require('can-namespace');
var getValueDependenciesSymbol = canSymbol.for('can.getValueDependencies');
var getKeyDependenciesSymbol = canSymbol.for('can.getKeyDependencies');
var canStreamKefir = {};

@@ -13,3 +18,3 @@

canStreamKefir.toStream = function (compute) {
return Kefir.stream(function (emitter) {
var stream = Kefir.stream(function (emitter) {
var changeHandler = function (ev, newVal) {

@@ -26,3 +31,2 @@ emitter.emit(newVal);

return function () {

@@ -32,7 +36,13 @@ compute.off('change', changeHandler);

});
stream[getValueDependenciesSymbol] = function getValueDependencies() {
return {
valueDependencies: new Set([compute])
};
};
return stream;
};
canStreamKefir.toCompute = function(makeStream, context){
var emitter,

@@ -45,13 +55,10 @@ lastValue,

emitter = e;
if(lastSetValue !== undefined) {
if (lastSetValue !== undefined) {
emitter.emit(lastSetValue);
}
});
var valueStream = makeStream.call(context, setterStream);
}),
valueStream = makeStream.call(context, setterStream);
// Create a compute that will bind to the resolved stream when bound
return compute(undefined, {
var streamCompute = compute(undefined, {
// When the compute is read, use that last value

@@ -87,2 +94,15 @@ get: function () {

});
// the symbol should ideally be implemented in the compute wrapper instead of
// the internal instance, this should be fixed once can-compute is removed
var _compute = streamCompute.computeInstance;
_compute[getKeyDependenciesSymbol] = function getKeyDependencies(key) {
if (key === 'change') {
return {
valueDependencies: new Set([valueStream])
};
}
};
return streamCompute;
};

@@ -89,0 +109,0 @@

{
"name": "can-stream-kefir",
"version": "1.0.0-pre.0",
"version": "1.0.0-pre.1",
"description": "Stream values into and out of computes",

@@ -40,10 +40,12 @@ "homepage": "http://canjs.com",

"can-event": "^3.7.6",
"can-kefir": "^1.0.0-pre.1",
"can-namespace": "^1.0.0",
"can-observation": "^4.0.0-pre.24",
"can-stream": "^1.0.0-pre.0",
"can-util": "^3.9.0",
"kefir": "^3.8.0"
"can-symbol": "^1.5.0",
"can-util": "^3.9.0"
},
"devDependencies": {
"can-define": "^2.0.0-pre.21",
"can-reflect": "^1.11.1",
"detect-cyclic-packages": "^1.1.0",

@@ -50,0 +52,0 @@ "done-serve": "^1.3.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