Skip to content

Commit

Permalink
implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Aug 10, 2019
1 parent a8be993 commit 8811c32
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
30 changes: 30 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

var isString = require('is-string');
var isNumber = require('is-number-object');
var isBoolean = require('is-boolean-object');
var isSymbol = require('is-symbol');
var isBigInt = require('is-bigint');

// eslint-disable-next-line consistent-return
module.exports = function whichBoxedPrimitive(value) {
// eslint-disable-next-line eqeqeq
if (value == null || (typeof value !== 'object' && typeof value !== 'function')) {
return null;
}
if (isString(value)) {
return 'String';
}
if (isNumber(value)) {
return 'Number';
}
if (isBoolean(value)) {
return 'Boolean';
}
if (isSymbol(value)) {
return 'Symbol';
}
if (isBigInt(value)) {
return 'BigInt';
}
};
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
"url": "https://github.com/ljharb/which-boxed-primitive/issues"
},
"homepage": "https://github.com/ljharb/which-boxed-primitive#readme",
"dependencies": {
"is-bigint": "^1.0.0",
"is-boolean-object": "^1.0.0",
"is-number-object": "^1.0.3",
"is-string": "^1.0.4",
"is-symbol": "^1.0.2"
},
"devDependencies": {
"@ljharb/eslint-config": "^14.0.2",
"eslint": "^6.1.0"
Expand Down

0 comments on commit 8811c32

Please sign in to comment.