Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
"clone": "^2.1.2",
"eventemitter2": "^6.4.4",
"hash-it": "^6.0.0",
"jsonpath-plus": "^7.2.0",
"lodash.isobjectlike": "^4.0.0"
"jsonpath-plus": "^7.2.0"
}
}
5 changes: 2 additions & 3 deletions src/almanac.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { UndefinedFactError } from './errors'
import debug from './debug'

import { JSONPath } from 'jsonpath-plus'
import isObjectLike from 'lodash.isobjectlike'

function defaultPathResolver (value, path) {
return JSONPath({ path, json: value, wrap: false })
Expand Down Expand Up @@ -161,7 +160,7 @@ export default class Almanac {
debug(`condition::evaluate extracting object property ${path}`)
return factValuePromise
.then(factValue => {
if (isObjectLike(factValue)) {
if (factValue != null && typeof factValue === 'object') {
const pathValue = this.pathResolver(factValue, path)
debug(`condition::evaluate extracting object property ${path}, received: ${JSON.stringify(pathValue)}`)
return pathValue
Expand All @@ -179,7 +178,7 @@ export default class Almanac {
* Interprets value as either a primitive, or if a fact, retrieves the fact value
*/
getValue (value) {
if (isObjectLike(value) && Object.prototype.hasOwnProperty.call(value, 'fact')) { // value = { fact: 'xyz' }
if (Boolean(value instanceof Object) && Object.prototype.hasOwnProperty.call(value, 'fact')) { // value = { fact: 'xyz' }
return this.factValue(value.fact, value.params, value.path)
}
return Promise.resolve(value)
Expand Down
3 changes: 1 addition & 2 deletions src/rule-result.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

import deepClone from 'clone'
import isObject from 'lodash.isobjectlike'

export default class RuleResult {
constructor (conditions, event, priority, name) {
Expand All @@ -17,7 +16,7 @@ export default class RuleResult {
}

resolveEventParams (almanac) {
if (isObject(this.event.params)) {
if (this.event.params instanceof Object) {
const updates = []
for (const key in this.event.params) {
if (Object.prototype.hasOwnProperty.call(this.event.params, key)) {
Expand Down