-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task 3 #3
base: main
Are you sure you want to change the base?
Conversation
utils/EventEmitter.js
Outdated
} | ||
this.listeners[eventName] = this.listeners[eventName].filter((currFn)=>currFn !== fn); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в конце каждого файлик нужно составлять пустую строку. Даже гит значок добавляет. иногда нужно для совместимости , когда на разных средах разрабатывают. вообше можно в вижаке поставить, чтобы у тебя автоматически проставлялась он всегда
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не знала такого, спасибо большое! поправила
} | ||
|
||
_pushListener(eventName, fn){ | ||
if(typeof fn !== "function") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
классно, что проверила тип
if(!this.listeners[eventName]){ | ||
throw new Error("There is no such eventName!") | ||
} | ||
this.listeners[eventName] = this.listeners[eventName].filter((currFn)=>currFn !== fn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а нужно ли хранить listener, если у тебя не останется никаких обработчиков ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
упустила это, поправила
спасибо!
utils/EventEmitter.js
Outdated
|
||
once(eventName, fn) { | ||
const onceWrapper = (...args)=>{ | ||
this.off(eventName, onceWrapper); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
почему решила, сначала удалить, а потом выполнить функцию ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
даже не помню, наверное, подумала, что пока функция выполняется, листенер могут вызвать еще раз
лучше поменять местами?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
поменяла
utils/EventEmitter.js
Outdated
} | ||
|
||
listenerCount(eventName) { | ||
return this.listeners[eventName].length || 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.listeners[eventName] можно быть undefined ? если да, тогда при вызове length буде ошибка
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я почему-то думала, || 0;
в этом случае сработает
заменила
const end = new Date().getTime(); | ||
const time = (end - start)/1000; | ||
|
||
this.emit('end', time, result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
хорошо)
const key = headers[idx] || `field${idx+1}`; | ||
resultObj[key] = field; | ||
}); | ||
return JSON.stringify(resultObj); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
спасибо!
No description provided.