
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
ts-type-detector
Advanced tools
Takes any JavaScript data type or object as an input and returns a string describing the type of the input.
Takes any JavaScript data type or object as an input and returns a string describing the type of the input.
The ts-type-detector library is help to identify the data type of the input provided to it. This document outlines how to use the API, including the available methods, request parameters, and response formats.
import whoami from 'ts-type-detector';whoami(input)The whoami function takes any JavaScript data type or object as an input and returns a string describing the type of the input.
input (any): The input parameter whose type needs to be identified.(string): A string describing the type of the input. Possible return values include:
'undefined''null''boolean''number''string''array''object''buffer''date''regexp''function''error''promise''generatorfunction''generator''map''weakmap''set''weakset''setiterator''mapiterator''arrayiterator''stringiterator''symbol''int8array''uint8array''uint8clampedarray''int16array''uint16array''int32array''uint32array''float32array''float64array'const result = whoami(undefined);
//=> 'undefined'
const result = whoami(null);
//=> 'null'
const result = whoami(true);
//=> 'boolean'
const result = whoami(false);
//=> 'boolean'
const result = whoami(new Buffer(''));
//=> 'buffer'
const result = whoami(42);
//=> 'number'
const result = whoami('str');
//=> 'string'
const result = whoami(arguments);
//=> 'arguments'
const result = whoami({});
//=> 'object'
const result = whoami(Object.create(null));
//=> 'object'
const result = whoami(new Test());
//=> 'object'
const result = whoami(new Date());
//=> 'date'
const result = whoami([1, 2, 3]);
//=> 'array'
const result = whoami(/foo/);
//=> 'regexp'
const result = whoami(new RegExp('foo'));
//=> 'regexp'
const result = whoami(new Error('error'));
//=> 'error'
const result = whoami(function () {});
//=> 'function'
const result = whoami(function* () {});
//=> 'generatorfunction'
const result = whoami(Symbol('str'));
//=> 'symbol'
const result = whoami(new Map());
//=> 'map'
const result = whoami(new WeakMap());
//=> 'weakmap'
const result = whoami(new Set());
//=> 'set'
const result = whoami(new WeakSet());
//=> 'weakset'
const result = whoami(new Int8Array());
//=> 'int8array'
const result = whoami(new Uint8Array());
//=> 'uint8array'
const result = whoami(new Uint8ClampedArray());
//=> 'uint8clampedarray'
const result = whoami(new Int16Array());
//=> 'int16array'
const result = whoami(new Uint16Array());
//=> 'uint16array'
const result = whoami(new Int32Array());
//=> 'int32array'
const result = whoami(new Uint32Array());
//=> 'uint32array'
const result = whoami(new Float32Array());
//=> 'float32array'
const result = whoami(new Float64Array());
//=> 'float64array'
If an unsupported data type or object is passed, it may return 'unknown' or throw an error.
FAQs
Takes any JavaScript data type or object as an input and returns a string describing the type of the input.
We found that ts-type-detector 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.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.