data-structure-algebra/doubly-linked-list

View on GitHub
src/values.js

Summary

Maintainability
A
0 mins
Test Coverage
import assert from 'assert';

import Node from './Node.js';
import _iter_fast from './_iter_fast.js';

/**
 * Generator of nodes in list in order.
 *
 * @param {Node} first First node of the list (can be null).
 * @return {IterableIterator<any>}
 */
export default function* values(first) {
    assert(first === null || first instanceof Node);
    if (first !== null) {
        for (const x of _iter_fast(first)) yield x.value;
    }
}