business-logics
A library to query business logics via truth table.
Business logics could be hardest parts to manage in a software when they are too complicated. Writing so many if-else block doesn't help usually too. But there is many simple solution to detech business logics and application behavior which is Truth Table.
You might see a simple truth table in following lines;
is_logged_in | is_admin | read_permission | write_permission |
---|---|---|---|
true | false | true | false |
true | true | true | true |
With this library, business-logics, you might define your business logics as truth tables and query them whenever you need.
You don't have to write if-else blocks anymore.
🔧 Installation
$ yarn add business-logics
📖 Basic Usage
It is easy to use;
const logics = parameters: 'is_logged_in' 'is_admin' results: read: default: false write: default: false data: // is_logged is_admin read write //-------------------------------------- true false true false true true true true const status = logics console
These are following result of a query;
If there is not any truth table definition for your query, you'll get your default values. So that you don't have to write all possible values for parameters.
🚀 VueJS Example
You might review simple usage for a VueJS application in following code;
{ return map: parameters: 'is_logged_in' 'is_admin' results: read: default: false write: default: false data: // is_logged is_admin read write //-------------------------------------- true false true false true true true true isLoggedIn: true isAdmin: false logics: null } { thislogics = thismap } computed: { if !thislogics return {} return thislogics }
In this example, you can calculate the statuses of business logic with your truth table.