From 5217d4586a597f8311aea24d78f422bc2b55d92e Mon Sep 17 00:00:00 2001 From: Nathan Fischer Date: Tue, 17 Sep 2024 11:42:18 -0700 Subject: [PATCH] Add isEmpty for containers --- ninny/src/nrktkt/ninny/ast/package.scala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ninny/src/nrktkt/ninny/ast/package.scala b/ninny/src/nrktkt/ninny/ast/package.scala index 073518d..3fb50af 100644 --- a/ninny/src/nrktkt/ninny/ast/package.scala +++ b/ninny/src/nrktkt/ninny/ast/package.scala @@ -38,6 +38,8 @@ package object ast { extends AnyVal with JsonValue { + def isEmpty = values.isEmpty + def mapNames(f: String => String) = JsonObject(values.map { case (k, v) => f(k) -> v }) @@ -96,6 +98,8 @@ package object ast { case class JsonArray(values: Seq[JsonValue]) extends AnyVal with JsonValue { + def isEmpty = values.isEmpty + def :+[A: ToJson](value: A) = value.toJson match { case Some(v) => this.copy(values = values :+ v)