Skip to content

Commit 4d33fae

Browse files
committed
Fix a weird edge case where the returned result was null but it needed to check if it was a function
1 parent 025ecba commit 4d33fae

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

async.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ modes.forEach((logic) => {
778778
)
779779
}
780780

781-
if (engine.allowFunctions || typeof context[key] !== 'function') {
781+
if (engine.allowFunctions || typeof (context && context[key]) !== 'function') {
782782
if (!(key in context)) {
783783
return new YieldStructure({
784784
message: 'Data does not exist in context.'

defaultMethods.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ const defaultMethods = {
194194
}
195195
const notFound = b === undefined ? null : b
196196
if (typeof key === 'undefined' || key === '' || key === null) {
197-
if (engine.allowFunctions || typeof context[key] !== 'function') {
197+
if (engine.allowFunctions || typeof (context && context[key]) !== 'function') {
198198
return context
199199
}
200200
return null
@@ -210,7 +210,7 @@ const defaultMethods = {
210210
return notFound
211211
}
212212
}
213-
if (engine.allowFunctions || typeof context[key] !== 'function') {
213+
if (engine.allowFunctions || typeof (context && context[key]) !== 'function') {
214214
return context
215215
}
216216
return null

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-logic-engine",
3-
"version": "1.2.5",
3+
"version": "1.2.6",
44
"description": "Construct complex rules with JSON & process them.",
55
"main": "./dist/cjs/index.js",
66
"module": "./dist/esm/index.js",

yieldingIterators.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const yieldVar = (key, context, above, engine) => {
3333
return new YieldStructure({ message: 'Data is not found.' })
3434
}
3535
}
36-
if (engine.allowFunctions || typeof context[key] !== 'function') {
36+
if (engine.allowFunctions || typeof (context && context[key]) !== 'function') {
3737
return context
3838
}
3939
return null

0 commit comments

Comments
 (0)