data-structure-algebra/doubly-linked-list

View on GitHub
src/_insertBetween.js

Summary

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

import Node from './Node.js';

/**
 * _insertBetween.
 *
 * @param {Node} x
 * @param {Node} y
 * @param {any} value
 */
export default function _insertBetween(x, y, value) {
    assert(x instanceof Node);
    assert(y instanceof Node);
    const z = new Node(value, x, y);
    x.next = z;
    y.prev = z;
    return z;
}