Skip to content
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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Task 3 #3

wants to merge 11 commits into from

Conversation

kandalova
Copy link
Owner

No description provided.

}
this.listeners[eventName] = this.listeners[eventName].filter((currFn)=>currFn !== fn);
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в конце каждого файлик нужно составлять пустую строку. Даже гит значок добавляет. иногда нужно для совместимости , когда на разных средах разрабатывают. вообше можно в вижаке поставить, чтобы у тебя автоматически проставлялась он всегда

Copy link
Owner Author

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") {

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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а нужно ли хранить listener, если у тебя не останется никаких обработчиков ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

упустила это, поправила
спасибо!


once(eventName, fn) {
const onceWrapper = (...args)=>{
this.off(eventName, onceWrapper);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

почему решила, сначала удалить, а потом выполнить функцию ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

даже не помню, наверное, подумала, что пока функция выполняется, листенер могут вызвать еще раз
лучше поменять местами?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

поменяла

}

listenerCount(eventName) {
return this.listeners[eventName].length || 0;

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 буде ошибка

Copy link
Owner Author

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);

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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super!

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

спасибо!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants