Skip to content

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

License

Notifications You must be signed in to change notification settings

milworm/gulp-trim-fn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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).

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published