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