isArrayBuffer.js 888 B

12345678910111213141516171819202122232425262728293031323334353637
  1. var isObjectLike = require('./isObjectLike');
  2. var arrayBufferTag = '[object ArrayBuffer]';
  3. /** Used for built-in method references. */
  4. var objectProto = Object.prototype;
  5. /**
  6. * Used to resolve the
  7. * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
  8. * of values.
  9. */
  10. var objectToString = objectProto.toString;
  11. /**
  12. * Checks if `value` is classified as an `ArrayBuffer` object.
  13. *
  14. * @static
  15. * @memberOf _
  16. * @since 4.3.0
  17. * @category Lang
  18. * @param {*} value The value to check.
  19. * @returns {boolean} Returns `true` if `value` is correctly classified,
  20. * else `false`.
  21. * @example
  22. *
  23. * _.isArrayBuffer(new ArrayBuffer(2));
  24. * // => true
  25. *
  26. * _.isArrayBuffer(new Array(2));
  27. * // => false
  28. */
  29. function isArrayBuffer(value) {
  30. return isObjectLike(value) && objectToString.call(value) == arrayBufferTag;
  31. }
  32. module.exports = isArrayBuffer;