Projektstart
This commit is contained in:
29
backend/node_modules/obliterator/consume.js
generated
vendored
Normal file
29
backend/node_modules/obliterator/consume.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/* eslint no-constant-condition: 0 */
|
||||
/**
|
||||
* Obliterator Consume Function
|
||||
* =============================
|
||||
*
|
||||
* Function consuming the given iterator for n or every steps.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Consume.
|
||||
*
|
||||
* @param {Iterator} iterator - Target iterator.
|
||||
* @param {number} [steps] - Optional steps.
|
||||
*/
|
||||
module.exports = function consume(iterator, steps) {
|
||||
var step,
|
||||
l = arguments.length > 1 ? steps : Infinity,
|
||||
i = 0;
|
||||
|
||||
while (true) {
|
||||
if (i === l) return;
|
||||
|
||||
step = iterator.next();
|
||||
|
||||
if (step.done) return;
|
||||
|
||||
i++;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user