isBuffer.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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;