Skip to content

Commit

Permalink
ArraySliceSelector extends Slice
Browse files Browse the repository at this point in the history
  • Loading branch information
Smoren committed Mar 8, 2024
1 parent 774410e commit c13d51c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ export class ArrayMaskSelector extends ArraySelector<Array<boolean>> {
}
}

export class ArraySliceSelector extends ArraySelector<Slice> {
export class ArraySliceSelector extends Slice implements SelectorInterface<Slice> {
public readonly value: Slice;

constructor(slice: Slice | string) {
super(slice instanceof Slice ? slice : Slice.toSlice(slice));
const s = Slice.toSlice(slice);
super(s.start, s.end, s.step);
this.value = this;
}

public select<T>(source: ArrayView<T>): ArraySliceView<T> {
return new ArraySliceView<T>(source, { slice: this.value });
return new ArraySliceView<T>(source, { slice: this });
}
}

0 comments on commit c13d51c

Please sign in to comment.