mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-02 06:46:22 +01:00
Remove obsolete functions
This commit is contained in:
parent
763762d385
commit
42495455b5
2 changed files with 1 additions and 53 deletions
|
@ -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<T> on Iterable<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// 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<U> mapStream<U>(
|
||||
Future<U> Function(T element) fn, [
|
||||
simultaneousFuture = 1,
|
||||
]) async* {
|
||||
final container = <Future<U>>[];
|
||||
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<void> forEachAsync(
|
||||
Future Function(T element) fn, [
|
||||
simultaneousFuture = 1,
|
||||
]) async {
|
||||
final container = <Future>[];
|
||||
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<Tuple2<int, T>> withIndex() => mapWithIndex((i, e) => Tuple2(i, e));
|
||||
|
||||
/// Whether the collection contains an element equal to [element] using the
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue