mirror of
https://github.com/Instadapp/Swap-Aggregator-Subgraph.git
synced 2024-07-29 21:57:12 +00:00
29 lines
585 B
JavaScript
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
|
|
}
|