-
Notifications
You must be signed in to change notification settings - Fork 59
Кулешова Ирина #53
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
base: master
Are you sure you want to change the base?
Кулешова Ирина #53
Conversation
🍅 Не пройден линтинг или базовые тесты |
🍅 Не пройден линтинг или базовые тесты |
🍏 Пройдено тестов 9 из 9 |
off: function (event, context) { | ||
console.info(event, context); | ||
var eventsToOff = Object.keys(this._events).filter( | ||
function (key) { |
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.
давай переименуем key
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.
и еще эту строку можно к предыдущей приписать, так обычно пишут
function (key) { | ||
return key === event || | ||
(key.length > event.length && | ||
key.substr(0, event.length + 1) === event + '.'); |
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.
вроде из условий
(key.length > event.length && key.substr(0, event.length + 1) === event + '.')
достаточно написать последнее
key.substr(0, event.length + 1) === event + '.'); | ||
} | ||
); | ||
for (var i = 0; i < eventsToOff.length; i++) { |
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.
почему бы не использовать forEach
?
emit: function (event) { | ||
console.info(event); | ||
var events = getAllEvents(event).reverse(); | ||
for (var i = 0; i < events.length; i++) { |
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.
и тут вроде forEach
хорошо впишется, тогда не придется создавать новую переменную строчкой ниже
|
||
|
||
function getAllEvents(event) { | ||
var splitted = event.split('.'); |
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.
Название не отражает, что лежит в переменной
*/ | ||
emit: function (event) { | ||
console.info(event); | ||
var events = getAllEvents(event).reverse(); |
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.
если ты сплитишь event, а потом реверсишь, то почему бы сразу не пойти с конца?
); | ||
for (var i = 0; i < eventsToOff.length; i++) { | ||
this._events[eventsToOff[i]] = this._events[eventsToOff[i]].filter( | ||
function (item) { |
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.
тут item
переименовать надо
🍅 |
No description provided.