Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 651 Bytes

File metadata and controls

26 lines (18 loc) · 651 Bytes

Data types

  • Check whether a value is a plain object
const checkIsPlainObject = (value: unknown): value is Record<string, any> =>
  Object.prototype.toString.call(value) === '[object Object]' &&
  [Object.prototype, null].includes(Object.getPrototypeOf(value));
  • Get the actual type of JavaScript primitives
const trueType = (value: unknown) => 
  Object.prototype.toString.call(value).slice(8, -1).toLowerCase();

isNil

Check whether a value is null or undefined

type Nil = undefined | null;

const isNil = (value: unknown): value is Nil => value === undefined || value === null;