From b6bf33adbcce4128b3cf08612dbf9c814d3678af Mon Sep 17 00:00:00 2001 From: Arete Code Date: Tue, 20 Jun 2017 15:21:52 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=81=20Set=20Iterator=20+=20Map=20Itera?= =?UTF-8?q?tor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 6 ++++++ test/es6/index.js | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 4c0233b..8d4bc45 100644 --- a/index.js +++ b/index.js @@ -84,6 +84,12 @@ module.exports = function kindOf(val) { if (type === '[object Symbol]') { return 'symbol'; } + if (type === '[object Map Iterator]') { + return 'mapiterator'; + } + if (type === '[object Set Iterator]') { + return 'setiterator'; + } // typed arrays if (type === '[object Int8Array]') { diff --git a/test/es6/index.js b/test/es6/index.js index b074eec..4154480 100644 --- a/test/es6/index.js +++ b/test/es6/index.js @@ -13,17 +13,19 @@ module.exports = function() { it('should work for rejected promises', function() { var promise = Promise.reject(new Error('foo bar')); - promise.catch(function() {}) + promise.catch(function() {}); assert.strictEqual(kindOf(promise), 'promise'); }); it('should work for generators', function() { - var gen = function * named() {return true;}; + var gen = function * named() { + return true; + }; assert.equal(kindOf(gen), 'function'); }); it('should work for template strings', function() { - var str = `Welcome buddy`; + var str = 'Welcome buddy'; assert.equal(kindOf(str), 'string'); }); @@ -59,6 +61,16 @@ module.exports = function() { assert.equal(kindOf(weakset.get), 'undefined'); }); + it('should work for Set Iterator', function() { + var set = new Set().values(); + assert.equal(kindOf(set), 'setiterator'); + }); + + it('should work for Map Iterator', function() { + var map = new Map().values(); + assert.equal(kindOf(map), 'mapiterator'); + }); + it('should work for Symbol', function() { assert.equal(kindOf(Symbol('foo')), 'symbol'); assert.equal(kindOf(Symbol.prototype), 'symbol');