0.0.8 • Published 6 months ago
conditionalize v0.0.8
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 conditionalize
Using yarn:
$ yarn add conditionalize
Using pnpm:
$ pnpm add conditionalize
You 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();
// => true
Constructor 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();
// => false
API
@TODO
Tests
Tests are using jest, to run the tests use:
$ npm run test
Coverage
Jest output coverage files to coverage
directory.
$ npm run coverage
License
This software is released under the terms of the MIT license.
0.0.8
6 months ago
0.0.7
6 months ago
0.0.6
6 months ago
0.0.5
1 year ago
0.0.5-alpha
1 year ago
0.0.4
1 year ago
0.0.3
1 year ago
0.0.3-alpha.0
1 year ago
0.0.3-alpha
1 year ago
0.0.2
1 year ago
0.0.1
1 year ago