class FoodObj { constructor(limit) { this.limit = limit; this.store = []; this.soup = {}; this.types = [0, 0, 0, 0, 0, 0, 0]; } get () { return this.store; } getFirstFive() { return (this.store.slice(0, 5)); } getFirstFiveIDs() { const outVal = this.store.slice(0, 5).map((item) => { return item._id; }); return (outVal); } add(item) { // console.log('>>', item); item.url = `https://menu.silvrtree.co.uk/view/${item.short}`; if (this.types[item.meat] < this.limit) { this.store.push(item); this.types[item.meat]++; } } addSoup(item) { item.url = `https://menu.silvrtree.co.uk/view/${item.short}`; this.soup = item; } soupID() { return this.soup._id || null; } count() { return (this.store.slice(0, 5).length); } forPug() { const output = { 'menu':null, 'soup':null }; output.menu = [...this.getFirstFive()]; output.soup = this.soup; return output; } } module.exports = FoodObj;