Files: 91e3d5d798ebcef85048597e9a56b9f579613469 / concat.js
853 bytesRaw
1 | var resolve = require('./resolve') |
2 | var addCollectionMethods = require('./lib/add-collection-methods') |
3 | var computed = require('./computed') |
4 | var forEach = require('./for-each') |
5 | |
6 | module.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