From 237f5c302b38024d900c16421156ee0c82c85c7d Mon Sep 17 00:00:00 2001 From: David Braun Date: Thu, 26 Apr 2018 13:09:28 -0400 Subject: [PATCH] Channel.isChannel: Work with 'undefined' and 'null'. --- lib/index.js | 4 +++- test/index.js | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index a9bd55c..0125830 100644 --- a/lib/index.js +++ b/lib/index.js @@ -408,7 +408,9 @@ Channel.from = (values, mapfn, thisArg) => { }; Channel.of = (...values) => Channel.from(values); -Channel.isChannel = arg => Object.getPrototypeOf(arg) === prototype; + +Channel.isChannel = arg => + arg !== undefined && arg !== null && Object.getPrototypeOf(arg) === prototype; Channel.select = methodPromises => Object.assign( diff --git a/test/index.js b/test/index.js index 05a0220..dda61a9 100644 --- a/test/index.js +++ b/test/index.js @@ -82,6 +82,8 @@ describe(`Channel function`, function() { it(`isChannel`, function() { assert(Channel.isChannel(Channel.of(0, 1, 2))); assert(!Channel.isChannel(Array.of(0, 1, 2))); + assert(!Channel.isChannel(undefined)); + assert(!Channel.isChannel(null)); assert(Channel.isChannel(Channel().readOnly())); assert(Channel.isChannel(Channel().writeOnly())); });