You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
190 KiB
1 line
190 KiB
4 years ago
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).csso={})}(this,(function(e){"use strict";function t(e){return{prev:null,next:null,data:e}}function n(e,t,n){var r;return null!==a?(r=a,a=a.cursor,r.prev=t,r.next=n,r.cursor=e.cursor):r={prev:t,next:n,cursor:e.cursor},e.cursor=r,r}function r(e){var t=e.cursor;e.cursor=t.cursor,t.prev=null,t.next=null,t.cursor=a,a=t}var a=null,i=function(){this.cursor=null,this.head=null,this.tail=null};i.createItem=t,i.prototype.createItem=t,i.prototype.updateCursors=function(e,t,n,r){for(var a=this.cursor;null!==a;)a.prev===e&&(a.prev=t),a.next===n&&(a.next=r),a=a.cursor},i.prototype.getSize=function(){for(var e=0,t=this.head;t;)e++,t=t.next;return e},i.prototype.fromArray=function(e){var n=null;this.head=null;for(var r=0;r<e.length;r++){var a=t(e[r]);null!==n?n.next=a:this.head=a,a.prev=n,n=a}return this.tail=n,this},i.prototype.toArray=function(){for(var e=this.head,t=[];e;)t.push(e.data),e=e.next;return t},i.prototype.toJSON=i.prototype.toArray,i.prototype.isEmpty=function(){return null===this.head},i.prototype.first=function(){return this.head&&this.head.data},i.prototype.last=function(){return this.tail&&this.tail.data},i.prototype.each=function(e,t){var a;void 0===t&&(t=this);for(var i=n(this,null,this.head);null!==i.next;)a=i.next,i.next=a.next,e.call(t,a.data,a,this);r(this)},i.prototype.forEach=i.prototype.each,i.prototype.eachRight=function(e,t){var a;void 0===t&&(t=this);for(var i=n(this,this.tail,null);null!==i.prev;)a=i.prev,i.prev=a.prev,e.call(t,a.data,a,this);r(this)},i.prototype.forEachRight=i.prototype.eachRight,i.prototype.nextUntil=function(e,t,a){if(null!==e){var i;void 0===a&&(a=this);for(var o=n(this,null,e);null!==o.next&&(i=o.next,o.next=i.next,!t.call(a,i.data,i,this)););r(this)}},i.prototype.prevUntil=function(e,t,a){if(null!==e){var i;void 0===a&&(a=this);for(var o=n(this,e,null);null!==o.prev&&(i=o.prev,o.prev=i.prev,!t.call(a,i.data,i,this)););r(this)}},i.prototype.some=function(e,t){var n=this.head;for(void 0===t&&(t=this);null!==n;){if(e.call(t,n.data,n,this))return!0;n=n.next}return!1},i.prototype.map=function(e,t){var n=new i,r=this.head;for(void 0===t&&(t=this);null!==r;)n.appendData(e.call(t,r.data,r,this)),r=r.next;return n},i.prototype.filter=function(e,t){var n=new i,r=this.head;for(void 0===t&&(t=this);null!==r;)e.call(t,r.data,r,this)&&n.appendData(r.data),r=r.next;return n},i.prototype.clear=function(){this.head=null,this.tail=null},i.prototype.copy=function(){for(var e=new i,n=this.head;null!==n;)e.insert(t(n.data)),n=n.next;return e},i.prototype.prepend=function(e){return this.updateCursors(null,e,this.head,e),null!==this.head?(this.head.prev=e,e.next=this.head):this.tail=e,this.head=e,this},i.prototype.prependData=function(e){return this.prepend(t(e))},i.prototype.append=function(e){return this.insert(e)},i.prototype.appendData=function(e){return this.insert(t(e))},i.prototype.insert=function(e,t){if(null!=t)if(this.updateCursors(t.prev,e,t,e),null===t.prev){if(this.head!==t)throw new Error("before doesn't belong to list");this.head=e,t.prev=e,e.next=t,this.updateCursors(null,e)}else t.prev.next=e,e.prev=t.prev,t.prev=e,e.next=t;else this.updateCursors(this.tail,e,null,e),null!==this.tail?(this.tail.next=e,e.prev=this.tail):this.head=e,this.tail=e;return this},i.prototype.insertData=function(e,n){return this.insert(t(e),n)},i.prototype.remove=function(e){if(this.updateCursors(e,e.prev,e,e.next),null!==e.prev)e.prev.next=e.next;else{if(this.head!==e)throw new Error("item doesn't belong to list");this.head=e.next}if(null!==e.next)e.next.prev=e.prev;else{if(this.tail!==e)throw new Error("item doesn't belong to list");this.tail=e.prev}return e.prev=null,e.next=null,e},i.prototype.push=function(e){this.insert(t(e))},i.prototype.pop=function(){if(null!==this.tail)return this.remove(this.tail)},i.prototype.unshift=function(e){this.prepend(t(e))},i.prototype.shift=function(){if(null!==this.head)return this.remove(this.head)},i.prototype.prependList=f
|