Merge branch 'master' into master

This commit is contained in:
Lukas Tetzlaff 2018-05-03 20:52:35 +02:00 committed by GitHub
commit 44948c222b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 3 deletions

View file

@ -1,4 +1,5 @@
import * as util from 'util';
import symbolObservable from 'symbol-observable';
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
type Primitive = null | undefined | string | number | boolean | Symbol;
@ -24,6 +25,7 @@ export const enum TypeName {
Function = 'Function',
GeneratorFunction = 'GeneratorFunction',
AsyncFunction = 'AsyncFunction',
Observable = 'Observable',
Array = 'Array',
Buffer = 'Buffer',
Object = 'Object',
@ -90,6 +92,10 @@ function is(value: any): TypeName { // tslint:disable-line:only-arrow-functions
return TypeName.Function;
}
if (is.observable(value)) {
return TypeName.Observable;
}
if (Array.isArray(value)) {
return TypeName.Array;
}
@ -246,7 +252,8 @@ namespace is { // tslint:disable-line:no-namespace
export const domElement = (value: any): value is DomElement => object(value) as any && value.nodeType === NODE_TYPE_ELEMENT && string(value.nodeName) &&
!plainObject(value) && DOM_PROPERTIES_TO_CHECK.every(property => property in value);
export const nodeStream = (value: any): value is NodeStream => !nullOrUndefined(value) && isObject(value) as any && function_(value.pipe);
export const observable = (value: any) => Boolean(value && value[symbolObservable] && value === value[symbolObservable]());
export const nodeStream = (value: any): value is NodeStream => !nullOrUndefined(value) && isObject(value) as any && function_(value.pipe) && !observable(value);
export const infinite = (value: any) => value === Infinity || value === -Infinity;

View file

@ -5,6 +5,8 @@ import * as util from 'util';
import * as tempy from 'tempy';
import test, {TestContext, Context} from 'ava';
import {JSDOM} from 'jsdom';
import {Subject, Observable} from 'rxjs';
import ZenObservable from 'zen-observable';
import m from '..';
const isNode8orHigher = Number(process.versions.node.split('.')[0]) >= 8;
@ -321,6 +323,14 @@ const types = new Map<string, Test>([
new Stream.Writable()
]
}],
['observable', {
is: m.observable,
fixtures: [
new Observable(),
new Subject(),
new ZenObservable(() => {}) // tslint:disable-line:no-empty
]
}],
['infinite', {
is: m.infinite,
fixtures: [