@almadar/evaluator 2.15.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -997,17 +997,17 @@ function evalArrayEmpty(args, evaluate2, ctx) {
997
997
  }
998
998
  function evalArrayFirst(args, evaluate2, ctx) {
999
999
  const arr = evaluate2(args[0], ctx);
1000
- return arr?.[0];
1000
+ return arr?.[0] ?? null;
1001
1001
  }
1002
1002
  function evalArrayLast(args, evaluate2, ctx) {
1003
1003
  const arr = evaluate2(args[0], ctx);
1004
- if (!Array.isArray(arr) || arr.length === 0) return void 0;
1004
+ if (!Array.isArray(arr) || arr.length === 0) return null;
1005
1005
  return arr[arr.length - 1];
1006
1006
  }
1007
1007
  function evalArrayNth(args, evaluate2, ctx) {
1008
1008
  const arr = evaluate2(args[0], ctx);
1009
1009
  const index = evaluate2(args[1], ctx);
1010
- return arr?.[index];
1010
+ return arr?.[index] ?? null;
1011
1011
  }
1012
1012
  function evalArraySlice(args, evaluate2, ctx) {
1013
1013
  const arr = evaluate2(args[0], ctx);
@@ -1121,7 +1121,7 @@ function evalArrayIndexOf(args, evaluate2, ctx) {
1121
1121
  function evalArrayFind(args, evaluate2, ctx) {
1122
1122
  const arr = evaluate2(args[0], ctx);
1123
1123
  const predExpr = args[1];
1124
- return (arr ?? []).find((item, i) => evalWithItem(predExpr, evaluate2, ctx, item, i));
1124
+ return (arr ?? []).find((item, i) => evalWithItem(predExpr, evaluate2, ctx, item, i)) ?? null;
1125
1125
  }
1126
1126
  function evalArrayFindIndex(args, evaluate2, ctx) {
1127
1127
  const arr = evaluate2(args[0], ctx);