all files / util/ ArrayTree.js

0% Statements 0/5
0% Branches 0/4
0% Functions 0/2
0% Lines 0/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18                                   
import deleteFromArray from './deleteFromArray'
 
// simplified version of TreeIndex for arrays
class ArrayTree {
  add(path, val) {
    if (!this[path]) {
      this[path] = []
    }
    this[path].push(val)
  }
  remove(path, val) {
    if (this[path]) {
      deleteFromArray(this[path], val)
    }
  }
}
 
export default ArrayTree