UNPKG

@sugarcoated/fondant-targets

Version:
24 lines (19 loc) 702 B
const Collection = require('@sugarcoated/fondant-collection'); const Target = require('@sugarcoated/fondant-target'); class Targets extends Collection { constructor (targetsCollection) { if (targetsCollection.length > 1) { const targetsParsed = Array.from(targetsCollection); const targetsMapping = targetsParsed.map($targetParsed => { if (!($targetParsed instanceof Target)) { const $targetCreated = new Target($targetParsed); return [$targetCreated.identifier, $targetCreated]; } }); super (targetsMapping); } else { return new Target(targetsCollection[0]); } } } module.exports = Targets;