Skip to content

Commit

Permalink
Change the reduce function to evaluate the initial value, which lets …
Browse files Browse the repository at this point in the history
…us capture state for use in the logic function. (#118)
  • Loading branch information
ubik2 authored Jul 9, 2024
1 parent 9c805e9 commit b00a1d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ http://ricostacruz.com/cheatsheets/umdjs.html
} else if (op === "reduce") {
scopedData = jsonLogic.apply(values[0], data);
scopedLogic = values[1];
initial = typeof values[2] !== "undefined" ? values[2] : null;
initial = typeof values[2] !== "undefined" ? jsonLogic.apply(values[2], data) : null;

if ( ! Array.isArray(scopedData)) {
return initial;
Expand Down

0 comments on commit b00a1d8

Please sign in to comment.