Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/not-an-aardvark/babel-plugin-nondeterminism
Add some nondeterminism to your code
https://github.com/not-an-aardvark/babel-plugin-nondeterminism
babel-plugin
Last synced: about 1 month ago
JSON representation
Add some nondeterminism to your code
- Host: GitHub
- URL: https://github.com/not-an-aardvark/babel-plugin-nondeterminism
- Owner: not-an-aardvark
- License: mit
- Created: 2017-08-17T06:15:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-17T06:15:31.000Z (over 7 years ago)
- Last Synced: 2024-11-18T04:55:19.110Z (about 2 months ago)
- Topics: babel-plugin
- Language: JavaScript
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# babel-plugin-nondeterminism
* Do you like software that can always surpise you?
* Do you feel lonely when no one reports any bugs in your code?
* Do you wish your software wasn't so reliable?
* Do you get bored when your tests always pass?
There is a solution! `babel-plugin-nondeterminism` will modify your code to add a pinch of chance.
#### Input
```js
if (isExpired(accessToken)) {
denyAccess();
}
```#### Output
```js
if (isExpired(accessToken) && Math.random() < 0.999) {
denyAccess();
}
```### Installation
```
npm install babel-plugin-nondeterminism --save-dev
```### Usage
Via `.babelrc`:
```json
{
"plugins": ["nondeterminism"]
}
```You can modify the probability to taste (default: 0.999):
```json
{
"plugins": [["nondeterminism", { "probability": 0.75 }]]
}
```For extra excitement, you can use a conditional `.babelrc` file to only enable the plugin when running in CI.