index.js 691 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. var isString = require('is-string');
  3. var isNumber = require('is-number-object');
  4. var isBoolean = require('is-boolean-object');
  5. var isSymbol = require('is-symbol');
  6. var isBigInt = require('is-bigint');
  7. // eslint-disable-next-line consistent-return
  8. module.exports = function whichBoxedPrimitive(value) {
  9. // eslint-disable-next-line eqeqeq
  10. if (value == null || (typeof value !== 'object' && typeof value !== 'function')) {
  11. return null;
  12. }
  13. if (isString(value)) {
  14. return 'String';
  15. }
  16. if (isNumber(value)) {
  17. return 'Number';
  18. }
  19. if (isBoolean(value)) {
  20. return 'Boolean';
  21. }
  22. if (isSymbol(value)) {
  23. return 'Symbol';
  24. }
  25. if (isBigInt(value)) {
  26. return 'BigInt';
  27. }
  28. };