/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
lib/internal/freelist.js
30 строк
476 B
Rich Trott
http: remove unused hasItems() from freelist
04 дек 2019, 02:00
04 дек 2019, 02:00
ff2ed3e
Код
Авторство
О чём код?
'use strict'; const { ReflectApply, } = primordials; class FreeList { constructor(name, max, ctor) { this.name = name; this.ctor = ctor; this.max = max; this.list = []; } alloc() { return this.list.length > 0 ? this.list.pop() : ReflectApply(this.ctor, this, arguments); } free(obj) { if (this.list.length < this.max) { this.list.push(obj); return true; } return false; } } module.exports = FreeList;