| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 24 | /**
* Yields the truthy values from the iterable.
* @param {*} xs - The iterable to compact.
* @returns {*} - All truthy values from the iterable.
*/
function *compact(xs) {
for (let x of xs) {
if (x) {
yield x;
}
}
}
export default compact;
|