diff options
author | (quasar) nebula <towerofnix@gmail.com> | 2021-06-07 14:50:01 -0300 |
---|---|---|
committer | (quasar) nebula <towerofnix@gmail.com> | 2021-06-07 14:50:01 -0300 |
commit | 04682cbea790fde874a8488777738d28758012a9 (patch) | |
tree | 8791f4eff39905d577749c5f70d4587b2607f000 /src/thing/album.js | |
parent | b2469c03bd4bdb29c5e80752f812203a6755c159 (diff) |
experimental AggregateError & Thing class hijinks
Diffstat (limited to 'src/thing/album.js')
-rw-r--r-- | src/thing/album.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/thing/album.js b/src/thing/album.js new file mode 100644 index 00000000..1915ab85 --- /dev/null +++ b/src/thing/album.js @@ -0,0 +1,43 @@ +import Thing from './thing.js'; + +import { + validateReference +} from './structures.js'; + +import { + showAggregate, + withAggregate +} from '../util/sugar.js'; + +export default class Album extends Thing { + #tracks; + + static updateError = { + tracks: Thing.extendPropertyError('tracks') + }; + + update(source) { + withAggregate(({ wrap, call, map }) => { + if (source.tracks) { + this.#tracks = map(source.tracks, validateReference('track'), { + errorClass: this.constructor.updateError.tracks + }); + } + }); + } +} + +const album = new Album(); + +try { + album.update({ + tracks: [ + 'lol', + 123, + 'track:oh-yeah', + 'group:what-am-i-doing-here' + ] + }); +} catch (error) { + showAggregate(error); +} |