Skip to content

Commit

Permalink
Fix a weird edge case where the returned result was null but it neede…
Browse files Browse the repository at this point in the history
…d to check if it was a function
  • Loading branch information
TotalTechGeek committed Jun 5, 2023
1 parent 025ecba commit 4d33fae
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion async.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ modes.forEach((logic) => {
)
}

if (engine.allowFunctions || typeof context[key] !== 'function') {
if (engine.allowFunctions || typeof (context && context[key]) !== 'function') {
if (!(key in context)) {
return new YieldStructure({
message: 'Data does not exist in context.'
Expand Down
4 changes: 2 additions & 2 deletions defaultMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const defaultMethods = {
}
const notFound = b === undefined ? null : b
if (typeof key === 'undefined' || key === '' || key === null) {
if (engine.allowFunctions || typeof context[key] !== 'function') {
if (engine.allowFunctions || typeof (context && context[key]) !== 'function') {
return context
}
return null
Expand All @@ -210,7 +210,7 @@ const defaultMethods = {
return notFound
}
}
if (engine.allowFunctions || typeof context[key] !== 'function') {
if (engine.allowFunctions || typeof (context && context[key]) !== 'function') {
return context
}
return null
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "json-logic-engine",
"version": "1.2.5",
"version": "1.2.6",
"description": "Construct complex rules with JSON & process them.",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion yieldingIterators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const yieldVar = (key, context, above, engine) => {
return new YieldStructure({ message: 'Data is not found.' })
}
}
if (engine.allowFunctions || typeof context[key] !== 'function') {
if (engine.allowFunctions || typeof (context && context[key]) !== 'function') {
return context
}
return null
Expand Down

0 comments on commit 4d33fae

Please sign in to comment.