@webdeveric/utils
    Preparing search index...

    Function isAnyObjectWith

    • Determine if input is an object and has the provided property or properties.

      Type Parameters

      • T
      • P extends PropertyKey

      Parameters

      • input: T
      • properties: P | P[]

      Returns input is T & Record<P, unknown>

      isAnyObjectWith({ a: 1 }, 'a'); // true
      isAnyObjectWith({ a: 1 }, 'b'); // false
      isAnyObjectWith({ a: 1, b: 2 }, ['a', 'b']); // true
      isAnyObjectWith({ a: 1 }, ['a', 'b']); // false
      isAnyObjectWith({}, 'toString'); // true (inherited properties are included)
      isAnyObjectWith(['a'], 0); // true (arrays are objects)
      isAnyObjectWith(null, 'a'); // false