UNPKG

ll-package

Version:

2 lines (1 loc) 1.65 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../../_virtual/_commonjsHelpers.js"),o=require("../../../_virtual/Iterator.js"),l=require("./Op.js");var a;function d(){if(a)return o.__exports;a=1;var p=f.commonjsGlobal&&f.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o.__exports,"__esModule",{value:!0});var u=p(l.__require()),h=function(){function e(t){this.ops=t,this.index=0,this.offset=0}return e.prototype.hasNext=function(){return this.peekLength()<1/0},e.prototype.next=function(t){t||(t=1/0);var i=this.ops[this.index];if(i){var r=this.offset,n=u.default.length(i);if(t>=n-r?(t=n-r,this.index+=1,this.offset=0):this.offset+=t,typeof i.delete=="number")return{delete:t};var s={};return i.attributes&&(s.attributes=i.attributes),typeof i.retain=="number"?s.retain=t:typeof i.insert=="string"?s.insert=i.insert.substr(r,t):s.insert=i.insert,s}else return{retain:1/0}},e.prototype.peek=function(){return this.ops[this.index]},e.prototype.peekLength=function(){return this.ops[this.index]?u.default.length(this.ops[this.index])-this.offset:1/0},e.prototype.peekType=function(){return this.ops[this.index]?typeof this.ops[this.index].delete=="number"?"delete":typeof this.ops[this.index].retain=="number"?"retain":"insert":"retain"},e.prototype.rest=function(){if(this.hasNext()){if(this.offset===0)return this.ops.slice(this.index);var t=this.offset,i=this.index,r=this.next(),n=this.ops.slice(this.index);return this.offset=t,this.index=i,[r].concat(n)}else return[]},e}();return o.__exports.default=h,o.__exports}exports.__require=d;