Types
isPureObj

Checks if the given value is an Object (opens in a new tab) and not null.

In JavaScript typeof null is 'object'.

Syntax

import { isPureObj } from '@opentf/std';
 
isPureObj(val: unknown): boolean;

Examples

//Invalid cases
// ************
 
isPureObj(undefined) //=> false
 
isPureObj(null) //=> false
 
isPureObj(true) //=> false
 
isPureObj(false) //=> false
 
isPureObj(0) //=> false
 
isPureObj(1n) //=> false
 
isPureObj('') //=> false
 
isPureObj(() => {}) //=> false
 
isPureObj(Symbol) //=> false
 
isPureObj(Math.min) //=> false
 
isPureObj(Map) //=> false
 
isPureObj(Set) //=> false
 
isPureObj(Error) //=> false
 
 
// Valid cases
// ***********
 
isPureObj(/./) //=> true
 
isPureObj(new Map()) //=> true
 
isPureObj(new Set()) //=> true
 
isPureObj(Math) //=> true
 
isPureObj(new Error()) //=> true
 
isPureObj([]) //=> true
 
isPureObj({}) //=> true
 
isPureObj({ a: 1 }) //=> true
 
isPureObj(new Object()) //=> true
 
isPureObj(Object.create(null)) //=> true

Try