You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

isBuffer.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. var root = require('./_root'),
  2. stubFalse = require('./stubFalse');
  3. /** Detect free variable `exports`. */
  4. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  5. /** Detect free variable `module`. */
  6. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  7. /** Detect the popular CommonJS extension `module.exports`. */
  8. var moduleExports = freeModule && freeModule.exports === freeExports;
  9. /** Built-in value references. */
  10. var Buffer = moduleExports ? root.Buffer : undefined;
  11. /* Built-in method references for those with the same name as other `lodash` methods. */
  12. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  13. /**
  14. * Checks if `value` is a buffer.
  15. *
  16. * @static
  17. * @memberOf _
  18. * @since 4.3.0
  19. * @category Lang
  20. * @param {*} value The value to check.
  21. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  22. * @example
  23. *
  24. * _.isBuffer(new Buffer(2));
  25. * // => true
  26. *
  27. * _.isBuffer(new Uint8Array(2));
  28. * // => false
  29. */
  30. var isBuffer = nativeIsBuffer || stubFalse;
  31. module.exports = isBuffer;