From f4c6eef2cd37f174cb5f41c6268ca09699718c58 Mon Sep 17 00:00:00 2001 From: Tissevert Date: Fri, 15 Jan 2021 11:11:26 +0100 Subject: [PATCH] Fix a bug in update and generalize the 'check' predicate to be a simple shorthand to bind the box into something --- src/UnitJS/Async/Box.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/UnitJS/Async/Box.js b/src/UnitJS/Async/Box.js index 839350d..f9edb3a 100644 --- a/src/UnitJS/Async/Box.js +++ b/src/UnitJS/Async/Box.js @@ -15,15 +15,15 @@ Box.prototype.set = function(newValue) { }.bind(this); }; -Box.prototype.check = function(predicate) { - return function(f) { - predicate(this.value)(f); - } +Box.prototype.use = function(f) { + return function(g) { + f(this.value)(g); + }.bind(this); }; Box.prototype.update = function(modifier) { return function(f) { - modifier(this.value)(function (newValue) {this.value = newValue; f()}); + modifier(this.value)(function (newValue) {this.value = newValue; f()}.bind(this)); }.bind(this); }; @@ -36,7 +36,7 @@ function make(initValue) { return { get: box.get.bind(box), set: box.set.bind(box), - check: box.check.bind(box), + use: box.use.bind(box), update: box.update.bind(box), }; }