You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
568 B
28 lines
568 B
/**
|
|
* Obliterator Includes Function
|
|
* ==============================
|
|
*
|
|
* Function taking an iterable and returning whether the given item can be
|
|
* found in it.
|
|
*/
|
|
var iter = require('./iter.js');
|
|
|
|
/**
|
|
* Includes.
|
|
*
|
|
* @param {Iterable} iterable - Target iterable.
|
|
* @param {function} value - Searched value.
|
|
* @return {boolean}
|
|
*/
|
|
module.exports = function includes(iterable, value) {
|
|
var iterator = iter(iterable);
|
|
|
|
var step;
|
|
|
|
while (((step = iterator.next()), !step.done)) {
|
|
if (step.value === value) return true;
|
|
}
|
|
|
|
return false;
|
|
};
|