Simple port of /packer/ by Dean Edwards to node.js
Switch branches/tags
Nothing to show
Latest commit 394d870 Jul 13, 2017 @evanw committed on GitHub Update
Failed to load latest commit information.
.npmignore initial commit Jan 29, 2011 Update Jul 13, 2017
cli.js - nomnom API changed, update cli to parse options again Sep 22, 2011
package.json version bump May 10, 2015
packer.js initial commit Jan 29, 2011

⚠️ ⚠️ ⚠️ DO NOT USE THIS ⚠️ ⚠️ ⚠️

I threw this up on npm a long time ago but there are better options now. Packer appears to be unsupported and has bugs like this that cause it to generate invalid JavaScript. I recommend using a community-supported JavaScript minifier such as uglify instead. I'm only keeping this page up on GitHub because some packages likely depend on this package and may attempt to navigate here.


This is a simple port of /packer/ by Dean Edwards to node.js.


If you use npm:

npm install packer

If you don't use npm, clone this repository or download the latest version using the GitHub repository Downloads link.


This module contains one function called pack(script, base62, shrink):

> var packer = require('packer');
> packer.pack('1 + 2');
> packer.pack('', true);
'eval(function(p,a,c,k,e,r){e=String;if(!\'\'.replace(/^/,String)){while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return\'\\\\w+\'};c=1};while(c--)if(k[c])p=p.replace(new RegExp(\'\\\\b\'+e(c)+\'\\\\b\',\'g\'),k[c]);return p}(\'\',2,0,\'\'.split(\'|\'),0,{}))'

It also adds the packer command:

$ packer -h
usage: <script> [options]

-i FILE	Input file (default stdin)
-o FILE	Output file (default stdout)
-b	Base62 encode
-s	Shrink variables

$ echo 1 + a | packer -b
eval(function(p,a,c,k,e,r){e=String;if(!''.replace(/^/,String)){while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('1+0',2,2,'a|'.split('|'),0,{}))