From 3ff0d2646dfa82aed7c75be1bce6899bc96bded7 Mon Sep 17 00:00:00 2001 From: Alejandro Santiago Date: Tue, 3 Oct 2023 14:25:42 +0100 Subject: [PATCH] refactor: add typedef --- lib/src/pub_license/pub_license.dart | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/src/pub_license/pub_license.dart b/lib/src/pub_license/pub_license.dart index fd44ac22..7a0cf3bd 100644 --- a/lib/src/pub_license/pub_license.dart +++ b/lib/src/pub_license/pub_license.dart @@ -28,6 +28,15 @@ class PubLicenseException implements Exception { final String message; } +/// The function signature for parsing HTML documents. +@visibleForTesting +typedef HtmlDocumentParse = html_dom.Document Function( + dynamic input, { + String? encoding, + bool generateSpans, + String? sourceUrl, +}); + /// {@template pub_license} /// Enables checking pub.dev's hosted packages license. /// {@endtemplate} @@ -35,13 +44,7 @@ class PubLicense { /// {@macro pub_license} PubLicense({ @visibleForTesting http.Client? client, - @visibleForTesting - html_dom.Document Function( - dynamic input, { - String? encoding, - bool generateSpans, - String? sourceUrl, - })? parse, + @visibleForTesting HtmlDocumentParse? parse, }) : _client = client ?? http.Client(), _parse = parse ?? html_parser.parse;