Re: [nodejs] Re: how to create a singleton

2013-11-21 Thread Kamil Leszczuk
> For example, if I have a module for emailing with a send() method on it, I don't have it export a constructor; I have it export an object. That object might maintain some state or it might not. When the module is subsequently require()'d, it will have any state that it has accumulated since. F

Re: [nodejs] Re: how to create a singleton

2013-11-21 Thread Kamil Leszczuk
Aah, nevermind then, I misunerstood ;) 21 lis 2013 16:36 "Gregg Caines" napisał(a): > Yeah... that's what I'm saying :) > > G > > > On Thu, Nov 21, 2013 at 7:33 AM, Kamil Leszczuk wrote: > >> > For example, if I have a module for emailing with

Re: [nodejs] Problem with Node.js in "For in"

2013-08-23 Thread Kamil Leszczuk
Simply use regular for loop or, if you really want the for-in, use Object.hasOwnProperty: for(var i in user[action]){ if (user[action].hasOwnProperty(i)) { console.log(i); } } On Friday, August 23, 2013 1:39:30 PM UTC+2, Александр Крылов wrote: > > if you look closely, I use array of object

[nodejs] Re: Passing the socket into the callback

2013-08-21 Thread Kamil Leszczuk
'this' will be bound to the EventEmitter instance. This behaviour is implemented around here: https://github.com/joyent/node/blob/master/lib/events.js#L100. So, the following code works as expected (prints "called!"). var SomeClass = function () { }; util.inherits(SomeClass, EventEmitter); var