https://github.com/anthonybudd/if
Chainable If syntax
https://github.com/anthonybudd/if
Last synced: 6 months ago
JSON representation
Chainable If syntax
- Host: GitHub
- URL: https://github.com/anthonybudd/if
- Owner: anthonybudd
- License: mit
- Created: 2022-10-05T18:39:39.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-10-05T19:03:48.000Z (almost 4 years ago)
- Last Synced: 2025-06-02T19:21:35.209Z (about 1 year ago)
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# If
A chainabale if library for JavaScript.
This is totally pointless, but I prefur chain syntax over control-structure syntax.
### Example
```js
const If = require('./index');
const myVar = (1 === 1);
const result = new If(myVar)
.then(() => ('True'))
.elseif((1 === 0), () => ('elesif 1'))
.else(() => ('False'))
.do();
console.log(result);
```
### Translation (control-structure syntax)
```js
const myVar = (1 === 1);
if (myVar) {
console.log('True');
} else if (1 === 0) {
console.log('elesif 1');
} else {
console.log('False');
}
```