index.js 459 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. var isMap = require('is-map');
  3. var isSet = require('is-set');
  4. var isWeakMap = require('is-weakmap');
  5. var isWeakSet = require('is-weakset');
  6. module.exports = function whichCollection(value) {
  7. if (value && typeof value === 'object') {
  8. if (isMap(value)) {
  9. return 'Map';
  10. }
  11. if (isSet(value)) {
  12. return 'Set';
  13. }
  14. if (isWeakMap(value)) {
  15. return 'WeakMap';
  16. }
  17. if (isWeakSet(value)) {
  18. return 'WeakSet';
  19. }
  20. }
  21. return false;
  22. };