Re: [nodejs] util is functions

2012-03-11 Thread Nathan Rajlich
It's a generally known problem is JavaScript that "instanceof" doesn't work across contexts (not just the vm module). This is even a problem in the web browser. So JS devs have had to come up with a sure-fire way to determine if you have a Date object by checking the internal [[Class]] property, wh

Re: [nodejs] util is functions

2012-03-11 Thread Mark Volkmann
On Sun, Mar 11, 2012 at 11:39 AM, Jann Horn wrote: > Am Sonntag, den 11.03.2012, 11:10 -0500 schrieb Mark Volkmann: >> util.isDate(obj) >> >> obj instanceof Date > >> new Date() instanceof Date > true >> require('vm').runInNewContext('new Date()') instanceof Date > false >> require('util').isDate(

Re: [nodejs] util is functions

2012-03-11 Thread Jann Horn
Am Sonntag, den 11.03.2012, 11:10 -0500 schrieb Mark Volkmann: > util.isDate(obj) > > obj instanceof Date > new Date() instanceof Date true > require('vm').runInNewContext('new Date()') instanceof Date false > require('util').isDate(new Date()) true > require('util').isDate(require('vm').runInNew

[nodejs] util is functions

2012-03-11 Thread Mark Volkmann
I'm sure there's a reason I don't yet appreciate, but why do we need the util module functions isArray, isDate, isError and isRegExp? When do the result of these expressions differ? util.isDate(obj) obj instanceof Date -- R. Mark Volkmann Object Computing, Inc. -- Job Board: http://jobs.nodej