« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/yaml.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/yaml.js')
-rw-r--r--src/data/yaml.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 6618fd4c..d7acdbc0 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -214,6 +214,7 @@ function makeProcessDocument(thingConstructor, {
 
       subdoc(documentType, data, {
         bindInto = null,
+        provide = null,
       } = {}) {
         if (!documentType)
           throw new Error(`Expected document type, got ${typeAppearance(documentType)}`);
@@ -223,12 +224,15 @@ function makeProcessDocument(thingConstructor, {
           throw new Error(`Expected data to be an object, got ${typeAppearance(data)}`);
         if (typeof bindInto !== 'string' && bindInto !== null)
           throw new Error(`Expected bindInto to be a string, got ${typeAppearance(bindInto)}`);
+        if (typeof provide !== 'object' && provide !== null)
+          throw new Error(`Expected provide to be an object, got ${typeAppearance(provide)}`);
 
         return {
           [subdocSymbol]: {
             documentType,
             data,
             bindInto,
+            provide,
           },
         };
       },
@@ -295,6 +299,10 @@ function makeProcessDocument(thingConstructor, {
         subthing[setup.bindInto] = thing;
       }
 
+      if (setup.provide) {
+        Object.assign(subthing, setup.provide);
+      }
+
       if (subthing) {
         fieldValues[field] = subthing;
       }