UNPKG

@rimbu/base

Version:

Utilities to implement Rimbu collections

22 lines 792 B
/** * Companion function to the `IsRecord<T>` type that checks whether the given object is a pure * data object. * @param obj - the object to check * @returns true if the given object is a pure data object * @note does not check whether a record's properties are not functions */ export function isPlainObj(obj) { return (typeof obj === 'object' && null !== obj && (obj.constructor === Object || !(obj.constructor instanceof Function)) && !(Symbol.iterator in obj) && !(Symbol.asyncIterator in obj)); } /** * Returns true if the given object is Iterable * @param obj - the object to check */ export function isIterable(obj) { return obj !== null && typeof obj === 'object' && Symbol.iterator in obj; } //# sourceMappingURL=plain-object.mjs.map