git ssb

1+

Matt McKegg / mutant



Tree: 6cbb0cdc8dd11c5f29e9c875e9f602f1d9a21f2a

Files: 6cbb0cdc8dd11c5f29e9c875e9f602f1d9a21f2a / 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