This is an automated email from the ASF dual-hosted git repository. gerben pushed a commit to branch import-dom-seek in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git
commit 9dc1e5e44b270efcbf40c5cd9e6f41fe21c54c56 Author: Gerben <[email protected]> AuthorDate: Thu Nov 19 17:48:40 2020 +0100 fix type of matchers --- packages/dom/src/text-position/match.ts | 12 +++--------- packages/dom/src/text-quote/match.ts | 11 +++-------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/packages/dom/src/text-position/match.ts b/packages/dom/src/text-position/match.ts index aa5fe49..53bfae3 100644 --- a/packages/dom/src/text-position/match.ts +++ b/packages/dom/src/text-position/match.ts @@ -26,9 +26,7 @@ import { Chunk, ChunkRange, TextNodeChunker, PartialTextNode } from '../chunker' export function createTextPositionSelectorMatcher( selector: TextPositionSelector, ): Matcher<Range, Range> { - - const abstractMatcher: AbstractMatcher<PartialTextNode> = - abstractTextPositionSelectorMatcher(selector); + const abstractMatcher = abstractTextPositionSelectorMatcher(selector); return async function* matchAll(scope) { const textChunks = new TextNodeChunker(scope); @@ -43,13 +41,9 @@ export function createTextPositionSelectorMatcher( }; } -type AbstractMatcher<TChunk extends Chunk<any>> = - Matcher<NonEmptyChunker<TChunk>, ChunkRange<TChunk>> - -export function abstractTextPositionSelectorMatcher<TChunk extends Chunk<string>>( +export function abstractTextPositionSelectorMatcher( selector: TextPositionSelector, -): AbstractMatcher<TChunk> { - +): <TChunk extends Chunk<any>>(scope: NonEmptyChunker<TChunk>) => AsyncGenerator<ChunkRange<TChunk>, void, void> { const { start, end } = selector; return async function* matchAll<TChunk extends Chunk<string>>(textChunks: NonEmptyChunker<TChunk>) { diff --git a/packages/dom/src/text-quote/match.ts b/packages/dom/src/text-quote/match.ts index 37a75ba..38e09d5 100644 --- a/packages/dom/src/text-quote/match.ts +++ b/packages/dom/src/text-quote/match.ts @@ -24,9 +24,7 @@ import { TextNodeChunker, Chunk, Chunker, ChunkRange, PartialTextNode } from '.. export function createTextQuoteSelectorMatcher( selector: TextQuoteSelector, ): Matcher<Range, Range> { - - const abstractMatcher: AbstractMatcher<PartialTextNode> = - abstractTextQuoteSelectorMatcher(selector); + const abstractMatcher = abstractTextQuoteSelectorMatcher(selector); return async function* matchAll(scope) { const textChunks = new TextNodeChunker(scope); @@ -37,12 +35,9 @@ export function createTextQuoteSelectorMatcher( } } -type AbstractMatcher<TChunk extends Chunk<any>> = - Matcher<Chunker<TChunk>, ChunkRange<TChunk>> - -export function abstractTextQuoteSelectorMatcher<TChunk extends Chunk<string>>( +export function abstractTextQuoteSelectorMatcher( selector: TextQuoteSelector, -): AbstractMatcher<TChunk> { +): <TChunk extends Chunk<any>>(scope: Chunker<TChunk>) => AsyncGenerator<ChunkRange<TChunk>, void, void> { return async function* matchAll<TChunk extends Chunk<string>>(textChunks: Chunker<TChunk>) { const exact = selector.exact; const prefix = selector.prefix || '';
