https://github.com/streetstrider/secator
get rid of debug branches in JavaScript code
https://github.com/streetstrider/secator
Last synced: 4 months ago
JSON representation
get rid of debug branches in JavaScript code
- Host: GitHub
- URL: https://github.com/streetstrider/secator
- Owner: StreetStrider
- Created: 2014-12-08T16:22:27.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-12-08T17:52:35.000Z (over 11 years ago)
- Last Synced: 2024-12-30T23:47:25.448Z (over 1 year ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# secator
**secator** for JavaScript debug branches of code. Instead of having debug code and configuration variable which controls it — just remove all debug entries in production.
Consider the following code:
```javascript
function debug () {
// control this parameter in development
// to run `debug` or `release` branches
// or any other features
return true;
}
if (debug()) {
console.log('some debug code');
console.log('debug_run', +new Date);
} else {
app.feedback.log('some debug code');
}
```
Then run `secator file.js`. The `if` statement would be replaced with the only `else`-statement contents (if present).
```javascript
app.feedback.log('some debug code');
```
secator only works with `debug()` function and only in positive form (`!debug()` would not be transformed), which can be used to prevent false positive transformations.
This is a fun experiment comparing two different aproaches: feature-gates vs code transforming. The second one creates lower code footprint, but requires preprocessing of all files involved. It can be used as transformation step before minification and other build steps.