Skip to content

Commit

Permalink
rename pureAssertion to assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
rcebulko committed Feb 22, 2021
1 parent a1c1d9a commit 3637025
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pure-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ export class UserError extends Error {
* @return {T}
* @throws {Error} when shouldBeTruthy is not truthy.
*/
function pureAssertion(errorCls, shouldBeTruthy, opt_message, var_args) {
// TODO: Support format strings.
function assertion(errorCls, shouldBeTruthy, opt_message, var_args) {
if (shouldBeTruthy) {
return shouldBeTruthy;
}

// Substitute provided values into format string in message
const message = Array.prototype.slice
// Skip the first 3 arguments to isolate format params
.call(arguments, 3)
.reduce(
(msg, subValue) => msg.replace('%s', subValue),
Expand Down Expand Up @@ -108,7 +108,7 @@ export function pureUserAssert(
opt_8,
opt_9
) {
return pureAssertion(
return assertion(
UserError,
shouldBeTruthy,
opt_message,
Expand Down Expand Up @@ -155,7 +155,7 @@ export function pureDevAssert(
opt_8,
opt_9
) {
return pureAssertion(
return assertion(
Error,
shouldBeTruthy,
opt_message,
Expand Down

0 comments on commit 3637025

Please sign in to comment.