From 42495455b5cab196c3bc929757ff35ab3ffb5e35 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Mon, 6 Jun 2022 19:49:28 +0800 Subject: [PATCH] Remove obsolete functions --- app/lib/iterable_extension.dart | 51 +-------------------------------- app/lib/k.dart | 3 -- 2 files changed, 1 insertion(+), 53 deletions(-) diff --git a/app/lib/iterable_extension.dart b/app/lib/iterable_extension.dart index 0ea473d7..24e039b9 100644 --- a/app/lib/iterable_extension.dart +++ b/app/lib/iterable_extension.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; +import 'package:nc_photos/list_extension.dart'; import 'package:nc_photos/override_comparator.dart'; import 'package:tuple/tuple.dart'; @@ -23,56 +24,6 @@ extension IterableExtension on Iterable { } } - /// The current elements of this iterable modified by async function [fn]. - /// - /// The result of [fn] will be emitted by the returned stream in the same - /// order as this iterable. - /// - /// If [simultaneousFuture] > 1, [fn] will be called multiple times before - /// awaiting their results. - Stream mapStream( - Future Function(T element) fn, [ - simultaneousFuture = 1, - ]) async* { - final container = >[]; - for (final e in this) { - container.add(fn(e)); - if (container.length >= simultaneousFuture) { - for (final result in await Future.wait(container)) { - yield result; - } - container.clear(); - } - } - if (container.isNotEmpty) { - for (final result in await Future.wait(container)) { - yield result; - } - } - } - - /// Invokes async function [fn] on each element of this iterable in iteration - /// order. - /// - /// If [simultaneousFuture] > 1, [fn] will be called multiple times before - /// awaiting their results. - Future forEachAsync( - Future Function(T element) fn, [ - simultaneousFuture = 1, - ]) async { - final container = []; - for (final e in this) { - container.add(fn(e)); - if (container.length >= simultaneousFuture) { - await Future.wait(container); - container.clear(); - } - } - if (container.isNotEmpty) { - await Future.wait(container); - } - } - Iterable> withIndex() => mapWithIndex((i, e) => Tuple2(i, e)); /// Whether the collection contains an element equal to [element] using the diff --git a/app/lib/k.dart b/app/lib/k.dart index 1768a90f..372eb354 100644 --- a/app/lib/k.dart +++ b/app/lib/k.dart @@ -36,6 +36,3 @@ const coverSize = 512; /// AppDb lock ID const appDbLockId = 1; - -/// Number of async query task that can be called simultaneously -const simultaneousQuery = 20;