mirror of
https://github.com/BreizhHardware/memoizee.git
synced 2026-01-18 16:37:21 +01:00
docs: Outline that crashed invocations are not cached (#116)
This commit is contained in:
committed by
GitHub
parent
4335c5217d
commit
d8daddae37
@@ -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
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user