git ssb

1+

Matt McKegg / mutant



Tree: 9a45ee19f015307308d964ffa52965fe95ed8ad0

Files: 9a45ee19f015307308d964ffa52965fe95ed8ad0 / lib / add-collection-methods.js

719 bytesRaw
1module.exports = function (target, list, checkUpdated) {
2 target.get = function (index) {
3 checkUpdated && checkUpdated()
4 return list[index]
5 }
6
7 target.getLength = function (index) {
8 checkUpdated && checkUpdated()
9 return list.length
10 }
11
12 target.includes = function (valueOrObs) {
13 checkUpdated && checkUpdated()
14 return !!~list.indexOf(valueOrObs)
15 }
16
17 target.indexOf = function (valueOrObs) {
18 checkUpdated && checkUpdated()
19 return list.indexOf(valueOrObs)
20 }
21
22 target.forEach = function (fn, context) {
23 checkUpdated && checkUpdated()
24 list.slice().forEach(fn, context)
25 }
26
27 target.find = function (fn) {
28 checkUpdated && checkUpdated()
29 return list.find(fn)
30 }
31}
32

Built with git-ssb-web