Skip to content

Commit

Permalink
♻️ rename Utils.maybeMap to apply
Browse files Browse the repository at this point in the history
  • Loading branch information
techouse committed Apr 2, 2024
1 parent 937fafd commit cb81ead
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/src/extensions/decode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension _$Decode on QS {
val = options.strictNullHandling ? null : '';
} else {
key = options.decoder(part.substring(0, pos), charset: charset);
val = Utils.maybeMap<dynamic>(
val = Utils.apply<dynamic>(
_parseArrayValue(part.substring(pos + 1), options),
(dynamic val) => options.decoder(val, charset: charset),
);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/extensions/encode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extension _$Encode on QS {
obj = serializeDate?.call(obj) ?? obj.toIso8601String();
} else if (generateArrayPrefix == ListFormat.comma.generator &&
obj is Iterable) {
obj = Utils.maybeMap(
obj = Utils.apply(
obj,
(value) => value is DateTime
? (serializeDate?.call(value) ?? value.toIso8601String())
Expand Down Expand Up @@ -93,7 +93,7 @@ extension _$Encode on QS {
if (generateArrayPrefix == ListFormat.comma.generator && obj is Iterable) {
// we need to join elements in
if (encodeValuesOnly && encoder != null) {
obj = Utils.maybeMap<String>(obj, encoder);
obj = Utils.apply<String>(obj, encoder);
}

if ((obj as Iterable).isNotEmpty) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ final class Utils {
if (b is Iterable<T>) ...b else b,
];

static dynamic maybeMap<T>(dynamic val, T Function(T) fn) =>
static dynamic apply<T>(dynamic val, T Function(T) fn) =>
val is Iterable ? val.map((item) => fn(item)) : fn(val);

static bool isNonNullishPrimitive(dynamic val, [bool skipNulls = false]) =>
Expand Down

0 comments on commit cb81ead

Please sign in to comment.