UNPKG

1.87 kBJavaScriptView Raw
1/** @ignore */
2const isNumber = (x) => typeof x === 'number';
3/** @ignore */
4const isBoolean = (x) => typeof x === 'boolean';
5/** @ignore */
6export const isFunction = (x) => typeof x === 'function';
7/** @ignore */
8export const isObject = (x) => x != null && Object(x) === x;
9/** @ignore */
10export const isPromise = (x) => {
11 return isObject(x) && isFunction(x.then);
12};
13/** @ignore */
14export function isArrayLike(x) {
15 return isObject(x) && isNumber(x['length']);
16}
17/** @ignore */
18export function isIterable(x) {
19 return x != null && isFunction(x[Symbol.iterator]);
20}
21/** @ignore */
22export function isIterator(x) {
23 return isObject(x) && !isFunction(x[Symbol.iterator]) && isFunction(x['next']);
24}
25/** @ignore */
26export function isAsyncIterable(x) {
27 return isObject(x) && isFunction(x[Symbol.asyncIterator]);
28}
29/** @ignore */
30export function isObservable(x) {
31 return x != null && Object(x) === x && typeof x['subscribe'] === 'function';
32}
33/** @ignore */
34export const isReadableNodeStream = (x) => {
35 return (isObject(x) &&
36 isFunction(x['pipe']) &&
37 isFunction(x['_read']) &&
38 isBoolean(x['readable']) &&
39 isObject(x['_readableState']));
40};
41/** @ignore */
42export const isWritableNodeStream = (x) => {
43 return (isObject(x) &&
44 isFunction(x['end']) &&
45 isFunction(x['_write']) &&
46 isBoolean(x['writable']) &&
47 isObject(x['_writableState']));
48};
49/** @ignore */
50export const isReadableDOMStream = (x) => {
51 return isObject(x) && isFunction(x['cancel']) && isFunction(x['getReader']);
52};
53/** @ignore */
54export const isWritableDOMStream = (x) => {
55 return isObject(x) && isFunction(x['abort']) && isFunction(x['getWriter']);
56};
57/** @ignore */
58export const isFetchResponse = (x) => {
59 return isObject(x) && isReadableDOMStream(x['body']);
60};
61
62//# sourceMappingURL=isiterable.mjs.map