summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/entities.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/common/entities.js b/common/entities.js
index b70661f..3ccbf04 100644
--- a/common/entities.js
+++ b/common/entities.js
@@ -101,6 +101,17 @@ function get_newest_version(versioned_item)
#EXPORT get_newest_version AS get_newest
/*
+ * Returns true if the argument is a nonempty array of numbers without trailing
+ * zeros.
+ */
+function is_valid_version(version) {
+ return Array.isArray(version) && version.length > 0 &&
+ version.every(n => typeof n === "number") &&
+ version[version.length - 1] !== 0;
+}
+#EXPORT is_valid_version
+
+/*
* item is a definition of a resource or mapping. Yield all file references
* (objects with `file` and `sha256` properties) this definition has.
*/