Skip to content

Commit a74cb51

Browse files
authored
Merge pull request #377 from trkic-zeiss/fix/remove-ladash-isobjectlike
Remove lodash.isobjectlike package
2 parents 194ebdb + 6ede34e commit a74cb51

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
"clone": "^2.1.2",
9090
"eventemitter2": "^6.4.4",
9191
"hash-it": "^6.0.0",
92-
"jsonpath-plus": "^7.2.0",
93-
"lodash.isobjectlike": "^4.0.0"
92+
"jsonpath-plus": "^7.2.0"
9493
}
9594
}

src/almanac.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { UndefinedFactError } from './errors'
55
import debug from './debug'
66

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

109
function defaultPathResolver (value, path) {
1110
return JSONPath({ path, json: value, wrap: false })
@@ -161,7 +160,7 @@ export default class Almanac {
161160
debug(`condition::evaluate extracting object property ${path}`)
162161
return factValuePromise
163162
.then(factValue => {
164-
if (isObjectLike(factValue)) {
163+
if (factValue != null && typeof factValue === 'object') {
165164
const pathValue = this.pathResolver(factValue, path)
166165
debug(`condition::evaluate extracting object property ${path}, received: ${JSON.stringify(pathValue)}`)
167166
return pathValue
@@ -179,7 +178,7 @@ export default class Almanac {
179178
* Interprets value as either a primitive, or if a fact, retrieves the fact value
180179
*/
181180
getValue (value) {
182-
if (isObjectLike(value) && 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' }
183182
return this.factValue(value.fact, value.params, value.path)
184183
}
185184
return Promise.resolve(value)

src/rule-result.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict'
22

33
import deepClone from 'clone'
4-
import isObject from 'lodash.isobjectlike'
54

65
export default class RuleResult {
76
constructor (conditions, event, priority, name) {
@@ -17,7 +16,7 @@ export default class RuleResult {
1716
}
1817

1918
resolveEventParams (almanac) {
20-
if (isObject(this.event.params)) {
19+
if (this.event.params !== null && typeof this.event.params === 'object') {
2120
const updates = []
2221
for (const key in this.event.params) {
2322
if (Object.prototype.hasOwnProperty.call(this.event.params, key)) {

0 commit comments

Comments
 (0)