Skip to content

Commit 6ede34e

Browse files
committed
Based on @chris-pardy suggestion using typeof because its more performant and reliable
1 parent ed0429c commit 6ede34e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/almanac.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export default class Almanac {
178178
* Interprets value as either a primitive, or if a fact, retrieves the fact value
179179
*/
180180
getValue (value) {
181-
if (Boolean(value instanceof Object) && Object.prototype.hasOwnProperty.call(value, 'fact')) { // value = { fact: 'xyz' }
181+
if (value != null && typeof value === 'object' && Object.prototype.hasOwnProperty.call(value, 'fact')) { // value = { fact: 'xyz' }
182182
return this.factValue(value.fact, value.params, value.path)
183183
}
184184
return Promise.resolve(value)

src/rule-result.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default class RuleResult {
1616
}
1717

1818
resolveEventParams (almanac) {
19-
if (this.event.params instanceof Object) {
19+
if (this.event.params !== null && typeof this.event.params === 'object') {
2020
const updates = []
2121
for (const key in this.event.params) {
2222
if (Object.prototype.hasOwnProperty.call(this.event.params, key)) {

0 commit comments

Comments
 (0)