-
Notifications
You must be signed in to change notification settings - Fork 11
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
dz2 #7
base: master
Are you sure you want to change the base?
dz2 #7
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Возвращает объект Event | ||
* | ||
* @param {String} name Название события | ||
* @param {Number|Date} start Дата и время начала события | ||
* @param {Number|Date} end Дата и время окончания события | ||
* @param {String} destination Пункт назначения | ||
* @param {String} priority Важность события | ||
* @param {String} InfSource Источники информации о событии | ||
* @param {boolean} ready Событие состоялось? | ||
* | ||
* @example | ||
* Event("event", | ||
* new Date('2012-01-01T12:00:00'), | ||
* new Date('2012-01-01T14:00:00'), | ||
* "Earth", | ||
* "important", | ||
* "http://www.world-newspapers.com/science.html", | ||
* true) | ||
* | ||
* @return {Object} | ||
*/ | ||
function Event(name, start, end, destination, priority, InfSource, ready) { | ||
"use strict"; | ||
if (typeof start === "Date") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
В программировании есть хороший принцип лучше шире, чем глубже - те нужно избавляться от вложенных стейтментов и стараться спрямлять их. if (typeof start !== "number") {
throw new TypeError("error of start time format");
}
if (typeof end !== "number") {
// ....
}
... |
||
if (typeof end === "Date") { | ||
if (typeof ready === "boolean") { | ||
return { | ||
"name": name || "event", | ||
"start": +start || '2012-01-01T12:00:00', | ||
"end": +end || '2012-01-01T14:00:00', | ||
"destination": destination || "any place", | ||
"priority": priority || "no important", | ||
"InfSource": InfSource || "-", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. infSource |
||
"ready": ready || false | ||
}; | ||
} else { | ||
throw new TypeError("error of end time format"); | ||
} | ||
} else { | ||
throw new TypeError("error of start time format"); | ||
} | ||
} | ||
} |
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.
Слишком много аргументов - подумай как уменьшить.