git ssb

1+

Matt McKegg / mutant



Tree: 0f95e238e7d990af64891bac02844a39e4c0cac1

Files: 0f95e238e7d990af64891bac02844a39e4c0cac1 / 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