0.0.9 • Published 11 months ago
conditionalize v0.0.9
A library of conditions builder and validator.
Conditionalize based on idea & codes from sequelize Querying Where. And targets node.js and the browser.
Browser Support
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|---|---|---|---|---|---|
| Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | :x: |
Installation
Package manager
Using npm:
$ npm install conditionalizeUsing yarn:
$ yarn add conditionalizeUsing pnpm:
$ pnpm add conditionalizeYou can import the library using import or require approach:
// ES6
import Conditionalize from 'conditionalize';
const { Op } = Conditionalize;
const instance = new Conditionalize();
console.log(instance.check());If you use require, only default export is available:
// CommonJS
const Conditionalize = require('conditionalize');
const instance = new Conditionalize();
console.log(instance.check());Examples
Basic
import Conditionalize from 'conditionalize';
const instance = new Conditionalize();
instance.check();
// => trueConstructor With options
| Name | Type | Default | Description |
|---|---|---|---|
| dataSource | object | - | Input data that needs to check |
| where | object | - | Logical comparisons(and/or/not .etc) |
| operatorsMap | object | - | The map of operators |
| operatorsAliases | object | - | The alias of operators |
import Conditionalize from 'conditionalize';
const { Op } = Conditionalize;
const instance = new Conditionalize({
dataSource: {
authorId: 20,
rank: 2
},
where: {
authorId: {
[Op.gte]: 22
}
}
});
instance.check();
// => falseAPI
@TODO
Tests
Tests are using jest, to run the tests use:
$ npm run testCoverage
Jest output coverage files to coverage directory.
$ npm run coverageLicense
This software is released under the terms of the MIT license.
0.0.9
11 months ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
3 years ago
0.0.5-alpha
3 years ago
0.0.4
3 years ago
0.0.3
3 years ago
0.0.3-alpha.0
3 years ago
0.0.3-alpha
3 years ago
0.0.2
3 years ago
0.0.1
3 years ago





