UNPKG

immutable-class

Version:

A template for creating immutable classes

19 lines (18 loc) 591 B
export function isArrayOf(things, constructor) { if (!Array.isArray(things)) return false; for (let i = 0, length = things.length; i < length; i++) { if (!(things[i] instanceof constructor)) return false; } return true; } export function isImmutableClass(thing) { if (!thing || typeof thing !== 'object') return false; const ClassFn = thing.constructor; return (typeof ClassFn.fromJS === 'function' && typeof thing.toJS === 'function' && typeof thing.equals === 'function'); } export function typeCheck(_x) { }