/
astafievk
/
source_code
Обзор
Документация
Войти
/
astafievk
/
source_code
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Api/node_modules/multer/lib/counter.js
28 строк
570 B
astafievK
source code
21 июн 2024, 21:02
21 июн 2024, 21:02
37a1d03
Код
Авторство
О чём код?
var EventEmitter = require('events').EventEmitter function Counter () { EventEmitter.call(this) this.value = 0 } Counter.prototype = Object.create(EventEmitter.prototype) Counter.prototype.increment = function increment () { this.value++ } Counter.prototype.decrement = function decrement () { if (--this.value === 0) this.emit('zero') } Counter.prototype.isZero = function isZero () { return (this.value === 0) } Counter.prototype.onceZero = function onceZero (fn) { if (this.isZero()) return fn() this.once('zero', fn) } module.exports = Counter