Skip to content

Commit

Permalink
Merge pull request #15 from aretecode/patch-1
Browse files Browse the repository at this point in the history
String Iterator + Array Iterator
  • Loading branch information
jonschlinkert committed Sep 4, 2017
2 parents cb84946 + 87bb563 commit 72d2f2b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
9 changes: 8 additions & 1 deletion index.js
Expand Up @@ -88,13 +88,20 @@ 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';
}

if (type === '[object String Iterator]') {
return 'stringiterator';
}
if (type === '[object Array Iterator]') {
return 'arrayiterator';
}

// typed arrays
if (type === '[object Int8Array]') {
return 'int8array';
Expand Down
21 changes: 14 additions & 7 deletions test/es6/index.js
Expand Up @@ -62,15 +62,22 @@ module.exports = function() {
});

it('should work for Set Iterator', function() {
var set = new Set().values();
assert.equal(kindOf(set), 'setiterator');
var SetValuesIterator = new Set().values();
assert.equal(kindOf(SetValuesIterator), 'setiterator');
});

it('should work for Map Iterator', function() {
var map = new Map().values();
assert.equal(kindOf(map), 'mapiterator');
});

var MapValuesIterator = new Map().values();
assert.equal(kindOf(MapValuesIterator), 'mapiterator');
});
it('should work for Array Iterator', function() {
var ArrayEntriesIterator = [].entries();
assert.equal(kindOf(ArrayEntriesIterator), 'arrayiterator');
})
it('should work for String Iterator', function() {
var StringCharIterator = ''[Symbol.iterator]();
assert.equal(kindOf(StringCharIterator), 'stringiterator');
})

it('should work for Symbol', function() {
assert.equal(kindOf(Symbol('foo')), 'symbol');
assert.equal(kindOf(Symbol.prototype), 'symbol');
Expand Down

0 comments on commit 72d2f2b

Please sign in to comment.