git ssb

1+

Matt McKegg / mutant



Tree: e9d4ab45391a98cd08092fe447f7cd7c3732779b

Files: e9d4ab45391a98cd08092fe447f7cd7c3732779b / concat.js

853 bytesRaw
1var resolve = require('./resolve')
2var addCollectionMethods = require('./lib/add-collection-methods')
3var computed = require('./computed')
4var forEach = require('./for-each')
5
6module.exports = function Concat (observables) {
7 var values = []
8 var rawValues = []
9
10 var instance = computed.extended(observables, function () {
11 var index = 0
12
13 forEach(observables, function (collection) {
14 forEach(collection, function (item) {
15 var value = resolve(item)
16 values[index] = value
17 rawValues[index] = item
18 index += 1
19 })
20 })
21
22 values.length = index
23 rawValues.length = index
24 return values
25 })
26
27 var result = function MutantConcat (listener) {
28 return instance(listener)
29 }
30
31 // getLength, get, indexOf, etc
32 addCollectionMethods(result, rawValues, instance.checkUpdated)
33
34 return result
35}
36

Built with git-ssb-web