Coder Social home page Coder Social logo

channel's People

Contributors

gozala avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

raynos swatinem

channel's Issues

remove gnode dependency

Calling gnode directly is just as bad as calling coffee-script directly.

It mutates the require.extensions global.

You can move gnode to devDependencies.

should this example work?

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 is broken

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.

Swap Channel input with output?

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?

Can this module work with other generator libraries - e.g. TJ's "co" module?

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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.