Node Roundup: LazyBoy, node-fibers, NsSocket

Alex R. Young





node modules network fibers

Node Roundup: LazyBoy, node-fibers, NsSocket

Posted by Alex R. Young on .

node modules network fibers

Node Roundup: LazyBoy, node-fibers, NsSocket

Posted by Alex R. Young on .
You can send your node modules and articles in for review through our [contact form](/contact.html) or [@dailyjs](http://twitter.com/dailyjs).


LazyBoy (GitHub: garrensmith / LazyBoy, License: MIT, npm:
LazyBoy) by Garren Smith is a CouchDB object mapper:

var Model = require('LazyBoy');

Model.define('User', {
  name: String
  surname: {type: String, default: 'Rambo'}

var user = Model.create('User', { name: 'John', surname: 'Rambo' });

user.save(function(err, saved_user) {

var User = Model('User');
User.find('some id', function(err, user) {

The API reminds me of Mongoose, where models
are registered then fetched back later. The author has written tests,
and intends to add some useful features like validation later.

node-fibers 0.5

node-fibers (License: MIT, npm: node-fibers) by Marcel Laverdet has just been updated to version

I recently pushed out version 0.5 which most notably adds a nifty implementation of futures which supports synchronous wait'ing in lieu of callback chains in NodeJS.

Fibers are a convenient way of wrapping code that blocks in something
like a thread -- "coroutines" is the more accurate term. To get a good
sense of what fibers are and how they can help with certain classes of
problems, Adding fibers to v8: efficiency + clarity in

covers the subject very well.


NsSocket (npm: nssocket) from Nodejitsu wraps network sockets with events and automatic buffering to
help simplify string-based network communication.

The default namespace delimiter is :::

nsSocket.on('data::some::evented', function(datas) {

The authors have written up a full example that demonstrates the basic

var net = require('net'),
    nssocket = require('nssocket');

// Config object
var config = {
  delimiter : '::' // default (recommended)
  type : 'tcp' // default (tcp, tls)
  msgLength : 3 // default (can be any length, technically even 1)

// socket gets wrapped
var socket = new net.Socket({ type: 'tcp4'}),
    nsSocket = nssocket.NsSocket(socket, config);

nsSocket.connect(80, '', function onConnect() {
  // pass in an array
  nsSocket.send(['hello', 'world', 'derp']);