Skip to content

Commit

Permalink
fix: use es2015 default params
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Strauß committed Jan 16, 2017
1 parent 911cfec commit 128e9a9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 45 deletions.
36 changes: 13 additions & 23 deletions lib/async/Completer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,25 @@ goog.require('goog.asserts');
clulib.async.Completer = function () {
/**
* @type {function((T|Promise<T>)=)}
* @private
*/
let resolve;
this.resolveFn_ = null;

/**
* @type {function(*=): void}
* @private
*/
let reject;
this.rejectFn_ = null;

/**
* @type {Promise<T>}
* @private
*/
this.promise_ = new Promise(function (rs, rj) {
resolve = rs;
reject = rj;
this.promise_ = new Promise((rs, rj) => {
this.resolveFn_ = rs;
this.rejectFn_ = rj;
});

/**
* @type {function((T|Promise<T>)=)}
* @private
*/
this.resolveFn_ = resolve;

/**
* @type {function(*=): void}
* @private
*/
this.rejectFn_ = reject;

/**
* @type {boolean}
* @private
Expand All @@ -55,20 +45,20 @@ clulib.async.Completer.prototype.getPromise = function () {
};

/**
* @param {(T|Promise<T>)=} opt_value
* @param {(T|Promise<T>)=} value
*/
clulib.async.Completer.prototype.resolve = function (opt_value) {
clulib.async.Completer.prototype.resolve = function (value = null) {
goog.asserts.assert(this.completed_ == false, 'Completer should not be completed more than once.');
this.resolveFn_(opt_value);
this.resolveFn_(value);
this.completed_ = true;
};

/**
* @param {*=} opt_reason
* @param {*=} reason
*/
clulib.async.Completer.prototype.reject = function (opt_reason) {
clulib.async.Completer.prototype.reject = function (reason = null) {
goog.asserts.assert(this.completed_ == false, 'Completer should not be completed more than once.');
this.rejectFn_(opt_reason);
this.rejectFn_(reason);
this.completed_ = true;
};

Expand Down
5 changes: 2 additions & 3 deletions lib/cm/ComponentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,10 @@ clulib.cm.ComponentManager.prototype.addComponentMap = function (map) {
};

/**
* @param {Element=} opt_rootElement
* @param {Element=} rootElement
* @returns {Promise}
*/
clulib.cm.ComponentManager.prototype.decorate = function (opt_rootElement) {
const rootElement = opt_rootElement || document.body;
clulib.cm.ComponentManager.prototype.decorate = function (rootElement = document.body) {
return this.nodeTree_.createTree(rootElement);
};

Expand Down
17 changes: 6 additions & 11 deletions lib/sdks/sdks.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ goog.require('goog.dom');
*
* For locales see {@link https://developers.facebook.com/docs/internationalization}
*
* @param {string=} opt_locale
* @param {string=} locale
* @returns {Promise}
*/
clulib.sdks.loadFacebookSdk = function (opt_locale) {
const locale = opt_locale || 'en_US';
clulib.sdks.loadFacebookSdk = function (locale = 'en_US') {
const fbObject = window['FB'];

if (fbObject != null)
Expand Down Expand Up @@ -44,16 +43,12 @@ clulib.sdks.loadFacebookSdk = function (opt_locale) {
*
* For locales see {@link https://developers.google.com/+/web/api/supported-languages}
*
* @param {string=} opt_pageId
* @param {string=} opt_locale
* @param {?string=} pageId
* @param {string=} locale
* @returns {Promise}
*/
clulib.sdks.loadGooglePlusSdk = function (opt_pageId, opt_locale) {
const locale = opt_locale || 'en-US';
let pageInfo = '';

if (opt_pageId != null)
pageInfo = '&publisherid=' + opt_pageId;
clulib.sdks.loadGooglePlusSdk = function (pageId = null, locale = 'en-US') {
let pageInfo = pageId != null ? '&publisherid=' + pageId : '';

const gapiObject = window['gapi'];
const initName = 'googAsyncInit';
Expand Down
12 changes: 4 additions & 8 deletions lib/ui/ToggleButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ clulib.ui.ToggleButton.prototype.setDisabled = function (value) {

/**
* @param {boolean} value
* @param {boolean=} opt_preventEvent
* @param {boolean=} preventEvent
*/
clulib.ui.ToggleButton.prototype.setChecked = function (value, opt_preventEvent) {
let preventEvent = opt_preventEvent || false;

clulib.ui.ToggleButton.prototype.setChecked = function (value, preventEvent = false) {
if (this.isChecked_ != value && !this.isDisabled()) {
this.isChecked_ = value;
goog.dom.classlist.enable(this.getElement(), clulib.ui.ToggleButton.CHECKED_CLASS, this.isChecked_);
Expand All @@ -92,10 +90,8 @@ clulib.ui.ToggleButton.prototype.setChecked = function (value, opt_preventEvent)
};

/**
* @param {boolean=} opt_preventEvent
* @param {boolean=} preventEvent
*/
clulib.ui.ToggleButton.prototype.toggle = function (opt_preventEvent) {
let preventEvent = opt_preventEvent || false;

clulib.ui.ToggleButton.prototype.toggle = function (preventEvent = false) {
this.setChecked(!this.isChecked_, preventEvent);
};

0 comments on commit 128e9a9

Please sign in to comment.