DMN FEEL Parser and Interpreter

6.2.0 · active · verified Tue Apr 21

Feelin is a robust JavaScript library designed to parse and interpret FEEL (Friendly Enough Expression Language) expressions, a standard defined by DMN (Decision Model and Notation). It provides functions like `evaluate` and `unaryTest` for executing FEEL expressions against a given context. The current stable version is 6.2.0, with minor releases and dependency updates occurring regularly, indicating active maintenance. Key differentiators include its comprehensive recognition of the full FEEL grammar, context-sensitive evaluation (handling names with spaces), built-in FEEL functions, and a focus on error recovery with detailed warnings for issues such as `null` conversions. While not yet fully DMN TCK compliant, it aims for high fidelity to the standard, making it suitable for integrating DMN decision logic into JavaScript applications.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic usage of `evaluate` and `unaryTest` functions, including context passing, list iteration, and inspecting `warnings` for execution issues like undefined variables.

import { evaluate, unaryTest } from 'feelin';

// Evaluate a simple expression with a context
const result1 = evaluate("Mike's daughter.name", {
  'Mike\'s daughter.name': 'Lisa'
});
console.log('Expression evaluation:', result1.value); // Lisa

// Perform a unary test
const result2 = unaryTest('1', { '?': 1 });
console.log('Unary test 1:', result2.value); // true

const result3 = unaryTest('[1..end]', { '?': 1, end: 10 });
console.log('Unary test 2:', result3.value); // true

// Iterate and transform a list
const result4 = evaluate('for a in [1, 2, 3] return a * 2');
console.log('Loop evaluation:', result4.value); // [2, 4, 6]

// Check warnings for undefined variables or null conversions
const { value, warnings } = evaluate('x');
console.log('Undefined variable result:', value); // null
console.log('Warnings for undefined variable:', warnings);
/*
Output: [
  {
    message: "Variable 'x' not found",
    type: 'NO_VARIABLE_FOUND',
    position: { from: 0, to: 1 }
  }
]
*/

view raw JSON →