From 2a43121efe5e45c977fe8449f080261e534d658d Mon Sep 17 00:00:00 2001 From: "Afshin T. Darian" Date: Thu, 11 Aug 2022 15:53:04 +0100 Subject: [PATCH] Reimplement empty() with native iterators --- packages/algorithm/src/empty.ts | 42 ++++----------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/packages/algorithm/src/empty.ts b/packages/algorithm/src/empty.ts index efa830f81..a7c580382 100644 --- a/packages/algorithm/src/empty.ts +++ b/packages/algorithm/src/empty.ts @@ -7,7 +7,6 @@ | | The full license is in the file LICENSE, distributed with this software. |----------------------------------------------------------------------------*/ -import { IIterator } from './iter'; /** * Create an empty iterator. @@ -16,45 +15,14 @@ import { IIterator } from './iter'; * * #### Example * ```typescript - * import { empty, toArray } from '@lumino/algorithm'; + * import { empty } from '@lumino/algorithm'; * * let stream = empty(); * - * toArray(stream); // [] + * Array.from(stream); // [] * ``` */ -export function empty(): IIterator { - return new EmptyIterator(); -} - -/** - * An iterator which is always empty. - */ -export class EmptyIterator implements IIterator { - /** - * Get an iterator over the object's values. - * - * @returns An iterator which yields the object's values. - */ - iter(): IIterator { - return this; - } - - /** - * Create an independent clone of the iterator. - * - * @returns A new independent clone of the iterator. - */ - clone(): IIterator { - return new EmptyIterator(); - } - - /** - * Get the next value from the iterator. - * - * @returns The next value from the iterator, or `undefined`. - */ - next(): T | undefined { - return undefined; - } +// eslint-disable-next-line require-yield, @typescript-eslint/no-unused-vars +export function* empty() { + return; }