« 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
diff options
context:
space:
mode:
Diffstat (limited to 'src/data')
-rw-r--r--src/data/composite/data/withSortedList.js2
-rw-r--r--src/data/yaml.js11
2 files changed, 4 insertions, 9 deletions
diff --git a/src/data/composite/data/withSortedList.js b/src/data/composite/data/withSortedList.js
index 882907f5..4ab0dfb1 100644
--- a/src/data/composite/data/withSortedList.js
+++ b/src/data/composite/data/withSortedList.js
@@ -102,7 +102,7 @@ export default templateCompositeFrom({
               if (empty(accumulator)) {
                 accumulator.push(0);
               } else {
-                const last = accumulator[accumulator.length - 1];
+                const last = accumulator.at(-1);
                 if (collapseEqual) {
                   accumulator.push(last);
                 } else {
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 2137f994..5a4e87e3 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -17,6 +17,7 @@ import T, {Thing} from '#things';
 
 import {
   annotateErrorWithFile,
+  atOffset,
   conditionallySuppressError,
   decorateErrorWithIndex,
   decorateErrorWithAnnotation,
@@ -1237,14 +1238,8 @@ export async function loadAndProcessDataDocuments({dataPath}) {
                   start,
                   end,
                   count: end - start + 1,
-                  previous:
-                    (start > 0
-                      ? documents[start - 1]
-                      : null),
-                  next:
-                    (end < documents.length - 1
-                      ? documents[end + 1]
-                      : null),
+                  previous: atOffset(documents, start, -1),
+                  next: atOffset(documents, end, +1),
                 }));
 
             for (const {start, end, count, previous, next} of blankIndexRangeInfo) {