twitst4tz

twitter statistics web application
Log | Files | Refs | README | LICENSE

is-buffer.js (576B)


      1 
      2 module.exports = isBuf;
      3 
      4 var withNativeBuffer = typeof Buffer === 'function' && typeof Buffer.isBuffer === 'function';
      5 var withNativeArrayBuffer = typeof ArrayBuffer === 'function';
      6 
      7 var isView = function (obj) {
      8   return typeof ArrayBuffer.isView === 'function' ? ArrayBuffer.isView(obj) : (obj.buffer instanceof ArrayBuffer);
      9 };
     10 
     11 /**
     12  * Returns true if obj is a buffer or an arraybuffer.
     13  *
     14  * @api private
     15  */
     16 
     17 function isBuf(obj) {
     18   return (withNativeBuffer && Buffer.isBuffer(obj)) ||
     19           (withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj)));
     20 }