From d54c1bbf7f9fb5831fd7ab78f786b1de2829d1c2 Mon Sep 17 00:00:00 2001 From: Zaoqi Date: Sat, 11 May 2019 19:03:23 +0800 Subject: [PATCH 1/2] Allow lazy `message` --- assert.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/assert.js b/assert.js index a9aa6ad..1b5f308 100644 --- a/assert.js +++ b/assert.js @@ -130,6 +130,9 @@ assert.AssertionError = function AssertionError(options) { this.expected = options.expected; this.operator = options.operator; if (options.message) { + if (options.message instanceof Function) { + options.message = options.message(); + } this.message = options.message; this.generatedMessage = false; } else { From 3b3e8f551079278a0ad658a62f1dc518c74c5888 Mon Sep 17 00:00:00 2001 From: Zaoqi Date: Sat, 11 May 2019 21:59:13 +0800 Subject: [PATCH 2/2] Update assert.js Co-Authored-By: Jordan Harband --- assert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assert.js b/assert.js index 1b5f308..4e89129 100644 --- a/assert.js +++ b/assert.js @@ -130,7 +130,7 @@ assert.AssertionError = function AssertionError(options) { this.expected = options.expected; this.operator = options.operator; if (options.message) { - if (options.message instanceof Function) { + if (typeof options.message === 'function') { options.message = options.message(); } this.message = options.message;