Any reason that there isn't a Buffer.isBuffer() method?
--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
You can submit docs requests as issues at https://github.com/miksago/node
How is instanceof broken?
nf instanceof Function; // prints true
--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
Yeah, sorry that wasn't documented. Now it is:
https://github.com/ry/node/commit/fca713eba45fb08d63dd677ca3163d002af15cca
Buffer.isBuffer = function (b) {
return b &&
typeof b === "object" &&
Object.prototype.toString.call(b.parent) === '[object SlowBuffer]';
}
--i
* This is also sometimes referred to as the "Miller Device", but I saw
Mark set someone straight on that point.
You can use the Flanagan Device* and do this:
Buffer.isBuffer = function (b) {
return b &&
typeof b === "object" &&
Object.prototype.toString.call(b.parent) === '[object SlowBuffer]';
}
--i
* This is also sometimes referred to as the "Miller Device", but I saw
Mark set someone straight on that point.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
There's another common JavaScript-ish mis-attribution. Look at these 2 and tell me what known pattern you see in there that sounds familiar to you :
July 2003: hint : Object.prototype.clone
http://groups.google.com/group/comp.lang.javascript/msg/5d06e72e55d5bf11
July 2004: hint : function inheritObject ()
http://groups.google.com/group/comp.lang.javascript/msg/af7e608ae26dad03
Then go to http://archive.org, and see crockford.com in, say, March 2006 ( ~3 years later ) :
http://web.archive.org/web/20060301101236/www.crockford.com/javascript/
See any trace of beget() in there?. No. Not until mid-2006 -> "Prototypal Inheritance in JavaScript" -> "I have learned to fully embrace prototypalism, and have liberated myself from the confines of the classical model."
Personally, I have learnt almost everything I know about JS from Crockford ( if you read this, thanks! ), but perhaps it would be fair to spread the word to attribute the invention of Object.create() to Lasse Reichstein Nielsen. If you think so too, please help correct this mis-attribution as well. Thanks.
--
Jorge.