Hi! You again ;-) ;-) (after Scala, Clojure.. )
1) No goroutinges, but streams and events (stream2 is the "new" implementation, two years age). But maybe JavaScript generators? I'm not sure. 2) No yield, until new ecmascript 6, but some links http://stackoverflow.com/questions/4126634/does-node-js-support-yield http://blog.alexmaccaw.com/how-yield-will-transform-node (v 0.11 not the stable 0.10.x) 3) setImmediate(myfn); or setTimeout(myfn, 0) (later is preferred, if your library should run in browsers too; not all the browsers implements setImmediate) 4) It's really simple. A complex number arithmetic library http://github.com/ajlopez/Complexo The key part is the package.json file where you define the entry point, the dependencies, the scripts to run (what is "npm test"?), the dev dependencies. You can get an account on NPM, and publish your module Sometimes, your main module.js is splitted, like in https://github.com/ajlopez/RustScript/tree/master/lib but you can still tests the files https://github.com/ajlopez/RustScript/tree/master/test notice the use of .npmignore to not publish samples files Sometimes, your separated files should be arranged in one, to support browsers https://github.com/ajlopez/Plangre https://github.com/ajlopez/PLangRe/tree/master/lib It could be rearrange with automation commands in only one to be used in browser. In the above project, I did the work with a windows command, and using the trick of defining each submodule in a function mysubmodule = (function() { ... return .... } if (typeof module != 'undefined' && module.exports) module.exports = mysubmodule; and concatenating all the files in order But you can use browserfy by @substack Sure, there are more complete and better samples You can read a lot of good code and module use/patterns at https://github.com/substack ie https://github.com/substack/minimist Angel "Java" Lopez @ajlopez On Sun, May 11, 2014 at 9:21 AM, Massimiliano Tomassoli <[email protected]>wrote: > Hi everyone, > I'd like to port a Dart library to node.js ( > https://github.com/mtomassoli/golib) but I don't know much about node.js. > I have some questions: > > 1. Do you already have goroutines and channels in node.js? > 2. Can I use *yield*? > 3. How can I add a function to the event loop? (I'll need to emulate > Dart's completers) > 4. What's the structure of a node.js library/module? Any links? > > Thanks. > > > -- > Job board: http://jobs.nodejs.org/ > New group rules: > https://gist.github.com/othiym23/9886289#file-moderation-policy-md > Old group rules: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > --- > You received this message because you are subscribed to the Google Groups > "nodejs" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/nodejs/fa584a27-76b5-49e8-a4b8-6ac86bdaaa95%40googlegroups.com<https://groups.google.com/d/msgid/nodejs/fa584a27-76b5-49e8-a4b8-6ac86bdaaa95%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/CAMs%2BDqK9LZ0O31gZFDeX5SrYQ2%2Bi1iTOmT9YAN5Zgx253Gdx1g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
