Pakete, Repositories und App-Kategorien suchen

GitHub-Repositorydart-archive/clock

Uhr

Ein nachstellbarer Wrapper für die Dart:Core-Uhr-APIs.

Projektcover von Uhr
Sterne
41
Forks
16
Letzter Push (UTC)
28.10.2024
Projektstatus
Archiviert

Original-README

Englischer Projektschnappschuss. Aktuelle Inhalte auf GitHub.

[!IMPORTANT]
This repo has moved to https://github.com/dart-lang/tools/tree/main/pkgs/clock

Dart CI pub package package publisher

This package provides a Clock class which encapsulates the notion of the "current time" and provides easy access to points relative to the current time. Different Clocks can have a different notion of the current time, and the default top-level clock's notion can be swapped out to reliably test timing-dependent code.

For example, you can use clock in your libraries like this:

// run_with_timing.dart
import 'package:clock/clock.dart';

/// Runs [callback] and prints how long it took.
T runWithTiming<T>(T Function() callback) {
  var stopwatch = clock.stopwatch()..start();
  var result = callback();
  print('It took ${stopwatch.elapsed}!');
  return result;
}

...and then test your code using the fake_async package, which automatically overrides the current clock:

// run_with_timing_test.dart
import 'run_with_timing.dart';

import 'package:fake_async/fake_async.dart';
import 'package:test/test.dart';

void main() {
  test('runWithTiming() prints the elapsed time', () {
    FakeAsync().run((async) {
      expect(() {
        runWithTiming(() {
          async.elapse(Duration(seconds: 10));
        });
      }, prints('It took 0:00:10.000000!'));
    });
  });
}
Dart Archive GitHub avatar
GitHub-Autor

Dart Archive ↗

Legacy projects kept around for posterity – See github.com/dart-lang for current work

SprachenDart

Verwendete Abhängigkeiten

Abhängigkeiten 2 Einträge

  • dart_flutter_team_lintsEntwicklung^3.0.0
  • testEntwicklung^1.16.6

Wie wähle ich ein passendes Repository?

Nach Anwendungsfall filtern, Aktivität vergleichen und vor der Nutzung das Originalprojekt prüfen.

  1. Nach Name, Autor oder Beschreibung suchen und nach Thema eingrenzen.
  2. Sterne, Forks und letzte Pushes vergleichen. Sterne zeigen Interesse, garantieren aber keine Qualität.
  3. Vor der Nutzung README, Lizenz und Issues auf GitHub prüfen.

Quellen und Pflege

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗