docs: Outline that crashed invocations are not cached (#116)

This commit is contained in:
Thodoris Greasidis
2020-11-23 10:41:57 +02:00
committed by GitHub
parent 4335c5217d
commit d8daddae37
2 changed files with 26 additions and 0 deletions

View File

@@ -52,6 +52,8 @@ memoized("foo", 3, "bar");
memoized("foo", 3, "bar"); // Cache hit
```
__Note__: Invocations that throw exceptions are not cached.
### Configuration
All below options can be applied in any combination

View File

@@ -105,6 +105,30 @@ module.exports = function (t, a) {
}
};
},
"Error": function () {
var i = 0,
e = new Error("Test"),
fn = function () {
++i;
if (i < 3) throw e;
return 3;
};
fn = t(fn);
a.throws(function () {
fn();
}, "Test");
a(i, 1, "Called once");
a.throws(function () {
fn();
}, "Test");
a(i, 2, "Called twice");
a(fn(), 3, "First");
a(fn(), 3, "Second");
a(fn(), 3, "Third");
a(i, 3, "Called three times");
},
"Normalizer function": function () {
var i = 0,
fn = function () {