Skip to content

Commit

Permalink
refactor: remove support for old index providers
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnowack committed Dec 12, 2024
1 parent 04b0c45 commit bd83e7d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 26 deletions.
1 change: 1 addition & 0 deletions packages/base/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* BREAKING: `SyncManager` was moved to `@signaldb/sync`
* BREAKING: `ReplicatedCollection` was removed entirely
* BREAKING: `options` parameter was removed from `combinePersistenceAdapters`
* BREAKING: support for old `IndexProviders` was removed
13 changes: 0 additions & 13 deletions packages/base/core/src/Collection/getIndexInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ export function getMergedIndexInfo<T extends BaseItem<I> = BaseItem, I = any>(
positions: number[],
optimizedSelector: FlatSelector<T>,
}>((memo, indexProvider) => {
/* istanbul ignore if -- @preserve */ // ignored because it's deprecated
if (indexProvider.getItemPositions) {
const result = indexProvider.getItemPositions(selector)
if (result == null) return memo
return {
matched: true,
positions: memo.matched
? intersection(memo.positions, result)
: result,
optimizedSelector: memo.optimizedSelector,
}
}

const info = indexProvider.query(selector)
if (!info.matched) return memo

Expand Down
14 changes: 1 addition & 13 deletions packages/base/core/src/types/IndexProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,11 @@ type IndexResult = {
matched: false,
}

interface OldIndexProvider<T extends BaseItem<I> = BaseItem, I = any> {
/**
* @deprecated Use `query` instead
*/
getItemPositions(selector: FlatSelector<T>): null | number[],
rebuild(items: T[]): void,
}

interface NewIndexProvider<T extends BaseItem<I> = BaseItem, I = any> {
getItemPositions?: never,
interface IndexProvider<T extends BaseItem<I> = BaseItem, I = any> {
query(selector: FlatSelector<T>): IndexResult,
rebuild(items: T[]): void,
}

type IndexProvider<T extends BaseItem<I> = BaseItem, I = any> = OldIndexProvider<T, I>
| NewIndexProvider<T, I>

export type LowLevelIndexProvider<
T extends BaseItem<I> = BaseItem,
I = any,
Expand Down

0 comments on commit bd83e7d

Please sign in to comment.