push
<a href="https://github.com/NikolayMakhonin/async-utils/commit/<a class=hub.com/NikolayMakhonin/async-utils/commit/54f2073ca8b452613bef764d32cb0ad78e8c5d89">54f2073ca<a href="https://github.com/NikolayMakhonin/async-utils/commit/54f2073ca8b452613bef764d32cb0ad78e8c5d89">">Merge </a><a class="double-link" href="https://github.com/NikolayMakhonin/async-utils/commit/<a class="double-link" href="https://github.com/NikolayMakhonin/async-utils/commit/2589e265091db48607d257e270d8fff4aa8e2406">2589e2650</a>">2589e2650</a><a href="https://github.com/NikolayMakhonin/async-utils/commit/54f2073ca8b452613bef764d32cb0ad78e8c5d89"> into 7444b8c09">7444b8c09</a>
271 of 353 branches covered (76.77%)
Branch coverage included in aggregate %.
358 of 358 new or added lines in 12 files covered. (100.0%)
491 of 591 relevant lines covered (83.08%)
53385.25 hits per line
|
import {IStackPool} from './contracts' |
2✔ |
2 |
|
|
|
export class StackPool<TObject> implements IStackPool<TObject> { |
647✔ |
|
private readonly _objects: TObject[] = []
|
335✔ |
|
|
2✔ |
6 |
get objects(): ReadonlyArray<TObject> { |
|
|
return this._objects |
158,796✔ |
8 |
} |
|
9 |
|
|
10 |
get size() { |
|
|
return this._objects.length |
287✔ |
|
} |
2✔ |
13 |
|
|
|
get(): TObject { |
554✔ |
|
const lastIndex = this._objects.length - 1 |
7,988✔ |
|
if (lastIndex >= 0) { |
|
|
const obj = this._objects[lastIndex] |
7,268✔ |
|
this._objects.length = lastIndex
|
7,268✔ |
|
return obj
|
7,268✔ |
|
} |
15,736✔ |
|
return null
|
|
|
} |
14,313✔ |
|
|
14,313✔ |
|
release(obj: TObject) { |
14,313✔ |
|
if (obj == null) {
|
|
|
throw new Error('object should not be null') |
1,423✔ |
27 |
} |
|
|
this._objects.push(obj)
|
8,722✔ |
|
} |
|
|
} |
× |