gozala / channel Goto Github PK
View Code? Open in Web Editor NEWCSP style channel implementation, for the Channel specification
CSP style channel implementation, for the Channel specification
Calling gnode
directly is just as bad as calling coffee-script
directly.
It mutates the require.extensions
global.
You can move gnode
to devDependencies.
Hi Gozala this is really just a question (it might be an issue but might not).
I was trying this module out today and I was esp. interested in using it with generators.
Can you see something wrong with the simple "example.js" I wrote below? It doesn't seem to work don't know if I've done something wrong or what:
var chan = require("channel");
console.log('making the channel');
var ch = new chan.Channel();
chan.spawn(function * () {
while(true) {
console.log('putting 1');
yield ch.put(1);
console.log('putting 2');
yield ch.put(2);
console.log('back from putting 2');
}
});
chan.spawn(function * () {
while(true) {
console.log('reading 1');
console.log(yield ch.take());
console.log('reading 2');
console.log(yield ch.take());
console.log('back from reading 2');
}
});
console.log('end');
Then output I get running "node --harmony example.js" is:
making the channel
putting 1
reading 1
end
Which I guess mean my puts and takes never resolved?
DroppingBuffer seems to inherit the prototype from itself, which breaks its functionality (e.g. Channel.output.put produces an error). I have fixed it as follows:
buffer.js : line 64:
DroppingBuffer.prototype = Object.create(DroppingBuffer.prototype)
should be
DroppingBuffer.prototype = Object.create(UnblockingBuffer.prototype)
I wasn't sure if this should be a pull request or not, so I decided to report it instead.
it would be nice if port.close
returns a promise when its done completing all pending puts / takes.
This is confusing:
channel.output.put(x)
var data = channel.input.take()
If we're using words like "input" and "output" to describe parts of a channel, It seems like we'd put
something into the input
of a channel, and take
something out of the output of a channel, so in that case, it'd make more sense as
channel.input.put(x)
var data = channel.output.take()
Isn't it more intuitive that way? Or did I missunderstand something about the concept?
I noticed this channel library can work with simple promises without having to use generators.
And that your "spawn" function is fairly simple and designed around promises.
And I knew TJ's "co" module allows you to yield promises to his "co" function (similar to your "spawn"):
https://www.npmjs.com/package/co
My question: Do you know (or do you think?) your module could work using that other "co" library in lieu of your "spawn" function? Is that part of the idea behind your design using Promises?
(I only ask because there's some other helper libraries that work together with "co" that seem convenient so I'd like to use it together with your library).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.