Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String Iterator + Array Iterator #15

Merged
merged 2 commits into from Sep 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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