40 lines
994 B
JavaScript
40 lines
994 B
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.fromArray = fromArray;
|
|
|
|
var _Stream = require('../Stream');
|
|
|
|
var _Stream2 = _interopRequireDefault(_Stream);
|
|
|
|
var _PropagateTask = require('../scheduler/PropagateTask');
|
|
|
|
var _PropagateTask2 = _interopRequireDefault(_PropagateTask);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/** @license MIT License (c) copyright 2010-2016 original author or authors */
|
|
/** @author Brian Cavalier */
|
|
/** @author John Hann */
|
|
|
|
function fromArray(a) {
|
|
return new _Stream2.default(new ArraySource(a));
|
|
}
|
|
|
|
function ArraySource(a) {
|
|
this.array = a;
|
|
}
|
|
|
|
ArraySource.prototype.run = function (sink, scheduler) {
|
|
return scheduler.asap(new _PropagateTask2.default(runProducer, this.array, sink));
|
|
};
|
|
|
|
function runProducer(t, array, sink) {
|
|
for (var i = 0, l = array.length; i < l && this.active; ++i) {
|
|
sink.event(t, array[i]);
|
|
}
|
|
|
|
this.active && sink.end(t);
|
|
} |