@d1g1tal/collections
Version:
JavaScript Collections ES Modules
57 lines (55 loc) • 1.57 kB
TypeScript
type NodeOptions<E> = Partial<Omit<Node<E>, 'value'>> & {
value: E;
};
/** JavaScript implementation of a Node that can be used in a linked list */
declare class Node<E> {
protected $previous: Node<E> | null;
protected $next: Node<E> | null;
protected $value: E;
/**
* 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.value The value to be assigned to the node.
*/
constructor({ previous, next, value }: NodeOptions<E>);
/**
* Gets the previous node.
* @returns The previous node.
*/
get previous(): Node<E> | null;
/**
* Sets the previous node.
* @param previous The previous node.
*/
set previous(previous: Node<E> | null);
/**
* Gets the next node.
* @returns The next node.
*/
get next(): Node<E> | null;
/**
* Sets the next node.
* @param next The next node.
*/
set next(next: Node<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);
/** Unlinks this node from the list */
unlink(): void;
/**
* Returns a string description of the class.
* @returns A string description of the class.
*/
get [Symbol.toStringTag](): string;
}
export { Node };