@rimbu/base
Version:
Utilities to implement Rimbu collections
27 lines • 971 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.isIterable = exports.isPlainObj = void 0;
/**
* 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
*/
function isPlainObj(obj) {
return (typeof obj === 'object' &&
null !== obj &&
(obj.constructor === Object || !(obj.constructor instanceof Function)) &&
!(Symbol.iterator in obj) &&
!(Symbol.asyncIterator in obj));
}
exports.isPlainObj = isPlainObj;
/**
* Returns true if the given object is Iterable
* @param obj - the object to check
*/
function isIterable(obj) {
return obj !== null && typeof obj === 'object' && Symbol.iterator in obj;
}
exports.isIterable = isIterable;
//# sourceMappingURL=plain-object.cjs.map
;