ts-data-forge
    Preparing search index...
    • Checks if an index is within the valid range of an array.

      Type Parameters

      • E

      Parameters

      • array: readonly E[]
      • index: ArgArr

      Returns boolean

      const items = ['Ada', 'Grace', 'Katherine'] as const;

      assert.ok(Arr.indexIsInRange(items, 1));
      assert.notOk(Arr.indexIsInRange(items, 3));

      if (Arr.indexIsInRange(items, 2)) {
      assert(items[2] === 'Katherine');
      }