Skip to content

Commit

Permalink
feat(fromPromise): widen support for promise types
Browse files Browse the repository at this point in the history
PR #187
  • Loading branch information
Sarun Rattanasiri authored and staltz committed Apr 27, 2017
1 parent 1512654 commit 12da02d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,9 @@ class FromArray<T> implements InternalProducer<T> {
class FromPromise<T> implements InternalProducer<T> {
public type = 'fromPromise';
public on: boolean;
public p: Promise<T>;
public p: PromiseLike<T>;

constructor(p: Promise<T>) {
constructor(p: PromiseLike<T>) {
this.on = false;
this.p = p;
}
Expand Down Expand Up @@ -1335,14 +1335,14 @@ export class Stream<T> implements InternalListener<T> {
* Creates a stream from an Array, Promise, or an Observable.
*
* @factory true
* @param {Array|Promise|Observable} input The input to make a stream from.
* @param {Array|PromiseLike|Observable} input The input to make a stream from.
* @return {Stream}
*/
static from<T>(input: Promise<T> | Stream<T> | Array<T> | Observable<T>): Stream<T> {
static from<T>(input: PromiseLike<T> | Stream<T> | Array<T> | Observable<T>): Stream<T> {
if (typeof input[$$observable] === 'function')
return Stream.fromObservable<T>(input as Observable<T>); else
if (typeof (input as Promise<T>).then === 'function')
return Stream.fromPromise<T>(input as Promise<T>); else
if (typeof (input as PromiseLike<T>).then === 'function')
return Stream.fromPromise<T>(input as PromiseLike<T>); else
if (Array.isArray(input))
return Stream.fromArray<T>(input);

Expand Down Expand Up @@ -1402,10 +1402,10 @@ export class Stream<T> implements InternalListener<T> {
* ```
*
* @factory true
* @param {Promise} promise The promise to be converted as a stream.
* @param {PromiseLike} promise The promise to be converted as a stream.
* @return {Stream}
*/
static fromPromise<T>(promise: Promise<T>): Stream<T> {
static fromPromise<T>(promise: PromiseLike<T>): Stream<T> {
return new Stream<T>(new FromPromise<T>(promise));
}

Expand Down

0 comments on commit 12da02d

Please sign in to comment.