/**
 *
 * @param {SignalHandler} first
 * @param {function} consumer
 * @returns {boolean}
 */
export function signal_handler_list_validate(first, consumer) {

    const visited = new Set();
    let n = first;
    while (n !== null) {

        if (n === undefined) {
            consumer("Node is undefined, invalid value type");
            return false;
        }

        if (visited.has(n)) {
            consumer('Detected loop');
            return false;
        }

        visited.add(n);

        n = n.next;
    }

    return true;
}