git ssb

1+

Matt McKegg / mutant



Tree: ef9e5ab9d31b22070e49efa9d5db1f9b8f20b572

Files: ef9e5ab9d31b22070e49efa9d5db1f9b8f20b572 / 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