
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
get-object-class
Advanced tools
A more explicit improvement on typeof
$ npm i get-object-class --save
// ES2015
import goc from 'get-object-class';
// CommonJS
const goc = require('get-object-class');
// script
const goc = window.getObjectClass;
const array = [];
const promise = Promise.resolve();
console.log(goc(array)); // array
console.log(goc(promise)); // promise
Generally speaking, you can use the typeof operator to determine a number of object classes:
However, this list is quite limited, and things can get confusing for other classes of objects:
console.log(typeof new Date()); // object
console.log(typeof null); // object
This library rectifies that by giving you the specific object class for any object (if I missed one tell me, I'll add it):
argumentsarrayarraybufferbooleandataviewdateerrorfloat32arrayfloat64arrayfunctiongeneratorfunctionglobal (specific to node)int8arrayint16arrayint32arrayjson (tests the JSON object itself, not if the value is a valid JSON string)mapmathnullnumberobjectpromiseregexpsetstringsymboluint8arrayuint8Clampedarrayuint16arrayuint32arrayweakmapweaksetwindow (specific to browser)get-object-class also provides a checker function for each object class, example:
const array = [];
const boolean = true;
console.log(goc.isArray(array)); // true
console.log(goc.isBoolean(array)); // false
Keep in mind that the name of the function is driven by the PascalCase names in the list above:
const regexp = /foo/;
console.log(goc.isRegExp(regexp)); // true
console.log(goc.isFloat32Array(regexp)); // false
console.log(goc.isJSON(regexp)); // false
Standard stuff, clone the repo and npm i to get the dependencies. npm scripts available:
build => builds the distributed JS with NODE_ENV=development and with sourcemapsbuild-minified => builds the distributed JS with NODE_ENV=production and minifiedcompile-for-publish => runs the lint, test, transpile, build, and build-minified scriptsdev => runs the webpack dev server for the playgroundlint => runs ESLint against files in the src folderprepublish => if in publish, runs compile-for-publishtest => run ava with NODE_ENV=testtest:watch => runs test but with persistent watchertranspile => runs Babel against files in src to files in libFAQs
Get the class type of any object
The npm package get-object-class receives a total of 0 weekly downloads. As such, get-object-class popularity was classified as not popular.
We found that get-object-class demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.