@luolapeikko/ts-common
    Preparing search index...

    Function objectEntries

    • Type-safe Object.entries() with overload for NonEmptyArray

      Type Parameters

      • R extends Record<string | number | symbol, unknown>

        The object shape

      Parameters

      • value: R

        The object shape to get the values from

      Returns ObjectMappedArrayTuples<R>

      Array of tuples with key and value

      const result1: NonEmptyReadonlyArray<['key', 'value']> = objectEntries({key: 'value'} as const);
      const result2: Array<['key', string]> = objectEntries({key: 'value'});
      const result3: Array<[string, string]> = objectEntries<Record<string, string>>({key: 'value'});
      const result4: [] = objectEntries({});

      v0.2.0