diff --git a/package.json b/package.json index 0322ee7..6929794 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/almanac.js b/src/almanac.js index 58cc243..610e280 100644 --- a/src/almanac.js +++ b/src/almanac.js @@ -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 }) @@ -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 @@ -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 (value != null && typeof value === 'object' && Object.prototype.hasOwnProperty.call(value, 'fact')) { // value = { fact: 'xyz' } return this.factValue(value.fact, value.params, value.path) } return Promise.resolve(value) diff --git a/src/rule-result.js b/src/rule-result.js index 5e1fcbd..09350c7 100644 --- a/src/rule-result.js +++ b/src/rule-result.js @@ -1,7 +1,6 @@ 'use strict' import deepClone from 'clone' -import isObject from 'lodash.isobjectlike' export default class RuleResult { constructor (conditions, event, priority, name) { @@ -17,7 +16,7 @@ export default class RuleResult { } resolveEventParams (almanac) { - if (isObject(this.event.params)) { + if (this.event.params !== null && typeof this.event.params === 'object') { const updates = [] for (const key in this.event.params) { if (Object.prototype.hasOwnProperty.call(this.event.params, key)) {