Changelog - 2026-11-08
RecordUtility.isPlainObject, a guard that checks the prototype
FeatureIn one line. Code that must accept only a literal-shaped object, such as a JSON body or a config, can now use RecordUtility.isPlainObject(value). It refuses a class instance, which isRecord and isPlainRecord accept.
What changed
RecordUtility.isPlainObject(value)in@venizia/ignis-helpersand@venizia/ignis-helpers/core. A type guard: it narrowsunknowntoRecord<string, unknown>.- True for a non-null object whose prototype is exactly
Object.prototypeornull: an object literal,JSON.parseoutput andObject.create(null). - False for an array, a class instance (
Error,Date,Map), a function, a primitive, an object whose prototype is another object (Object.create(Object.create(null))) and an object from another realm, such as one made innode:vm. - Never throws. A Proxy whose
getPrototypeOftrap throws, or a revoked Proxy, answersfalse. - Not a change to
isRecordandisPlainRecord. They still check only the type of the value, so anErrorstill passes them.
ts
if (RecordUtility.isPlainObject(body)) {
// body is a Record<string, unknown> made from a literal or JSON, never a class instance
}Who is affected
Nobody needs to act. It adds a method; no existing call site is changed.
Details
- An object that only carries its own
Symbol.toStringTagproperty is still plain. A class instance that has the tag is not. - A Proxy is judged by what its
getPrototypeOfanswers, which is its target's prototype unless the trap says otherwise.
| File | Package |
|---|---|
src/utilities/record.utility.ts | helpers |