1/**************************/ 2/* Utility */ 3/**************************/ 4 5var Utility = { 6 7 // FindObject by name 8 FindByName: function (Name, Object) 9 { 10 var element = null; 11 if (typeof Object != "object") throw "object must be typeof object"; 12 for (var i = 0; i < Object.length; i++) 13 { 14 if (Object[i].hasOwnProperty("_Name") && Object[i]._Name == Name) 15 { 16 element = Object[i]; 17 break; 18 } 19 } 20 return element; 21 } 22}; 23 24// This is a simple implementation of the queue data structure (JS doesn't have queues) 25class Queue { 26 constructor() { 27 this.elements = []; 28 this.minIndex = 0; 29 this.maxIndex = -1; 30 } 31 32 Enqueue(element) { 33 this.elements.push(element); 34 this.maxIndex++; 35 } 36 37 Dequeue() { 38 if (this.minIndex <= this.maxIndex) { 39 const element = this.elements[this.minIndex++]; 40 return element; 41 } 42 } 43 44 IsEmpty() { 45 return this.minIndex === this.maxIndex + 1; 46 } 47 48 Size() { 49 return this.maxIndex - this.minIndex + 1; 50 } 51} 52 53class ContentLoadingQueue { 54 constructor(maxNumberOfContentsBeingLoaded) { 55 this.numberOfContentsBeingLoaded = 0; 56 this.maxNumberOfContentsBeingLoaded = maxNumberOfContentsBeingLoaded; 57 this.queue = new Queue(); 58 } 59 60 QueueTask(task) { 61 if (this.numberOfContentsBeingLoaded + 1 > this.maxNumberOfContentsBeingLoaded) { 62 this.queue.Enqueue(task); 63 } else { 64 this._Executetask(task); 65 } 66 } 67 68 async _Executetask(task) { 69 this.numberOfContentsBeingLoaded++; 70 71 await task(); 72 73 if (!this.queue.IsEmpty()) { 74 const taskFromQueue = this.queue.Dequeue(); 75 this._Executetask(taskFromQueue); 76 } 77 this.numberOfContentsBeingLoaded--; 78 } 79} 80 81window.GlobalContentLoadingQueue = new ContentLoadingQueue(300);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.