ts-data-forge
    Preparing search index...
    • Type guard that checks if a value is a non-null object.

      This function checks if a value has type "object" according to the typeof operator and is not null. This includes all object types such as plain objects, arrays, dates, regular expressions, and other object instances, but excludes functions.

      Type Narrowing Behavior:

      • Narrows unknown to object
      • Excludes null, undefined, and all primitive types
      • Excludes functions (they have typeof === "function", not "object")
      • Includes arrays, dates, regex, and other object instances

      Note: This function returns true for arrays. If you need to check for plain objects specifically (excluding arrays), use isRecord() instead.

      Parameters

      • u: unknown

        The value to check

      Returns u is object

      true if u is an object and not null, false otherwise. When true, TypeScript narrows the type to object.

      const mixed: unknown[] = [{ id: 1 }, null, 'Ada'] as const;

      const objects = mixed.filter(isNonNullObject);

      assert.deepStrictEqual(objects, [{ id: 1 }]);

      isRecord - For checking plain objects specifically (excludes arrays)