isWeakSet.js 643 B

12345678910111213141516171819202122232425262728
  1. var baseGetTag = require('./_baseGetTag'),
  2. isObjectLike = require('./isObjectLike');
  3. /** `Object#toString` result references. */
  4. var weakSetTag = '[object WeakSet]';
  5. /**
  6. * Checks if `value` is classified as a `WeakSet` object.
  7. *
  8. * @static
  9. * @memberOf _
  10. * @since 4.3.0
  11. * @category Lang
  12. * @param {*} value The value to check.
  13. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  14. * @example
  15. *
  16. * _.isWeakSet(new WeakSet);
  17. * // => true
  18. *
  19. * _.isWeakSet(new Set);
  20. * // => false
  21. */
  22. function isWeakSet(value) {
  23. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  24. }
  25. module.exports = isWeakSet;