diff --git a/lib/is-iterable.js b/lib/is-iterable.js index 9505300..f747e9d 100644 --- a/lib/is-iterable.js +++ b/lib/is-iterable.js @@ -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} diff --git a/lib/is-iterator.js b/lib/is-iterator.js index bb866ab..c3fc3b3 100644 --- a/lib/is-iterator.js +++ b/lib/is-iterator.js @@ -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';