diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-04-03 16:35:07 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-04-03 16:35:07 -0300 |
commit | 822216b3df6525484df1b5ac436928023cc5789a (patch) | |
tree | 9c36cb347081ac932acd481916a9e5d597206aea | |
parent | 2d3a59502de2e6b7c19c3159be065f540b5cceeb (diff) |
data: flash: improve missing-docoument-type reporting
-rw-r--r-- | src/data/things/flash.js | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/data/things/flash.js b/src/data/things/flash.js index dc6a32df..d0aef04a 100644 --- a/src/data/things/flash.js +++ b/src/data/things/flash.js @@ -2,6 +2,7 @@ export const FLASH_DATA_FILE = 'flashes.yaml'; import {input} from '#composite'; import find from '#find'; +import {empty} from '#sugar'; import {sortFlashesChronologically} from '#sort'; import Thing from '#thing'; import {anyOf, isColor, isContentString, isDirectory, isNumber, isString} @@ -308,15 +309,22 @@ export class FlashSide extends Thing { : Flash), save(results) { - let thing; - for (let index = 0; thing = results[index]; index++) { - if (index === 0 && !(thing instanceof FlashSide)) { - throw new Error(`Expected a side at top of flash data file`); - } + // JavaScript likes you. + + if (!empty(results) && !(results[0] instanceof FlashSide)) { + throw new Error(`Expected a side at top of flash data file`); + } - // JavaScript likes you. + let index = 0; + let thing; + for (; thing = results[index]; index++) { const flashSide = thing; const flashActRefs = []; + + if (results[index + 1] instanceof Flash) { + throw new Error(`Expected an act to immediately follow a side`); + } + for ( index++; (thing = results[index]) && thing instanceof FlashAct; |