git ssb

1+

Matt McKegg / mutant



Tree: 91e3d5d798ebcef85048597e9a56b9f579613469

Files: 91e3d5d798ebcef85048597e9a56b9f579613469 / 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