ChemPal Documentation - v0.0.13-beta.5
    Preparing search index...
    • Check if a value is a plain object or array.

      Parameters

      • v: unknown

        The value to check.

      Returns v is object

      True if the value is a plain object or array, false otherwise.

      const obj = { a: 1, b: 2, c: 3 };
      isPlainContainer(obj) // true
      isPlainContainer([1, 2, 3]) // true
      isPlainContainer(1) // false
      isPlainContainer("hello") // false
      isPlainContainer(null) // false
      isPlainContainer(undefined) // false
      export function isPlainContainer(v: unknown): v is object {
      if (v == null || typeof v !== "object") return false;
      if (Array.isArray(v)) return true;
      const proto = Object.getPrototypeOf(v);
      return proto === Object.prototype || proto === null;
      }