Swap-Aggregator-Subgraph/node_modules/is-circular/lib/node.js
Richa-iitr d211083153 Revert "Revert "added handler""
This reverts commit c36ee8c5ca.
2022-07-03 07:30:05 +05:30

29 lines
585 B
JavaScript

module.exports = Node
/**
* a linked-list node
* @class
* @param {any} value - node's value
* @param {Node} next - next node
*/
function Node (value, next) {
this.value = value
this.next = next
}
/**
* checks if this node or any of its children has the value
* @param {any} value - value to check if linked-list contains
* @return {boolean} true if the list contains the value; false if not
*/
Node.prototype.contains = function (value) {
var cursor = this
while (cursor) {
if (cursor.value === value) return true
cursor = cursor.next
}
return false
}