1 line
2.2 KiB
JavaScript
1 line
2.2 KiB
JavaScript
!function r(e,t,n){function o(u,f){if(!t[u]){if(!e[u]){var p="function"==typeof require&&require;if(!f&&p)return p(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var c=t[u]={exports:{}};e[u][0].call(c.exports,function(r){var t=e[u][1][r];return o(t?t:r)},c,c.exports,r,e,t,n)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<n.length;u++)o(n[u]);return o}({1:[function(r,e){var t;t=function(){function r(r){this.user_id=r,this.operation_counter={},this.buffer={},this.change_listeners=[]}return r.prototype.getUserId=function(){return this.user_id},r.prototype.getReservedUniqueIdentifier=function(){return{creator:"_",op_number:"_"}},r.prototype.getOperationCounter=function(){var r,e,t,n;e={},n=this.operation_counter;for(t in n)r=n[t],e[t]=r;return e},r.prototype._encode=function(r){var e,t,n,o,i,u,f,p,c,a;null==r&&(r={}),e=[],p=function(e,t){if(null==e||null==t)throw new Error("dah!");return null==r[e]||r[e]<=t},a=this.buffer;for(f in a){c=a[f];for(i in c)if(t=c[i],!isNaN(parseInt(i))&&p(f,i)){if(n=t._encode(),null!=t.next_cl){for(o=t.next_cl;null!=o.next_cl&&p(o.creator,o.op_number);)o=o.next_cl;n.next=o.getUid()}else if(null!=t.prev_cl){for(u=t.prev_cl;null!=u.prev_cl&&p(o.creator,o.op_number);)u=u.prev_cl;n.prev=u.getUid()}e.push(n)}}return e},r.prototype.getNextOperationIdentifier=function(r){var e;return null==r&&(r=this.user_id),null==this.operation_counter[r]&&(this.operation_counter[r]=0),e={creator:r,op_number:this.operation_counter[r]},this.operation_counter[r]++,e},r.prototype.getOperation=function(r){var e;if(r instanceof Object)return null!=(e=this.buffer[r.creator])?e[r.op_number]:void 0;if(null!=r)throw new Error("This type of uid is not defined!")},r.prototype.addOperation=function(r){if(null==this.buffer[r.creator]&&(this.buffer[r.creator]={}),null!=this.buffer[r.creator][r.op_number])throw new Error("You must not overwrite operations!");return this.buffer[r.creator][r.op_number]=r,r},r.prototype.addToCounter=function(r){return null==this.operation_counter[r.creator]&&(this.operation_counter[r.creator]=0),"number"==typeof r.op_number&&r.creator!==this.getUserId()?this.operation_counter[r.creator]++:void 0},r}(),e.exports=t},{}]},{},[1]); |