npm.io
1.1.6 • Published 10 years ago

gulp-trim-fn

Licence
ISC
Version
1.1.6
Deps
5
Vulns
0
Weekly
0
Stars
6

Gulp module to trim private methods/properties in JS files.

gulp-trim-fn

Introduction

gulp-trim-fn is a small gulp module that obfuscates private functions/properties (with "_"-prefix in their names) in js files (babel-generated code is supported) in order to protect your code.

Support

Installation
npm install gulp-trim-fn --save-dev
Usage
const gulp = require('gulp');
const trimFn = require('gulp-trim-fn');

gulp.task('trim-fn', () => {
  return gulp.src('./src/**/*.js')
    .pipe(trimFn())
    .pipe(gulp.dest('./lib/'));
});
Example

Before:

function SideBar() {}
SideBar.prototype = {
  render: function() {
    var data = this._getRenderData();
    document.body.innerHTML = this._getTpl().apply(data);
  },
  _getTpl: function() {},
  _getRenderData: function() {},
  _getElement: function() {}
}

After:

function SideBar() {}
SideBar.prototype = {
  render: function() {
    var data = this.a1();
    document.body.innerHTML = this.a2().apply(data);
  },
  a2: function() {},
  a1: function() {},
  a3: function() {}
}
Authors and Contributors

Created in 2016 by Ruslan Prytula (@milworm).

Keywords