Import
import { ArrayIndexAccessor } from '@rs-x/core';API Reference
Array accessor implementation used by the index-value-accessor pipeline. It handles Array contexts, reads and writes values by numeric index (array[index]), reports whether an index has a value, and lists available indexes with array.keys().
import { ArrayIndexAccessor } from '@rs-x/core';import {
InjectionContainer,
RsXCoreInjectionTokens,
RsXCoreModule,
type IArrayIndexAccessor,
} from '@rs-x/core';
await InjectionContainer.load(RsXCoreModule);
const arrayAccessor = InjectionContainer.get<IArrayIndexAccessor>(
RsXCoreInjectionTokens.IArrayIndexAccessor,
);
const values = ['a', 'b', 'c'];
const hasSecond = arrayAccessor.hasValue(values, 1);
const second = arrayAccessor.getValue(values, 1);
arrayAccessor.setValue(values, 1, 'beta');
const indexes = [...arrayAccessor.getIndexes(values)];
console.log(hasSecond); // true
console.log(second); // bimport { Inject, RsXCoreInjectionTokens, type IArrayIndexAccessor } from '@rs-x/core';
class MyConsumer {
constructor(
@Inject(RsXCoreInjectionTokens.IArrayIndexAccessor)
private readonly dependency: IArrayIndexAccessor,
) {}
}6 members in this class.
public applies(array: unknown): booleanParameters
Returns
boolean
public getIndexes(array: unknown[]): IterableIterator<number>Parameters
Returns
IterableIterator<number>
public getResolvedValue(
array: unknown[],
index: number
): unknownParameters
Returns
unknown
public getValue(
array: unknown[],
index: number
): unknownParameters
Returns
unknown
public hasValue(
array: unknown[],
index: number
): booleanParameters
Returns
boolean
public setValue(
array: unknown[],
index: number,
value: unknown
): voidParameters
Returns
void