All files / src/operations set_item.js

100% Statements 13/13
100% Branches 0/0
100% Functions 4/4
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24    1x 1x 1x   1x     1x 1x 1x 3x 3x 3x 3x 3x       1x      
export default {
  single: ({ key, value, store, log }) => {
    log(`Set Single`)
    log(`"${key}":${JSON.stringify(value)}`)
    store.set(key, value)
 
    return { key, value }
  },
  multi: ({ namespace, values, store, log }) => {
    log(`Set Multi`)
    const promises = []
    values.forEach(({ key, value }) => {
      promises.push(new Promise((resolve, reject) => {
        const _key = `${namespace}${key}`
        log(`"${_key}": ${JSON.stringify(value)}`)
        store.set(_key, value)
        resolve({ key, value })
      }))
    })
 
    return Promise.all(promises)
  }
}