MCPcopy
hub / github.com/sindresorhus/is / getObjectType

Function getObjectType

source/index.ts:181–193  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

179export type AssertionTypeDescription = typeof assertionTypeDescriptions[number];
180
181const getObjectType = (value: unknown): ObjectTypeName | undefined => {
182 const objectTypeName = Object.prototype.toString.call(value).slice(8, -1);
183
184 if (/HTML\w+Element/v.test(objectTypeName) && isHtmlElement(value)) {
185 return 'HTMLElement';
186 }
187
188 if (isObjectTypeName(objectTypeName)) {
189 return objectTypeName;
190 }
191
192 return undefined;
193};
194
195function detect(value: unknown): TypeName {
196 if (value === null) {

Callers 15

detectFunction · 0.85
isArrayBufferFunction · 0.85
isAsyncFunctionFunction · 0.85
isAsyncGeneratorFunctionFunction · 0.85
isBigInt64ArrayFunction · 0.85
isBigUint64ArrayFunction · 0.85
isBlobFunction · 0.85
isDataViewFunction · 0.85
isDateFunction · 0.85
isErrorFunction · 0.85
isFloat32ArrayFunction · 0.85
isFloat64ArrayFunction · 0.85

Calls 2

isHtmlElementFunction · 0.85
isObjectTypeNameFunction · 0.85

Tested by

no test coverage detected