wed
Version:
Wed is a schema-aware editor for XML documents.
55 lines (52 loc) • 1.83 kB
JavaScript
define(function(require,exports,module){
;
Object.defineProperty(exports, "__esModule", { value: true });
var fromArray_1 = require("../observable/fromArray");
var scalar_1 = require("../observable/scalar");
var empty_1 = require("../observable/empty");
var concat_1 = require("../observable/concat");
var isScheduler_1 = require("../util/isScheduler");
/* tslint:enable:max-line-length */
/**
* Returns an Observable that emits the items you specify as arguments before it begins to emit
* items emitted by the source Observable.
*
* <img src="./img/startWith.png" width="100%">
*
* @param {...T} values - Items you want the modified Observable to emit first.
* @param {Scheduler} [scheduler] - A {@link IScheduler} to use for scheduling
* the emissions of the `next` notifications.
* @return {Observable} An Observable that emits the items in the specified Iterable and then emits the items
* emitted by the source Observable.
* @method startWith
* @owner Observable
*/
function startWith() {
var array = [];
for (var _i = 0; _i < arguments.length; _i++) {
array[_i] = arguments[_i];
}
return function (source) {
var scheduler = array[array.length - 1];
if (isScheduler_1.isScheduler(scheduler)) {
array.pop();
}
else {
scheduler = null;
}
var len = array.length;
if (len === 1 && !scheduler) {
return concat_1.concat(scalar_1.scalar(array[0]), source);
}
else if (len > 0) {
return concat_1.concat(fromArray_1.fromArray(array, scheduler), source);
}
else {
return concat_1.concat(empty_1.empty(scheduler), source);
}
};
}
exports.startWith = startWith;
//# sourceMappingURL=startWith.js.map
return module.exports;
});