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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃攣 Set Iterator + Map Iterator #12

Merged
merged 1 commit into from Jun 21, 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
6 changes: 6 additions & 0 deletions index.js
Expand Up @@ -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]') {
Expand Down
18 changes: 15 additions & 3 deletions test/es6/index.js
Expand Up @@ -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';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was testing template strings, I'm guessing there was a linting error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonschlinkert ah sorry about that, yes, it was autofixed

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np, it was a simple mistake. I had to do some linting anyway. thanks for the pr

assert.equal(kindOf(str), 'string');
});

Expand Down Expand Up @@ -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');
Expand Down