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

Layers: Scoring Algorithm #12958

Merged
merged 12 commits into from Jan 30, 2018
15 changes: 15 additions & 0 deletions src/log.js
Expand Up @@ -379,6 +379,21 @@ export class Log {
return /** @type {number} */ (shouldBeNumber);
}

/**
* Throws an error if the first argument isn't a boolean.
*
* For more details see `assert`.
*
* @param {*} shouldBeBoolean
* @param {string=} opt_message The assertion message
* @return {boolean} The boolean value.
*/
assertBoolean(shouldBeBoolean, opt_message) {
this.assert(!!shouldBeBoolean === shouldBeBoolean,

Choose a reason for hiding this comment

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

This is faster than typeof?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤷‍♂️

(opt_message || 'Boolean expected') + ': %s', shouldBeBoolean);
return /** @type {boolean} */ (shouldBeBoolean);
}

/**
* Asserts and returns the enum value. If the enum doesn't contain such a value,
* the error is thrown.
Expand Down