UNPKG

@d1g1tal/collections

Version:
78 lines (75 loc) 2.06 kB
import { Node } from './node.js'; type KeyedNodeOptions<K, E> = Partial<Omit<KeyedNode<K, E>, 'value' | 'key'>> & { key: K; value: E; }; /** JavaScript implementation of a Node that can be used in a linked list. */ declare class KeyedNode<K, E> extends Node<E> { private $key; /** * Creates a new node with the given value. * * @param {Object} options The options for the node, or the node to copy. * @param {KeyedNode<K, E>} [options.previous] The previous node. * @param {KeyedNode<K, E>} [options.next] The next node. * @param {K} options.key The key to be assigned to the node. * @param {E} options.value The value to be assigned to the node. */ constructor({ previous, next, key, value }: KeyedNodeOptions<K, E>); /** * Gets the key. * * @returns {K | null} The key. */ get key(): K | null; /** * Sets the key. * * @param {K} key The key. */ set key(key: K); /** * Gets the previous node. * * @returns {KeyedNode<K, E> | null} The previous node. */ get previous(): KeyedNode<K, E> | null; /** * Sets the previous node. * * @param {Node<E> | null} previous The previous node. */ set previous(previous: KeyedNode<K, E> | null); /** * Gets the next node. * * @returns {Node<E> | null} The next node. */ get next(): KeyedNode<K, E> | null; /** * Sets the next node. * * @param {KeyedNode<K, E> | null} next The next node. */ set next(next: KeyedNode<K, E> | null); /** * Gets the value of the node. * * @returns {E} The value of the node. */ get value(): E; /** * Sets the value of the node. * * @param {E} value The value of the node. */ set value(value: E); /** * Gets the string description of the class. * * @override * @returns {string} The string description of the class. */ get [Symbol.toStringTag](): string; } export { KeyedNode };