Skip to content
Permalink
34b43ed881
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
28 lines (20 sloc) 525 Bytes
'use strict'
let data = []
module.exports.clear = () => {
data = []
}
module.exports.add = (item, qty) => {
if(typeof qty !== 'number') throw new Error('qty must be a number')
data.push({item: item, qty: qty})
}
module.exports.getAll = () => {
if(data.length === 0) throw new Error('empty list')
for(const key in data) data[key].key = key
return data
}
module.exports.delete = key => {
console.log(`delete key ${key}`)
return
}
module.exports.countItems = () => data.length
module.exports.count = data.length