let structLinkedListFactory=(data=[])=>{let headNode=null,tailNode=null,size=0,linkedList={size:()=>size,getHead:()=>headNode,getTail:()=>tailNode,prepend:data=>{data={data:data,prev:null,next:headNode||null};size+=1,headNode=data,tailNode=tailNode||data},append:data=>{data={data:data,prev:tailNode||null,next:null};size+=1,tailNode&&(tailNode.next=data),tailNode=data,headNode=headNode||data},find:comparator=>{let checkNext=node=>comparator(node.data)?node:node.next?checkNext(node.next):null;return headNode?checkNext(headNode):null},insertBefore:(node,data)=>{data={data:data,prev:node.prev,next:node};size+=1,node.prev?node.prev.next=data:headNode=data,node.prev=data},insertAfter:(node,data)=>{data={data:data,prev:node,next:node.next};size+=1,node.next?node.next.prev=data:tailNode=data,node.next=data},deleteNode:node=>{node.prev?node.prev.next=node.next||null:headNode=node.next||null,node.next?node.next.prev=node.prev||null:tailNode=node.prev||null,--size},deleteHead:()=>{var headNode=linkedList.getHead();headNode&&linkedList.deleteNode(headNode)},deleteTail:()=>{var tailNode=linkedList.getTail();tailNode&&linkedList.deleteNode(tailNode)},clear:()=>{headNode=null,tailNode=null,size=0},toArray:()=>{let array=[];if(!headNode)return array;let addToArray=node=>(array.push(node.data),node.next?addToArray(node.next):array);return addToArray(headNode)},toArrayReverse:()=>{let array=[];if(!tailNode)return array;let addToArray=node=>(array.push(node.data),node.prev?addToArray(node.prev):array);return addToArray(tailNode)},[Symbol.iterator](){let node=headNode;return{next(){let value=null,done=!0;return null!==node&&(value=node.data,done=!1,node=node.next),{value:value,done:done}}}}};for(var datum of data)linkedList.append(datum);return linkedList};exports.structLinkedListFactory=structLinkedListFactory;