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