50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
|
'use strict';
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.from = from;
|
||
|
|
||
|
var _Stream = require('../Stream');
|
||
|
|
||
|
var _Stream2 = _interopRequireDefault(_Stream);
|
||
|
|
||
|
var _fromArray = require('./fromArray');
|
||
|
|
||
|
var _iterable = require('../iterable');
|
||
|
|
||
|
var _fromIterable = require('./fromIterable');
|
||
|
|
||
|
var _getObservable = require('../observable/getObservable');
|
||
|
|
||
|
var _getObservable2 = _interopRequireDefault(_getObservable);
|
||
|
|
||
|
var _fromObservable = require('../observable/fromObservable');
|
||
|
|
||
|
var _prelude = require('@most/prelude');
|
||
|
|
||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
|
||
|
function from(a) {
|
||
|
// eslint-disable-line complexity
|
||
|
if (a instanceof _Stream2.default) {
|
||
|
return a;
|
||
|
}
|
||
|
|
||
|
var observable = (0, _getObservable2.default)(a);
|
||
|
if (observable != null) {
|
||
|
return (0, _fromObservable.fromObservable)(observable);
|
||
|
}
|
||
|
|
||
|
if (Array.isArray(a) || (0, _prelude.isArrayLike)(a)) {
|
||
|
return (0, _fromArray.fromArray)(a);
|
||
|
}
|
||
|
|
||
|
if ((0, _iterable.isIterable)(a)) {
|
||
|
return (0, _fromIterable.fromIterable)(a);
|
||
|
}
|
||
|
|
||
|
throw new TypeError('from(x) must be observable, iterable, or array-like: ' + a);
|
||
|
} /** @license MIT License (c) copyright 2010-2016 original author or authors */
|
||
|
/** @author Brian Cavalier */
|
||
|
/** @author John Hann */
|