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
10
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 to 1.0.1

36

docs/can-stream-kefir.md

@@ -15,17 +15,18 @@ @module {Object} can-stream-kefir can-stream-kefir

```js
var canStream = require("can-stream-kefir");
var DefineMap = require("can-define/map/map");
import canStream from "can-stream-kefir";
import DefineMap from "can-define/map/map";
var me = new DefineMap({name: "Justin"});
const me = new DefineMap( { name: "Justin" } );
var nameStream = canStream.toStream(me,".name");
const nameStream = canStream.toStream( me, ".name" );
nameStream.onValue(function(name){
// name -> "Obaid";
});
nameStream.onValue( function( name ) {
me.name = "Obaid";
```
// name -> "Obaid";
} );
me.name = "Obaid";
```
@body

@@ -48,14 +49,15 @@

```js
var canCompute = require("can-compute");
var canStream = require("can-stream-kefir");
import canCompute from "can-compute";
import canStream from "can-stream-kefir";
var compute = canCompute(0);
var stream = canStream.toStream(compute);
const compute = canCompute( 0 );
const stream = canStream.toStream( compute );
stream.onValue(function(newVal){
console.log(newVal);
});
stream.onValue( function( newVal ) {
console.log( newVal );
} );
compute(1);
compute( 1 );
//-> console.logs 1
```

@@ -18,21 +18,21 @@ @function can-stream-kefir.toCompute toCompute

```js
var count = Kefir.sequentially(1000, [1, 2]);
const count = Kefir.sequentially( 1000, [ 1, 2 ] );
var myCompute = canStream.toCompute(function(setStream){
return setStream.merge(count);
});
const myCompute = canStream.toCompute( function( setStream ) {
return setStream.merge( count );
} );
// listen to the compute for it to have a value
myCompute.on("change", function(){})
myCompute.on( "change", function() {} );
myCompute("A")
myCompute( "A" );
// immediate value
myCompute() //-> "A"
myCompute(); //-> "A"
// 1000ms later
myCompute() //-> 1
myCompute(); //-> 1
// 1000ms later
myCompute() //-> 2
myCompute(); //-> 2
```

@@ -46,7 +46,7 @@

```js
var returnedCompute = canStream.toCompute(function(setStream){
return setStream;
});
returnedCompute(1);
returnedCompute(2);
const returnedCompute = canStream.toCompute( function( setStream ) {
return setStream;
} );
returnedCompute( 1 );
returnedCompute( 2 );
```

@@ -53,0 +53,0 @@

@@ -13,15 +13,15 @@ @function can-stream-kefir.toStream toStream

```js
var compute = require('can-compute');
var canStream = require('can-stream-kefir');
import compute from "can-compute";
import canStream from "can-stream-kefir";
var c1 = compute(0);
const c1 = compute( 0 );
var resultCompute = canStream.toStream(c1);
const resultCompute = canStream.toStream( c1 );
resultCompute.onValue(function (val) {
console.log(val);
});
resultCompute.onValue( function( val ) {
console.log( val );
} );
c1(1);
```
c1( 1 );
```

@@ -38,20 +38,22 @@ @param {can-compute} compute A compute whose value will be the stream values.

```js
var DefineList = require('can-define/list/list');
var canStream = require('can-stream-kefir');
import DefineList from "can-define/list/list";
import canStream from "can-stream-kefir";
var hobbies = new DefineList(["js","kayaking"]);
const hobbies = new DefineList( [ "js", "kayaking" ] );
var changeCount = canStream.toStream(hobbies, "length").scan(function(prev){
return prev + 1;
}, 0);
changeCount.onValue(function(event) {
console.log(event);
});
const changeCount = canStream.toStream( hobbies, "length" ).scan( function( prev ) {
return prev + 1;
}, 0 );
changeCount.onValue( function( event ) {
console.log( event );
} );
hobbies.push("bball")
//-> console.logs {type: "add", args: [2,["bball"]]}
hobbies.shift()
//-> console.logs {type: "remove", args: [0,["js"]]}
```
hobbies.push( "bball" );
//-> console.logs {type: "add", args: [2,["bball"]]}
hobbies.shift();
//-> console.logs {type: "remove", args: [0,["js"]]}
```
@param {Observable} obs An observable object like a [can-define/map/map].

@@ -69,25 +71,25 @@ Promises can work too.

```js
var canStream = require('can-stream-kefir');
var DefineMap = require("can-define/map/map");
import canStream from "can-stream-kefir";
import DefineMap from "can-define/map/map";
var person = new DefineMap({
first: "Justin",
last: "Meyer"
});
const person = new DefineMap( {
first: "Justin",
last: "Meyer"
} );
var first = canStream.toStream(person, '.first'),
last = canStream.toStream(person, '.last');
const first = canStream.toStream( person, ".first" ), last = canStream.toStream( person, ".last" );
var fullName = Kefir.combine(first, last, function(first, last){
return first + last;
});
const fullName = Kefir.combine( first, last, function( first, last ) {
return first + last;
} );
fullName.onValue(function(newVal){
console.log(newVal);
});
fullName.onValue( function( newVal ) {
console.log( newVal );
} );
map.first = "Payal"
//-> console.logs "Payal Meyer"
```
map.first = "Payal";
//-> console.logs "Payal Meyer"
```
Create a stream based on a event on an observable property.

@@ -106,20 +108,21 @@

```js
var canStream = require('can-stream-kefir');
var DefineMap = require("can-define/map/map");
var DefineList = require("can-define/list/list");
import canStream from "can-stream-kefir";
import DefineMap from "can-define/map/map";
import DefineList from "can-define/list/list";
var me = new DefineMap({
todos: ["mow lawn"]
});
const me = new DefineMap( {
todos: [ "mow lawn" ]
} );
var addStream = canStream.toStream(me, ".todos add");
const addStream = canStream.toStream( me, ".todos add" );
addStream.onValue(function(event){
console.log(event);
});
addStream.onValue( function( event ) {
console.log( event );
} );
map.todos.push("do dishes");
//-> console.logs {type: "add", args: [1,["do dishes"]]}
```
map.todos.push( "do dishes" );
//-> console.logs {type: "add", args: [1,["do dishes"]]}
```
Create a stream based on a event on an observable property.

@@ -126,0 +129,0 @@

{
"name": "can-stream-kefir",
"version": "1.0.0",
"version": "1.0.1",
"description": "Stream values into and out of computes",

@@ -5,0 +5,0 @@ "homepage": "http://canjs.com",

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