diff options
Diffstat (limited to 'src/thing/album.js')
-rw-r--r-- | src/thing/album.js | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/src/thing/album.js b/src/thing/album.js deleted file mode 100644 index e99cfc3..0000000 --- a/src/thing/album.js +++ /dev/null @@ -1,62 +0,0 @@ -import Thing from './thing.js'; - -import { - validateDirectory, - validateReference -} from './structures.js'; - -import { - showAggregate, - withAggregate -} from '../util/sugar.js'; - -export default class Album extends Thing { - #directory = null; - #tracks = []; - - static updateError = { - directory: Thing.extendPropertyError('directory'), - tracks: Thing.extendPropertyError('tracks') - }; - - update(source) { - const err = this.constructor.updateError; - - withAggregate(({ nest, filter, throws }) => { - - if (source.directory) { - nest(throws(err.directory), ({ call }) => { - if (call(validateDirectory, source.directory)) { - this.#directory = source.directory; - } - }); - } - - if (source.tracks) - this.#tracks = filter(source.tracks, validateReference('track'), throws(err.tracks)); - }); - } - - get directory() { return this.#directory; } - get tracks() { return this.#tracks; } -} - -const album = new Album(); - -console.log('tracks (before):', album.tracks); - -try { - album.update({ - directory: 'oh yes', - tracks: [ - 'lol', - 123, - 'track:oh-yeah', - 'group:what-am-i-doing-here' - ] - }); -} catch (error) { - showAggregate(error); -} - -console.log('tracks (after):', album.tracks); |