node.js - What's the use of 'Buffer.isBuffer' when you could use 'instanceof'? -


I do not understand what is the purpose of the buffer.isbff function when For example, works like a magic:

  var b = new buffer ('bubala') assert.ok (buffer for buffer)  < / Pre> 

OK, in reality these are exactly (currently at least):

:

  buffer.isbifter = function buffer (b) {return usage.isbuffer (b); };  

:

  function isBuffer (arg) {return arg instance buffer; } Export.isBuffer = isBuffer;  

... So the only possible cause is readability. Note that prior to this specific implementation the source was used but it has been replaced with it, and it was argued:

Adding macros to the JS layer of the node would be obstacles Increases in contribution, and it breaks programs that export the JS file of the node for the user's module. (For example, many outline changes, my readable-stream polyphills, eut-dBgl mag module etc.) are not small problems.

I'm committed to checking the whole discussion.


Comments