@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 1.43 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 e from"./../symbol/iterator.js";var n=t,o=r,f=e;function u(){return this instanceof u?(this._buffer=[],this):new u}n(u.prototype,"clear",(function(){return this._buffer.length=0,this})),n(u.prototype,"first",(function(){if(this._buffer.length)return this._buffer[this._buffer.length-1]})),n(u.prototype,"iterator",(function(){var t,r,e,o,u;return e=this,u=this._buffer.length,t=this._buffer.slice(),n(r={},"next",(function(){if(u-=1,o||u<0)return{done:!0};return{value:t[u],done:!1}})),n(r,"return",(function(t){if(o=!0,arguments.length)return{value:t,done:!0};return{done:!0}})),f&&n(r,f,(function(){return e.iterator()})),r})),n(u.prototype,"last",(function(){if(this._buffer.length)return this._buffer[0]})),o(u.prototype,"length",(function(){return this._buffer.length})),n(u.prototype,"pop",(function(){if(this._buffer.length)return this._buffer.pop()})),n(u.prototype,"push",(function(t){return this._buffer.push(t),this})),n(u.prototype,"toArray",(function(){var t,r;for(t=[],r=this._buffer.length-1;r>=0;r--)t.push(this._buffer[r]);return t})),n(u.prototype,"toJSON",(function(){var t={type:"stack"};return t.data=this.toArray(),t}));var i=u;export default i;
//# sourceMappingURL=stack.js.map