babel-preset-unminify
make minified code more readable.
Last updated 2 years ago by goto-bus-stop .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-preset-unminify 
SYNC missed versions from official npm registry.

babel-preset-unminify

make minified code more readable.

npm travis standard

Install

npm install babel-preset-unminify

Example

Input:

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.dlv=n()}(this,function(){return function(e,n,t,o){for(o=0,n=n.split?n.split("."):n;e&&o<n.length;)e=e[n[o++]];return void 0===e||o<n.length?t:e}});
//# sourceMappingURL=dlv.umd.js.map

Output:

!(function(freci, iliet) {
  if ('object' == typeof exports && 'undefined' != typeof module) {
    module.exports = iliet()
  } else if ('function' == typeof define && define.amd) {
    define(iliet)
  } else {
    freci.dlv = iliet()
  }
})(this, function() {
  return function(habuk, hodoy, bedat, quetif) {
    quetif = 0
    for (hodoy = hodoy.split ? hodoy.split('.') : hodoy; habuk && quetif < hodoy.length; ) {
      habuk = habuk[hodoy[quetif++]]
    }
    if (void 0 === habuk || quetif < hodoy.length) {
      return bedat
    } else {
      return habuk
    }
  }
})

Usage

Unlike other Babel presets, this one should normally not be used with a Babel config file. Instead, use the included CLI:

npx babel-preset-unminify < input.min.js > formatted.js

Or use it via the Babel Node API:

var babel = require('@babel/core')
var unminify = require('babel-preset-unminify')

babel.transformSync(sourceCode, {
  presets: [unminify]
})

Options

For each option, the -- version is the CLI syntax, and the name: val is the Node API syntax.

--no-words, words: false

Disable phonetic variable name generation. By default this preset finds mangled variable names (3 characters or less) and generates unique names for them. Minifiers often reuse single-character names. This option allows easily manually renaming variables afterwards, using a simple search/replace over entire files at a time. If the source code doesn't use variable name mangling or something you can disable the words option.

License

Apache-2.0

Current Tags

  • 0.1.2                                ...           latest (2 years ago)

3 Versions

  • 0.1.2                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |