Code coverage report for src/isEmpty.js

Statements: 100% (8 / 8)      Branches: 100% (8 / 8)      Functions: 100% (1 / 1)      Lines: 100% (8 / 8)      Ignored: none     

All files » src/ » isEmpty.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21            1 17 17   17 8     9   9        
/**
 * Checks if the iterable is empty.
 * The the given value is considered empty if it is not an iterable.
 * @param {*} xs - The iterable to check.
 * @returns {Boolean} - True if the iterable is empty.
 */
function isEmpty(xs) {
    let iter = xs && xs[Symbol.iterator] ? xs[Symbol.iterator]() : null;
    let x;
 
    if (!iter) {
        return true;
    }
 
    x = iter.next();
 
    return x.done ? true : false;
}
 
export default isEmpty;