substance
Version:
Substance is a JavaScript library for web-based content editing. It provides building blocks for realizing custom text editors and web-based publishing systems.
21 lines (19 loc) • 378 B
JavaScript
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)
}
}
get(path) {
return this[path] || []
}
}
export default ArrayTree