Skip to content

Extended native JavaScript Array which provides indexed lookup similar to native Map.

License

Notifications You must be signed in to change notification settings

ozum/indexable-array

Repository files navigation

indexable-array

Commitizen friendly Conventional Commits

Extended native JavaScript Array which provides indexed lookup similar to native Map.

Installation

npm install indexable-array

Description

indexable-array extends native JavaScript array and provides indexed lookup features similar to native Map by using Proxy for shallow change detection.

Synopsis

import IndexableArray, { Self } from "indexable-array";

const users = new IndexableArray({ id: 23, name: "George" }, { id: 92, name: "George" }).addIndex("name", Self);
const otherUsers = new IndexableArray({ id: 12, name: "Hans" }, { id: 18, name: "Tanja" }).addIndex("name").addSelfIndex();

Array.isArray(users); // true
users.getIndex("George"); // 1
users.get("George"); // Get first George: { id: 23, name: "George"}
users.get("George", { fromIndex: 1 }); // Get first George starting from index 1: { id: 23, name: "George"}
users.getAllIndexes("George"); // [0, 1]

// Replace George with Henry
const newUser = { id: 21, name: "Henry" };
users[0] = newUser;
users.getIndex(newUser); // 0 - It is possible to index whole object by { selfIndex: true } option.

// Add another Henry
users.splice(1, 1, { id: 34, name: "Henry" });
users.getAllIndexes("Henry"); // [0, 1];

// You may want to disable en re-enable index for heavy updates for performance reasons.
users.disableIndex(); // Disable index before heavy updates.
// ... many many many updates here
users.enableIndex(); // Index is recreated from scratch.

// Do NOT change deeply nested values in indexed fields.
// users[0].name = "DON'T DO THIS";       // WRONG: Sub fields (i.e. [0]."name") of the array is not watched, so index does not get updated.

// To change nested values use `set()`
users.set(0, "name", "OK"); // Index updated.

// or (not preferred because of expensive index creation for a small update)
users.disableIndex();
users[0].name = "Prefer set()";
users.enableIndex(); // Index is recreated from scratch.

Details

  • Written in TypeScript.
  • Is a native Array (Array.isArray(indexableArray) === true), so supports all array features.
  • 100% test coverage.
  • Tracks all shallow changes via by using Proxy
  • Limited support for updating deep properties via set() method.
  • Uses map to index for very fast lookups.
  • Uses binary search for updates for faster index update.
  • Disables and recreates index from scratch automatically for heavy update operations like splice if above threshold..
  • Indexing may be disabled and re-enabled for heavy update operations manually.
  • Uses binary search for indexOf(), lastIndexOf(), has() if user added self index.
  • Methods such as map(), filter(), slice() returns IndexedArray. Additionally provides mapIndexed() method.

API

indexable-array

indexable-array

Table of contents

Classes

Classes

indexable-array / default

Class: default<I, DK, OK, TH>

Extended native array class to access array elements by fast key lookups using binary search. Used for storing objects.

Example

import IndexableArray, { Self } from "indexable-array";
const users = new IndexableArray({ id: 23, name: "Geroge" }, { id: 96, name: "Lisa" }).addIndex("name");
Array.isArray(users); // true
users.get("George"); // { id: 23, name: "George"}
const user = { id: 21, name: "Henry" };
users[0] = user;
users.getIndex(user); // 0 - It is possible to index whole object by { selfIndex: true } option.
users.splice(1, 1, { id: 34, name: "Henry" });
users.getAllIndexes("Henry"); // [0, 1];

users[0].name = "DON'T DO THIS"; // WRONG: Sub fields (i.e. [0]."name") of the array is not watched, so index does not get updated.
users.set(0, "name", "OK"); // Index updated.
users.disableIndex();
users[0].name = "THIS IS OK NOW";
users.enableIndex(); // Index is recreated from scratch.

Type parameters

Name Type Default
I any -
DK keyof I -
OK keyof I -
TH boolean false

Hierarchy

  • Array<I>

    default

Table of contents

Properties

Accessors

Methods

Properties

indexedKeys

Readonly indexedKeys: Set<DK | OK>

Set of the indexed key names. $$self is used for the whole value.

Example

const users = new IndexableArray({ id: 23, name: "Geroge" }, { id: 96, name: "Lisa" }).addSelfIndex().addIndex("name");
users.indexedArray; // ["$$self", "name"]

Defined in: index.ts:77

Accessors

defaultKey

defaultKey(): DK

Returns: DK

Defined in: index.ts:200

Methods

concat

concat(...items: ConcatArray<I>[]): default<I, DK, OK, TH>

Parameters:

Name Type
...items ConcatArray<I>[]

Returns: default<I, DK, OK, TH>

Defined in: index.ts:672

concat(...items: (I | ConcatArray<I>)[]): default<I, DK, OK, TH>

Parameters:

| Name | Type | | ---------- | ---- | -------------------- | | ...items | (I | ConcatArray<I>)[] |

Returns: default<I, DK, OK, TH>

Defined in: index.ts:673


disableIndex

disableIndex(): void

Disables indexing of the array. It may be used to disable temporarily

  • to do heavy updates for performance reasons,
  • to do operations in sub fields. If indexing is not needed anymore, it is suggested to create a new native non-extended array and copy values into it for avoiding performance penalty of proxy array used in this library.

Example

indexedArray.disableIndex();
indexedArray[0].name = "THIS IS OK NOW";
indexedArray.enableIndex(); // Index is recreated from scratch.

see {IndexedArray#enableIndex} method.

Returns: void

Defined in: index.ts:857


enableIndex

enableIndex(): void

Enables indexing and recreates index from scratch.

see {IndexedArray#disableIndex} method.

Returns: void

Defined in: index.ts:866


filter

filter<S>(callbackfn: (value: I, index: number, array: default<I, DK, OK, TH>) => value is S, thisArg?: any): default<S, DK, OK, TH>

Type parameters:

Name Type
S unknown

Parameters:

Name Type
callbackfn (value: I, index: number, array: default<I, DK, OK, TH>) => value is S
thisArg? any

Returns: default<S, DK, OK, TH>

Defined in: index.ts:466

filter(callbackfn: Callback<I, DK, OK, TH, unknown>, thisArg?: any): default<I, DK, OK, TH>

Parameters:

Name Type
callbackfn Callback<I, DK, OK, TH, unknown>
thisArg? any

Returns: default<I, DK, OK, TH>

Defined in: index.ts:471


flatMap

flatMap<U, DK2, OK2, This>(callbackFn: CallbackThis<I, DK, OK, TH, U | readonly U[], This>, defaultKey?: DK2, ...indexKeys: OK2[]): default<U, DK2, Exclude<OK2, DK2>, TH>

Type parameters:

| Name | Type | Default | | ------ | ------------ | ------------------------------ | ----------- | --- | | U | Pick<I, DK | OK> | - | | DK2 | string | number | symbol | DK | | OK2 | string | number | symbol | OK | | This | undefined | Record<string, unknown> | undefined |

Parameters:

| Name | Type | | -------------- | ------------------------------- | -------------------- | | callbackFn | CallbackThis<I, DK, OK, TH, U | readonly U[], This> | | defaultKey? | DK2 | | ...indexKeys | OK2[] |

Returns: default<U, DK2, Exclude<OK2, DK2>, TH>

Defined in: index.ts:558

flatMap<U, DK2, OK2, This>(callbackFn: CallbackThis<I, DK, OK, TH, U | readonly U[], This>, thisArg: This, defaultKey?: DK2, ...indexKeys: OK2[]): default<U, DK2, Exclude<OK2, DK2>, TH>

Type parameters:

| Name | Type | Default | | ------ | ------------ | ------------------------------ | ----------- | --- | | U | Pick<I, DK | OK> | - | | DK2 | string | number | symbol | DK | | OK2 | string | number | symbol | OK | | This | undefined | Record<string, unknown> | undefined |

Parameters:

| Name | Type | | -------------- | ------------------------------- | -------------------- | | callbackFn | CallbackThis<I, DK, OK, TH, U | readonly U[], This> | | thisArg | This | | defaultKey? | DK2 | | ...indexKeys | OK2[] |

Returns: default<U, DK2, Exclude<OK2, DK2>, TH>

Defined in: index.ts:569

flatMap<U, DK2, OK2, This>(callbackFn: CallbackThis<I, DK, OK, TH, U | readonly U[], This>, defaultKey: DK2, ...indexKeys: OK2[]): default<U, DK2, Exclude<OK2, DK2>, TH>

Type parameters:

| Name | Type | Default | | ------ | ------------------------------ | ------------------------------ | ----------- | ------- | | U | Record<string, unknown> | - | | DK2 | string | number | symbol | - | | OK2 | string | number | symbol | never | | This | undefined | Record<string, unknown> | undefined |

Parameters:

| Name | Type | | -------------- | ------------------------------- | -------------------- | | callbackFn | CallbackThis<I, DK, OK, TH, U | readonly U[], This> | | defaultKey | DK2 | | ...indexKeys | OK2[] |

Returns: default<U, DK2, Exclude<OK2, DK2>, TH>

Defined in: index.ts:581

flatMap<U, DK2, OK2, This>(callbackFn: CallbackThis<I, DK, OK, TH, U | readonly U[], This>, thisArg: This, defaultKey: DK2, ...indexKeys: OK2[]): default<U, DK2, Exclude<OK2, DK2>, TH>

Type parameters:

| Name | Type | Default | | ------ | ------------------------------ | ------------------------------ | ----------- | ------- | | U | Record<string, unknown> | - | | DK2 | string | number | symbol | - | | OK2 | string | number | symbol | never | | This | undefined | Record<string, unknown> | undefined |

Parameters:

| Name | Type | | -------------- | ------------------------------- | -------------------- | | callbackFn | CallbackThis<I, DK, OK, TH, U | readonly U[], This> | | thisArg | This | | defaultKey | DK2 | | ...indexKeys | OK2[] |

Returns: default<U, DK2, Exclude<OK2, DK2>, TH>

Defined in: index.ts:592

flatMap<U, This>(callbackFn: CallbackThis<I, DK, OK, TH, U | readonly U[], This>, thisArg?: This, ...rest: never[]): default<U, AvailableDefaultIndex<U, DK, OK>, Exclude<Extract<OK, keyof U>, AvailableDefaultIndex<U, DK, OK>>, TH>

Type parameters:

| Name | Type | Default | | ------ | ------------------------------ | ------------------------------ | ----------- | | U | Record<string, unknown> | - | | This | undefined | Record<string, unknown> | undefined |

Parameters:

| Name | Type | | ------------ | ------------------------------- | -------------------- | | callbackFn | CallbackThis<I, DK, OK, TH, U | readonly U[], This> | | thisArg? | This | | ...rest | never[] |

Returns: default<U, AvailableDefaultIndex<U, DK, OK>, Exclude<Extract<OK, keyof U>, AvailableDefaultIndex<U, DK, OK>>, TH>

Defined in: index.ts:604

flatMap<U, This>(callbackFn: CallbackThis<I, DK, OK, TH, U | readonly U[], This>, thisArg?: This, ...rest: never[]): default<U, AvailableDefaultIndex<U, DK, OK>, Exclude<Extract<OK, keyof U>, AvailableDefaultIndex<U, DK, OK>>, TH>

Type parameters:

| Name | Type | Default | | ------ | ----------- | ------------------------------ | ----------- | | U | unknown | - | | This | undefined | Record<string, unknown> | undefined |

Parameters:

| Name | Type | | ------------ | ------------------------------- | -------------------- | | callbackFn | CallbackThis<I, DK, OK, TH, U | readonly U[], This> | | thisArg? | This | | ...rest | never[] |

Returns: default<U, AvailableDefaultIndex<U, DK, OK>, Exclude<Extract<OK, keyof U>, AvailableDefaultIndex<U, DK, OK>>, TH>

Defined in: index.ts:610


get

get<K, TH2>(value: I[K], __namedParameters?: { fromIndex?: undefined | number ; key?: undefined | K ; throwUnknown?: undefined | TH2 }): TH2 extends true ? I : undefined | I

Returns the first item at which a given indexed value can be found in the array. According to construction option or throwUnknown option, returns undefined or throws exception if value cannot be found.

Type parameters:

| Name | Type | Default | | ----- | ----------- | --------- | -------- | --- | | K | string | number | symbol | - | | TH2 | undefined | boolean | TH |

Parameters:

value: I[K]

is indexed value to search for.

__namedParameters: object

| Name | Type | | --------------- | ----------- | -------- | | fromIndex? | undefined | number | | key? | undefined | K | | throwUnknown? | undefined | TH2 |

Returns: TH2 extends true ? I : undefined | I

the first item with given indexed value in the array; undefined if not found.

Defined in: index.ts:743


getAll

getAll<K>(value: I[K], __namedParameters?: { key?: undefined | K }): I[]

Returns all items at which a given indexed value can be found in the array, or empty array if it is not present.

Type parameters:

| Name | Type | | ---- | -------- | -------- | -------- | | K | string | number | symbol |

Parameters:

value: I[K]

is indexed value to search for.

__namedParameters: object

| Name | Type | | ------ | ----------- | --- | | key? | undefined | K |

Returns: I[]

all items with given indexed value in the array; Empty array if not found.

Defined in: index.ts:799


getAllIndexes

getAllIndexes<K>(value: I[K], __namedParameters?: { key?: undefined | K }): number[]

Returns all indexes at which a given indexed value can be found in the array, or empty array if it is not present.

Type parameters:

| Name | Type | | ---- | -------- | -------- | -------- | | K | string | number | symbol |

Parameters:

value: I[K]

indexed value to search for.

__namedParameters: object

| Name | Type | | ------ | ----------- | --- | | key? | undefined | K |

Returns: number[]

all indexes of the element in the array; Empty array if not found.

Defined in: index.ts:727


getIndex

getIndex<K>(value: I[K], __namedParameters?: { fromIndex?: undefined | number ; key?: undefined | K }): number

Returns the first index at which a given indexed value can be found in the array, or -1 if it is not present.

Type parameters:

| Name | Type | | ---- | -------- | -------- | -------- | | K | string | number | symbol |

Parameters:

value: I[K]

indexed value to search for.

__namedParameters: object

| Name | Type | | ------------ | ----------- | -------- | | fromIndex? | undefined | number | | key? | undefined | K |

Returns: number

the first index of the element in the array; -1 if not found.

Defined in: index.ts:704


getMaybe

getMaybe<K>(value: I[K], __namedParameters?: { fromIndex?: undefined | number ; key?: undefined | K }): undefined | I

Returns the first item at which a given indexed value can be found in the array. Returns undefined if value cannot be found.

Type parameters:

| Name | Type | | ---- | -------- | -------- | -------- | | K | string | number | symbol |

Parameters:

value: I[K]

is indexed value to search for.

__namedParameters: object

| Name | Type | | ------------ | ----------- | -------- | | fromIndex? | undefined | number | | key? | undefined | K |

Returns: undefined | I

is the first item with given indexed value in the array; undefined if not found.

Defined in: index.ts:784


getSure

getSure<K>(value: I[K], __namedParameters?: { fromIndex?: undefined | number ; key?: undefined | K }): I

Returns the first item at which a given indexed value can be found in the array, or throws exception if it is not present.

Type parameters:

| Name | Type | | ---- | -------- | -------- | -------- | | K | string | number | symbol |

Parameters:

value: I[K]

is indexed value to search for.

__namedParameters: object

| Name | Type | | ------------ | ----------- | -------- | | fromIndex? | undefined | number | | key? | undefined | K |

Returns: I

the first item with given indexed value in the array; undefined if not found.

Defined in: index.ts:771


has

has<K>(value: I[K], __namedParameters?: { fromIndex?: undefined | number ; key?: undefined | K }): boolean

Determines whether an array includes a certain indexed value among its entries' keys, returning true or false as appropriate.

Type parameters:

| Name | Type | | ---- | -------- | -------- | -------- | | K | string | number | symbol |

Parameters:

value: I[K]

is indexed value to search for.

__namedParameters: object

| Name | Type | | ------------ | ----------- | -------- | | fromIndex? | undefined | number | | key? | undefined | K |

Returns: boolean

true if indexed value is found among array's entries' keys.

Defined in: index.ts:814


map

map<U, DK2, OK2>(callbackFn: Callback<I, DK, OK, TH, U>, defaultKey?: DK2, ...indexKeys: OK2[]): default<U, DK2, Exclude<OK2, DK2>, TH>

Type parameters:

| Name | Type | Default | | ----- | ------------ | -------- | -------- | --- | | U | Pick<I, DK | OK> | - | | DK2 | string | number | symbol | DK | | OK2 | string | number | symbol | OK |

Parameters:

Name Type
callbackFn Callback<I, DK, OK, TH, U>
defaultKey? DK2
...indexKeys OK2[]

Returns: default<U, DK2, Exclude<OK2, DK2>, TH>

Defined in: index.ts:481

map<U, DK2, OK2>(callbackFn: Callback<I, DK, OK, TH, U>, thisArg: Record<string, unknown>, defaultKey?: DK2, ...indexKeys: OK2[]): default<U, DK2, Exclude<OK2, DK2>, TH>

Type parameters:

| Name | Type | Default | | ----- | ------------ | -------- | -------- | --- | | U | Pick<I, DK | OK> | - | | DK2 | string | number | symbol | DK | | OK2 | string | number | symbol | OK |

Parameters:

Name Type
callbackFn Callback<I, DK, OK, TH, U>
thisArg Record<string, unknown>
defaultKey? DK2
...indexKeys OK2[]

Returns: default<U, DK2, Exclude<OK2, DK2>, TH>

Defined in: index.ts:487

map<U, DK2, OK2>(callbackFn: Callback<I, DK, OK, TH, U>, defaultKey: DK2, ...indexKeys: OK2[]): default<U, DK2, Exclude<OK2, DK2>, TH>

Type parameters:

| Name | Type | Default | | ----- | ------------------------------ | -------- | -------- | ------- | | U | Record<string, unknown> | - | | DK2 | string | number | symbol | - | | OK2 | string | number | symbol | never |

Parameters:

Name Type
callbackFn Callback<I, DK, OK, TH, U>
defaultKey DK2
...indexKeys OK2[]

Returns: default<U, DK2, Exclude<OK2, DK2>, TH>

Defined in: index.ts:494

map<U, DK2, OK2>(callbackFn: Callback<I, DK, OK, TH, U>, thisArg: Record<string, unknown>, defaultKey: DK2, ...indexKeys: OK2[]): default<U, DK2, Exclude<OK2, DK2>, TH>

Type parameters:

| Name | Type | Default | | ----- | ------------------------------ | -------- | -------- | ------- | | U | Record<string, unknown> | - | | DK2 | string | number | symbol | - | | OK2 | string | number | symbol | never |

Parameters:

Name Type
callbackFn Callback<I, DK, OK, TH, U>
thisArg Record<string, unknown>
defaultKey DK2
...indexKeys OK2[]

Returns: default<U, DK2, Exclude<OK2, DK2>, TH>

Defined in: index.ts:500

map<U>(callbackFn: Callback<I, DK, OK, TH, U>, thisArg?: Record<string, unknown>): default<U, AvailableDefaultIndex<U, DK, OK>, Exclude<Extract<OK, keyof U>, AvailableDefaultIndex<U, DK, OK>>, TH>

Type parameters:

Name Type
U Record<string, unknown>

Parameters:

Name Type
callbackFn Callback<I, DK, OK, TH, U>
thisArg? Record<string, unknown>

Returns: default<U, AvailableDefaultIndex<U, DK, OK>, Exclude<Extract<OK, keyof U>, AvailableDefaultIndex<U, DK, OK>>, TH>

Defined in: index.ts:507

map<U>(callbackFn: Callback<I, DK, OK, TH, U>, thisArg?: Record<string, unknown>): default<U, AvailableDefaultIndex<U, DK, OK>, Exclude<Extract<OK, keyof U>, AvailableDefaultIndex<U, DK, OK>>, TH>

Type parameters:

Name Type
U unknown

Parameters:

Name Type
callbackFn Callback<I, DK, OK, TH, U>
thisArg? Record<string, unknown>

Returns: default<U, AvailableDefaultIndex<U, DK, OK>, Exclude<Extract<OK, keyof U>, AvailableDefaultIndex<U, DK, OK>>, TH>

Defined in: index.ts:512


mapToArray

mapToArray<U>(callbackfn: Callback<I, DK, OK, TH, U | readonly U[]>, thisArg?: any): U[]

Creates a new base Array (not IndexableArray) with the results of calling a provided function on every element in the calling array.

Example

const usersWithName = new IndexableArray({ id: 23, name: "Geroge" }, { id: 96, name: "Lisa" }).addIndex("name");
const baseArray = usersWithName.mapToArray((user) => ({ id: user.id, nick: name.substring(0, 2) })); // Normal base array.

see {@link IndexableArray#map} to get an IndexableArray.

Type parameters:

Name
U

Parameters:

| Name | Type | Description | | ------------ | --------------------------- | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------- | | callbackfn | Callback<I, DK, OK, TH, U | readonly U[]> | is function that produces an element of the new Array, taking three arguments: value, index and indexableArray. | | thisArg? | any | is value to use as this when executing callback. |

Returns: U[]

a new Array with each element being the result of the callback function.

Defined in: index.ts:664


push

push(...items: I[]): number

Parameters:

Name Type
...items I[]

Returns: number

Defined in: index.ts:422


set

set(position: number, path: string, value: any): void

Sets value at path of the object, which is one of the entires of array. To update fields of the objects, this method should be used. Otherwise index cannot be updated, because sub fileds are not tracked for chage detection.

Example

indexedArray[0].name = "DON'T DO THIS"; // WRONG: Sub fields (i.e. [0]."name") of the array is not watched, so index does not get updated.
indexedArray.set(0, "name", "OK"); // Index updated.

Parameters:

Name Type Description
position number is index of the item to be changed.
path string is item's path where value to be changed at.
value any is new value to be assigned.

Returns: void

Defined in: index.ts:831


slice

slice(start?: number, end?: number): default<I, DK, OK, TH>

Parameters:

Name Type
start? number
end? number

Returns: default<I, DK, OK, TH>

Defined in: index.ts:668


sort

sort(compareFn?: (a: I, b: I) => number): default<I, DK, OK, TH>

Parameters:

Name Type
compareFn? (a: I, b: I) => number

Returns: default<I, DK, OK, TH>

Defined in: index.ts:441


sortBy

sortBy(key?: DK | OK): default<I, DK, OK, TH>

Sorts the elements of an array by given key in place and returns the sorted array.

Parameters:

| Name | Type | Default value | Description | | ----- | ---- | ------------- | ----------- | ---------------------------- | | key | DK | OK | ... | is the key to sort array by. |

Returns: default<I, DK, OK, TH>

this instance.

Defined in: index.ts:454


splice

splice(start: number, deleteCount?: number, ...items: I[]): I[]

Parameters:

Name Type Default value
start number -
deleteCount number ...
...items I[] -

Returns: I[]

Defined in: index.ts:429


withDefaultIndex

withDefaultIndex<K>(key: K): default<I, K, OK, TH>

Sets default index key to be used with lookup functions. Returns same instance.

Example

const input = [
  { id: 23, name: "Geroge" },
  { id: 96, name: "Lisa" },
];
let users = new IndexableArray(...input).addIndex("name", "id"); // "name" is default index
users = users.withDefaultIndex("id"); // "id" is default index. Assignment is used for TypeScript to assign right type to variable.

Type parameters:

| Name | Type | | ---- | -------- | -------- | -------- | | K | string | number | symbol |

Parameters:

Name Type Description
key K is key to be used as default index with lookup functions.

Returns: default<I, K, OK, TH>

this object.

Defined in: index.ts:690


from

Staticfrom<I2, DK2, DK3, OK2, OK3, TH2>(indexableArray: default<I2, DK2, OK2, TH2>, defaultKey?: DK3, ...indexKeys: OK3[]): default<I2, DK3, Exclude<OK3, DK3>, TH2>

Type parameters:

| Name | Type | Default | | ----- | --------- | -------- | -------- | ------- | | I2 | unknown | - | | DK2 | string | number | symbol | - | | DK3 | string | number | symbol | DK2 | | OK2 | string | number | symbol | never | | OK3 | string | number | symbol | OK2 | | TH2 | boolean | false |

Parameters:

Name Type
indexableArray default<I2, DK2, OK2, TH2>
defaultKey? DK3
...indexKeys OK3[]

Returns: default<I2, DK3, Exclude<OK3, DK3>, TH2>

Defined in: index.ts:95

Staticfrom<I2, DK2, OK2>(arrayLike: Iterable<I2> | ArrayLike<I2>, defaultKey: DK2, ...indexKeys: OK2[]): default<I2, DK2, Exclude<OK2, DK2>, false>

Type parameters:

| Name | Type | Default | | ----- | -------- | -------- | -------- | ------- | | I2 | - | - | | DK2 | string | number | symbol | - | | OK2 | string | number | symbol | never |

Parameters:

| Name | Type | | -------------- | --------------- | ---------------- | | arrayLike | Iterable<I2> | ArrayLike<I2> | | defaultKey | DK2 | | ...indexKeys | OK2[] |

Returns: default<I2, DK2, Exclude<OK2, DK2>, false>

Defined in: index.ts:108


throwingFrom

StaticthrowingFrom<I2, DK2, DK3, OK2, OK3, TH2>(indexableArray: default<I2, DK2, OK2, TH2>, defaultKey?: DK3, ...indexKeys: OK3[]): default<I2, DK3, Exclude<OK3, DK3>, true>

Type parameters:

| Name | Type | Default | | ----- | --------- | -------- | -------- | ------- | | I2 | unknown | - | | DK2 | string | number | symbol | - | | DK3 | string | number | symbol | DK2 | | OK2 | string | number | symbol | never | | OK3 | string | number | symbol | OK2 | | TH2 | boolean | false |

Parameters:

Name Type
indexableArray default<I2, DK2, OK2, TH2>
defaultKey? DK3
...indexKeys OK3[]

Returns: default<I2, DK3, Exclude<OK3, DK3>, true>

Defined in: index.ts:154

StaticthrowingFrom<I2, DK2, OK2>(arrayLike: Iterable<I2> | ArrayLike<I2>, defaultKey: DK2, ...indexKeys: OK2[]): default<I2, DK2, Exclude<OK2, DK2>, true>

Type parameters:

| Name | Type | Default | | ----- | -------- | -------- | -------- | ------- | | I2 | - | - | | DK2 | string | number | symbol | - | | OK2 | string | number | symbol | never |

Parameters:

| Name | Type | | -------------- | --------------- | ---------------- | | arrayLike | Iterable<I2> | ArrayLike<I2> | | defaultKey | DK2 | | ...indexKeys | OK2[] |

Returns: default<I2, DK2, Exclude<OK2, DK2>, true>

Defined in: index.ts:167

About

Extended native JavaScript Array which provides indexed lookup similar to native Map.

Resources

License

Stars

Watchers

Forks

Packages

No packages published