mutant
Version:
Create observables and map them to DOM elements. Massively inspired by hyperscript and observ-*. No virtual dom, just direct observable bindings. Unnecessary garbage collection is avoided by using mutable objects instead of blasting immutable junk all ove
32 lines (26 loc) • 719 B
JavaScript
module.exports = function (target, list, checkUpdated) {
target.get = function (index) {
checkUpdated && checkUpdated()
return list[index]
}
target.getLength = function (index) {
checkUpdated && checkUpdated()
return list.length
}
target.includes = function (valueOrObs) {
checkUpdated && checkUpdated()
return !!~list.indexOf(valueOrObs)
}
target.indexOf = function (valueOrObs) {
checkUpdated && checkUpdated()
return list.indexOf(valueOrObs)
}
target.forEach = function (fn, context) {
checkUpdated && checkUpdated()
list.slice().forEach(fn, context)
}
target.find = function (fn) {
checkUpdated && checkUpdated()
return list.find(fn)
}
}