can-stream-kefir
Advanced tools
Comparing version 1.0.0-pre.0 to 1.0.0-pre.1
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 ]) | ||
} | ||
); | ||
}); |
@@ -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", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
23818
263
0
8
11
+ Addedcan-kefir@^1.0.0-pre.1
+ Addedcan-symbol@^1.5.0
+ Addedcan-kefir@1.1.4(transitive)
- Removedkefir@^3.8.0