* Dequeues an id. * Similar to Array#pop(). * @returns {Number} Returns an id or null
()
| 96 | * @returns {Number} Returns an id or null |
| 97 | */ |
| 98 | pop() { |
| 99 | let id = this.currentGroup.pop(); |
| 100 | if (typeof id !== 'undefined') { |
| 101 | this.inUse++; |
| 102 | return id; |
| 103 | } |
| 104 | //try to use the following groups |
| 105 | while (this.groupIndex < this.groups.length - 1) { |
| 106 | //move to the following group |
| 107 | this.currentGroup = this.groups[++this.groupIndex]; |
| 108 | //try dequeue |
| 109 | id = this.currentGroup.pop(); |
| 110 | if (typeof id !== 'undefined') { |
| 111 | this.inUse++; |
| 112 | return id; |
| 113 | } |
| 114 | } |
| 115 | return this._tryCreateGroup(); |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Enqueue an id for future use. |
no test coverage detected