Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anthonybudd/if
Chainable If syntax
https://github.com/anthonybudd/if
Last synced: 6 days 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 (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-05T19:03:48.000Z (about 2 years ago)
- Last Synced: 2024-11-07T16:12:04.775Z (about 2 months 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');
}
```