![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
decision_table
Advanced tools
Simple implementation of Decision Tables (https://en.wikipedia.org/wiki/Decision_table).
Simple implementation of Decision Tables (https://en.wikipedia.org/wiki/Decision_table).
For Node.JS or bundlers (Wepback, Browserify):
# By NPM
npm i decision-table --save
# By Yarn
yarn add decision-table --save
For browser (compressed library at file lib/decision-table.js
):
<script src="path/to/decision-table.js"></script>
For Node.JS or bundlers you just need to import DecisionTable
class:
const {DecisionTable} = require('decision-table');
// or
import {DecisionTable} from 'decision-table';
In browsers you can get it from global variable:
window.dt.DecisionTable;
Creates new instance of Decision Table. No arguments.
Example:
var table = new window.dt.DecisionTable();
Static method which returns Decision Table constructor and returns
a previous value of window.dt
field.
Example:
window.mynamespace.DecisionTable = window.dt.DecisionTable.noConflict();
console.log(window.dt); // Must be a previous value now
In Node.JS this method just returns Decision Table constructor.
Instance method which adds new condition to table. If condition with this name was already added it will be overriden.
Arguments:
name
- string identifier of condition;func
- condition function, must have no arguments and return a boolean value;Example:
var A = true, B = false;
table.addCondition('A', function() { return A; });
table.addCondition('B', function() { return B; });
Removes condition from table. For any actions which requires condition with this name it will be automaticaly equals "false".
table.removeCondition('A');
table.removeCondition('B');
Adds new action to table. Argument action must be an object which contains fields:
whenTrue
- array of conditions names which must be a "true" to do action;whenFalse
- array of conditions names which must be a "false" to do action;execute
- action's body, code to execute on this action.If whenTrue
or whenFalse
will be both not defined or empty, action will
never be executed.
If one of actions in whenTrue
or whenFalse
is not defined in table
(or removed from it), action will never be executed.
Example:
table.addAction({
whenTrue: ['A'],
execute: function() {
console.log('Executed only if A is true');
}
});
table.addAction({
whenFalse: ['A'],
execute: function() {
console.log('Executed only if A is false');
}
});
table.addAction({
whenTrue: ['B'],
execute: function() {
console.log('Executed only if B is true');
}
});
table.addAction({
whenFalse: ['B'],
execute: function() {
console.log('Executed only if B is false');
}
});
table.addAction({
whenTrue: ['A', 'B'],
execute: function() {
console.log('Executed only if A and B are true');
}
});
table.addAction({
whenFalse: ['A', 'B'],
execute: function() {
console.log('Executed only if A and B are false');
}
});
table.addAction({
whenTrue: ['A'],
whenFalse: ['B'],
execute: function() {
console.log('Executed only if A is true and B is false');
}
});
table.addAction({
whenTrue: ['B'],
whenFalse: ['A'],
execute: function() {
console.log('Executed only if B is true and A is false');
}
});
Removes action from table. Please note, that this method just equals pointes to objects.
Check all conditions and execute all approved actions.
Example:
table.run();
var table = new window.dt.DecisionTable();
var A, B;
table.addCondition('A', function() { return A; });
table.addCondition('B', function() { return B; });
table.addAction({
whenTrue: ['A'],
execute: function() {
console.log('Executed only if A is true');
}
});
table.addAction({
whenFalse: ['A'],
execute: function() {
console.log('Executed only if A is false');
}
});
table.addAction({
whenTrue: ['B'],
execute: function() {
console.log('Executed only if B is true');
}
});
table.addAction({
whenFalse: ['B'],
execute: function() {
console.log('Executed only if B is false');
}
});
table.addAction({
whenTrue: ['A', 'B'],
execute: function() {
console.log('Executed only if A and B are true');
}
});
table.addAction({
whenFalse: ['A', 'B'],
execute: function() {
console.log('Executed only if A and B are false');
}
});
table.addAction({
whenTrue: ['A'],
whenFalse: ['B'],
execute: function() {
console.log('Executed only if A is true and B is false');
}
});
table.addAction({
whenTrue: ['B'],
whenFalse: ['A'],
execute: function() {
console.log('Executed only if B is true and A is false');
}
});
A = true;
B = true;
table.run();
A = false;
B = true;
table.run();
A = true;
B = false;
table.run();
A = false;
B = false;
table.run();
FAQs
Simple implementation of Decision Tables (https://en.wikipedia.org/wiki/Decision_table).
The npm package decision_table receives a total of 0 weekly downloads. As such, decision_table popularity was classified as not popular.
We found that decision_table demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.