Git Product home page Git Product logo

packer's Introduction

⚠️ ⚠️ ⚠️ 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.

packer.js

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

Installation

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.

Usage

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

> var packer = require('packer');
> packer.pack('1 + 2');
'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]

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,{}))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.