@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 1.74 kB
JavaScript
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0
import t from"./define-nonenumerable-read-only-property.js";import r from"./define-nonenumerable-read-only-accessor.js";import n from"./../symbol/iterator.js";function e(t){return this.next=null,this.prev=null,this.value=t,this}var i=t,s=r,o=n,h=e;function l(){return this instanceof l?(this._length=0,this._first=null,this._last=null,this):new l}i(l.prototype,"clear",(function(){return this._length=0,this._first=null,this._last=null,this})),i(l.prototype,"first",(function(){if(this._length)return this._first.value})),i(l.prototype,"iterator",(function(){var t,r,n,e,s;return n=this,s=-1,t=this.toArray(),i(r={},"next",(function(){if(s+=1,e||s>=t.length)return{done:!0};return{value:t[s],done:!1}})),i(r,"return",(function(t){if(e=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),o&&i(r,o,(function(){return n.iterator()})),r})),i(l.prototype,"last",(function(){if(this._length)return this._last.value})),s(l.prototype,"length",(function(){return this._length})),i(l.prototype,"pop",(function(){var t;return this._length&&(t=this._first.value,this._first.next?(this._first=this._first.next,this._first.prev=null):(this._first=null,this._last=null),this._length-=1),t})),i(l.prototype,"push",(function(t){var r;return r=new h(t),0===this._length?(this._first=r,this._last=r):(r.prev=this._last,this._last.next=r,this._last=r),this._length+=1,this})),i(l.prototype,"toArray",(function(){var t,r,n;for(r=[],t=this._first,n=0;n<this._length;n++)r.push(t.value),t=t.next;return r})),i(l.prototype,"toJSON",(function(){var t={type:"fifo"};return t.data=this.toArray(),t}));var u=l;export default u;
//# sourceMappingURL=fifo.js.map