All files KeyMap.js

100% Statements 12/12
100% Branches 0/0
100% Functions 0/0
100% Lines 12/12

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 25 26        48x 48x   2077x 2077x     6199x 6199x 6199x 6199x     4x 4x 4x 4x          
import toString from 'lodash/toString'
 
export default {
  create () {
    let map = {}
    return {
      get (collectionName, key) {
        key = `${collectionName}-${toString(key)}`
        return map[key]
      },
      link (collectionName, a, b) {
        a = toString(a)
        b = toString(b)
        map[`${collectionName}-${a}`] = b
        map[`${collectionName}-${b}`] = a
      },
      unlink (collectionName, a, b) {
        a = `${collectionName}-${toString(a)}`
        b = `${collectionName}-${toString(b)}`
        delete map[a]
        delete map[b]
      }
    }
  }
}