Skip to content

Commit

Permalink
docs(jsdoc): update docs for isIterator() method
Browse files Browse the repository at this point in the history
  • Loading branch information
blond committed Aug 4, 2016
1 parent b0ebf8e commit 69e80b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/is-iterable.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @example
* const isIterable = require('ho-iter').isIterable;
*
* console.log(isIterable([1, 2, 3])); // true
* console.log(isIterable(123)); // false
* isIterable([1, 2, 3]); // true
* isIterable(123); // false
*
* @param {*} iterable - a value which might implement the Iterable protocol.
* @return {boolean}
Expand Down
15 changes: 12 additions & 3 deletions lib/is-iterator.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
'use strict';

/**
* Checks if `obj` is iterator.
* Returns `true` if the specified object is iterator.
*
* @param {*} obj - some object.
* @example
* const isIterator = require('ho-iter').isIterator;
*
* const generator = function *() {};
* const iterator = generator();
*
* isIterator(generator) // false
* isIterator(iterator) // true
*
* @param {*} iterator - a value which might implement the Iterable protocol.
* @return {boolean}
*/
module.exports = (obj) => Boolean(obj) && typeof obj.next === 'function';
module.exports = (iterator) => Boolean(iterator) && typeof iterator.next === 'function';

0 comments on commit 69e80b2

Please sign in to comment.