@d1g1tal/collections
Version:
JavaScript Collections ES Modules
66 lines (64 loc) • 1.8 kB
TypeScript
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 options The options for the node, or the node to copy.
* @param [options.previous] The previous node.
* @param [options.next] The next node.
* @param options.key The key to be assigned to the node.
* @param options.value The value to be assigned to the node.
*/
constructor({ previous, next, key, value }: KeyedNodeOptions<K, E>);
/**
* Gets the key.
* @returns The key.
*/
get key(): K | null;
/**
* Sets the key.
* @param key The key.
*/
set key(key: K);
/**
* Gets the previous node.
* @returns The previous node.
*/
get previous(): KeyedNode<K, E> | null;
/**
* Sets the previous node.
* @param previous The previous node.
*/
set previous(previous: KeyedNode<K, E> | null);
/**
* Gets the next node.
* @returns The next node.
*/
get next(): KeyedNode<K, E> | null;
/**
* Sets the next node.
* @param next The next node.
*/
set next(next: KeyedNode<K, E> | null);
/**
* Gets the value of the node.
* @returns The value of the node.
*/
get value(): E;
/**
* Sets the value of the node.
* @param value The value of the node.
*/
set value(value: E);
/**
* Gets the string description of the class.
* @returns The string description of the class.
*/
get [Symbol.toStringTag](): string;
}
export { KeyedNode };