You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@annotator.apache.org by ge...@apache.org on 2020/09/16 18:04:06 UTC

[incubator-annotator] branch chunking updated: Tweak types

This is an automated email from the ASF dual-hosted git repository.

gerben pushed a commit to branch chunking
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git


The following commit(s) were added to refs/heads/chunking by this push:
     new 251ea24  Tweak types
251ea24 is described below

commit 251ea24523ebeafc2798da91bcc6bf10028021ba
Author: Gerben <ge...@treora.com>
AuthorDate: Wed Sep 16 20:03:39 2020 +0200

    Tweak types
---
 packages/dom/src/text-iterator.ts    | 2 +-
 packages/dom/src/text-quote/match.ts | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/packages/dom/src/text-iterator.ts b/packages/dom/src/text-iterator.ts
index 17fdf1c..4236625 100644
--- a/packages/dom/src/text-iterator.ts
+++ b/packages/dom/src/text-iterator.ts
@@ -45,7 +45,7 @@ export interface Chunk {
   toString(): string;
 }
 
-export interface ChunkRange<TChunk> {
+export interface ChunkRange<TChunk extends Chunk> {
   startChunk: TChunk;
   startIndex: number;
   endChunk: TChunk;
diff --git a/packages/dom/src/text-quote/match.ts b/packages/dom/src/text-quote/match.ts
index 3ec4b68..5fcd80c 100644
--- a/packages/dom/src/text-quote/match.ts
+++ b/packages/dom/src/text-quote/match.ts
@@ -24,7 +24,7 @@ import { rangeToTextChunks, Chunk, TextRange, ChunkRange } from '../text-iterato
 
 export function createTextQuoteSelectorMatcher(
   selector: TextQuoteSelector,
-): (scope: Range) => AsyncGenerator<TextRange, void, void> {
+): (scope: Range) => AsyncIterable<TextRange> {
   const abstractMatcher = abstractTextQuoteSelectorMatcher(selector);
   return async function* matchAll(scope) {
     // Turn the scope into a stream of ranges, each wrapping exactly one text node. We wrap it in
@@ -46,7 +46,7 @@ export function createTextQuoteSelectorMatcher(
 
 export function abstractTextQuoteSelectorMatcher(
   selector: TextQuoteSelector,
-): <TChunk extends Chunk>(textChunks: AsyncIterable<TChunk>) => AsyncGenerator<ChunkRange<TChunk>, void, void> {
+): <TChunk extends Chunk>(textChunks: AsyncIterable<TChunk>) => AsyncIterable<ChunkRange<TChunk>> {
   return async function* matchAll<TChunk extends Chunk>(textChunks: AsyncIterable<TChunk>) {
     const exact = selector.exact;
     const prefix = selector.prefix || '';