Skip to content

Commit 7e96b94

Browse files
author
Cache Hamm
committed
build & changelog for 1.5.1
1 parent 6b2e92a commit 7e96b94

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.5.1 / 2017-03-19
2+
==================
3+
4+
* Bugfix almanac.factValue skipping interpreting condition "path" for cached facts
5+
16
1.5.0 / 2017-03-12
27
==================
38

dist/almanac.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var Almanac = function () {
3838
_classCallCheck(this, Almanac);
3939

4040
this.factMap = new Map(factMap);
41-
this.factResultsCache = new Map();
41+
this.factResultsCache = new Map(); // { cacheKey: Promise<factValu> }
4242

4343
for (var factId in runtimeFacts) {
4444
var fact = void 0;
@@ -131,33 +131,40 @@ var Almanac = function () {
131131
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(factId) {
132132
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
133133
var path = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
134-
var fact, cacheKey, cacheVal, factValue;
134+
var factValue, fact, cacheKey, cacheVal;
135135
return regeneratorRuntime.wrap(function _callee$(_context) {
136136
while (1) {
137137
switch (_context.prev = _context.next) {
138138
case 0:
139+
factValue = void 0;
139140
fact = this._getFact(factId);
140141
cacheKey = fact.getCacheKey(params);
141142
cacheVal = cacheKey && this.factResultsCache.get(cacheKey);
142143

143144
if (!cacheVal) {
144-
_context.next = 6;
145+
_context.next = 11;
145146
break;
146147
}
147148

148-
cacheVal.then(function (val) {
149-
return debug('almanac::factValue cache hit for fact:' + factId + ' value: ' + JSON.stringify(val) + '<' + (typeof val === 'undefined' ? 'undefined' : _typeof(val)) + '>');
150-
});
151-
return _context.abrupt('return', cacheVal);
149+
_context.next = 7;
150+
return cacheVal;
152151

153-
case 6:
152+
case 7:
153+
factValue = _context.sent;
154+
155+
debug('almanac::factValue cache hit for fact:' + factId + ' value: ' + JSON.stringify(factValue) + '<' + (typeof factValue === 'undefined' ? 'undefined' : _typeof(factValue)) + '>');
156+
_context.next = 15;
157+
break;
158+
159+
case 11:
154160
verbose('almanac::factValue cache miss for fact:' + factId + '; calculating');
155-
_context.next = 9;
161+
_context.next = 14;
156162
return this._setFactValue(fact, params, fact.calculate(params, this));
157163

158-
case 9:
164+
case 14:
159165
factValue = _context.sent;
160166

167+
case 15:
161168
if (path) {
162169
if (isPlainObject(factValue) || Array.isArray(factValue)) {
163170
factValue = selectn(path)(factValue);
@@ -168,7 +175,7 @@ var Almanac = function () {
168175
}
169176
return _context.abrupt('return', factValue);
170177

171-
case 12:
178+
case 17:
172179
case 'end':
173180
return _context.stop();
174181
}

0 commit comments

Comments
 (0)