npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

uglify-lite

v2017.2.19

Published

this zero-dependency package will provide a browser-compatible version of the uglifyjs v1.3.5 javascript-minifier

Downloads

10

Readme

uglifyjs-lite

this zero-dependency package will provide a browser-compatible version of the uglifyjs v1.3.5 javascript-minifier

travis-ci.org build-status istanbul-coverage

NPM

package-listing

cdn download

live demo

github.com test-server

documentation

api-doc

api-doc

todo

  • none

change since e0235d04

  • npm publish 2017.2.19
  • create published-alias uglify-lite
  • replace env var npm_package_name with npm_package_nameAlias in istanbul code-coverage
  • none

this package requires

  • darwin or linux os

additional info

  • uglifyjs code derived from https://github.com/mishoo/UglifyJS/tree/v1.3.5

build status travis-ci.org build-status

build commit status

| git-branch : | master | beta | alpha| |--:|:--|:--|:--| | test-server-1 : | github.com test-server | github.com test-server | github.com test-server| | test-server-2 : | heroku.com test-server | heroku.com test-server | heroku.com test-server| | test-report : | test-report | test-report | test-report| | coverage : | istanbul-coverage | istanbul-coverage | istanbul-coverage| | build-artifacts : | build-artifacts | build-artifacts | build-artifacts|

master branch

  • stable branch
  • HEAD should be tagged, npm-published package

beta branch

  • semi-stable branch
  • HEAD should be latest, npm-published package

alpha branch

  • unstable branch
  • HEAD is arbitrary
  • commit history may be rewritten

quickstart web example

screen-capture

to run this example, follow the instruction in the script below

/*
example.js

this script will demo the browser-version of uglifyjs

instruction
    1. save this script as example.js
    2. run the shell command:
        $ npm install uglifyjs-lite && PORT=8081 node example.js
    3. play with the browser-demo on http://127.0.0.1:8081
*/



/* istanbul instrument in package uglifyjs */
/*jslint
    bitwise: true,
    browser: true,
    maxerr: 8,
    maxlen: 96,
    node: true,
    nomen: true,
    regexp: true,
    stupid: true
*/
(function () {
    'use strict';
    var local;



    // run shared js-env code - pre-init
    (function () {
        // init local
        local = {};
        // init modeJs
        local.modeJs = (function () {
            try {
                return typeof navigator.userAgent === 'string' &&
                    typeof document.querySelector('body') === 'object' &&
                    typeof XMLHttpRequest.prototype.open === 'function' &&
                    'browser';
            } catch (errorCaughtBrowser) {
                return module.exports &&
                    typeof process.versions.node === 'string' &&
                    typeof require('http').createServer === 'function' &&
                    'node';
            }
        }());
        // init global
        local.global = local.modeJs === 'browser'
            ? window
            : global;
        // init utility2_rollup
        local = local.global.utility2_rollup || (local.modeJs === 'browser'
            ? local.global.utility2_uglifyjs
            : require('uglifyjs-lite'));
        // export local
        local.global.local = local;
    }());
    switch (local.modeJs) {



    // post-init
    /* istanbul ignore next */
    // run browser js-env code - post-init
    case 'browser':
        local.testRunBrowser = function (event) {
            switch (event.currentTarget.id) {
            case 'testRunButton1':
                // show tests
                if (document.querySelector('#testReportDiv1').style.display === 'none') {
                    document.querySelector('#testReportDiv1').style.display = 'block';
                    document.querySelector('#testRunButton1').innerText = 'hide internal test';
                    local.modeTest = true;
                    local.testRunDefault(local);
                // hide tests
                } else {
                    document.querySelector('#testReportDiv1').style.display = 'none';
                    document.querySelector('#testRunButton1').innerText = 'run internal test';
                }
                break;
            default:
                // reset stdout
                document.querySelector('#outputTextareaStdout1').value = '';
                // try to uglify and eval input-code
                try {
                    /*jslint evil: true*/
                    document.querySelector('#outputTextarea1').value = '';
                    document.querySelector('#outputTextarea1').value = local.uglifyjs.uglify(
                        document.querySelector('#inputTextarea1').value,
                        'inputTextarea1.js'
                    );
                    eval(document.querySelector('#outputTextarea1').value);
                } catch (errorCaught) {
                    console.error(errorCaught.stack);
                }
                // scroll stdout to bottom
                document.querySelector('#outputTextareaStdout1').scrollTop =
                    document.querySelector('#outputTextareaStdout1').scrollHeight;
            }
        };
        // log stderr and stdout to #outputTextareaStdout1
        ['error', 'log'].forEach(function (key) {
            console['_' + key] = console[key];
            console[key] = function () {
                console['_' + key].apply(console, arguments);
                (document.querySelector('#outputTextareaStdout1') || { value: '' }).value +=
                    Array.from(arguments).map(function (arg) {
                        return typeof arg === 'string'
                            ? arg
                            : JSON.stringify(arg, null, 4);
                    }).join(' ') + '\n';
            };
        });
        // init event-handling
        ['change', 'click', 'keyup'].forEach(function (event) {
            Array.from(document.querySelectorAll('.on' + event)).forEach(function (element) {
                element.addEventListener(event, local.testRunBrowser);
            });
        });
        // run tests
        local.testRunBrowser({ currentTarget: { id: 'default' } });
        break;



    /* istanbul ignore next */
    // run node js-env code - post-init
    case 'node':
        // export local
        module.exports = local;
        // require modules
        local.fs = require('fs');
        local.http = require('http');
        local.url = require('url');
        // init assets
        local.assetsDict = local.assetsDict || {};
        /* jslint-ignore-begin */
        local.assetsDict['/assets.index.template.html'] = '\
<!doctype html>\n\
<html lang="en">\n\
<head>\n\
<meta charset="UTF-8">\n\
<meta name="viewport" content="width=device-width, initial-scale=1">\n\
<title>{{env.npm_package_nameAlias}} v{{env.npm_package_version}}</title>\n\
<style>\n\
/*csslint\n\
    box-sizing: false,\n\
    universal-selector: false\n\
*/\n\
* {\n\
    box-sizing: border-box;\n\
}\n\
body {\n\
    background: #dde;\n\
    font-family: Arial, Helvetica, sans-serif;\n\
    margin: 2rem;\n\
}\n\
body > * {\n\
    margin-bottom: 1rem;\n\
}\n\
</style>\n\
<style>\n\
/*csslint\n\
*/\n\
textarea {\n\
    font-family: monospace;\n\
    height: 10rem;\n\
    width: 100%;\n\
}\n\
textarea[readonly] {\n\
    background: #ddd;\n\
}\n\
</style>\n\
</head>\n\
<body>\n\
<!-- utility2-comment\n\
    <div id="ajaxProgressDiv1" style="background: #d00; height: 2px; left: 0; margin: 0; padding: 0; position: fixed; top: 0; transition: background 0.5s, width 1.5s; width: 25%;"></div>\n\
utility2-comment -->\n\
    <h1>\n\
<!-- utility2-comment\n\
        <a\n\
            {{#if env.npm_package_homepage}}\n\
            href="{{env.npm_package_homepage}}"\n\
            {{/if env.npm_package_homepage}}\n\
            target="_blank"\n\
        >\n\
utility2-comment -->\n\
            {{env.npm_package_nameAlias}} v{{env.npm_package_version}}\n\
<!-- utility2-comment\n\
        </a>\n\
utility2-comment -->\n\
    </h1>\n\
    <h3>{{env.npm_package_description}}</h3>\n\
<!-- utility2-comment\n\
    <h4><a download href="assets.app.js">download standalone app</a></h4>\n\
    <button class="onclick" id="testRunButton1">run internal test</button><br>\n\
    <div id="testReportDiv1" style="display: none;"></div>\n\
utility2-comment -->\n\
\n\
    <label>edit or paste script below to cover and eval</label>\n\
<textarea class="onkeyup" id="inputTextarea1">\n\
var aa;\n\
aa = "hello";\n\
console.log(aa);\n\
console.log(null);\n\
</textarea>\n\
    <label>uglified-code</label>\n\
    <textarea id="outputTextarea1" readonly></textarea>\n\
    <label>stderr and stdout</label>\n\
    <textarea id="outputTextareaStdout1" readonly></textarea>\n\
<!-- utility2-comment\n\
    {{#if isRollup}}\n\
    <script src="assets.app.js"></script>\n\
    {{#unless isRollup}}\n\
utility2-comment -->\n\
    <script src="assets.utility2.rollup.js"></script>\n\
    <script src="jsonp.utility2._stateInit?callback=window.utility2._stateInit"></script>\n\
    <script src="assets.uglifyjs.rollup.js"></script>\n\
    <script src="assets.example.js"></script>\n\
    <script src="assets.test.js"></script>\n\
<!-- utility2-comment\n\
    {{/if isRollup}}\n\
utility2-comment -->\n\
</body>\n\
</html>\n\
';
        /* jslint-ignore-end */
        if (local.templateRender) {
            local.assetsDict['/'] = local.templateRender(
                local.assetsDict['/assets.index.template.html'],
                {
                    env: local.objectSetDefault(local.env, {
                        npm_package_description: 'example module',
                        npm_package_nameAlias: 'example',
                        npm_package_version: '0.0.1'
                    })
                }
            );
        } else {
            local.assetsDict['/'] = local.assetsDict['/assets.index.template.html']
                .replace((/\{\{env\.(\w+?)\}\}/g), function (match0, match1) {
                    // jslint-hack
                    String(match0);
                    switch (match1) {
                    case 'npm_package_description':
                        return 'example module';
                    case 'npm_package_nameAlias':
                        return 'example';
                    case 'npm_package_version':
                        return '0.0.1';
                    }
                });
        }
        // run the cli
        if (local.global.utility2_rollup || module !== require.main) {
            break;
        }
        local.assetsDict['/assets.example.js'] = local.assetsDict['/assets.example.js'] ||
            local.fs.readFileSync(__filename, 'utf8');
        local.assetsDict['/assets.uglifyjs.rollup.js'] =
            local.assetsDict['/assets.uglifyjs.rollup.js'] || local.fs.readFileSync(
                local.uglifyjs.__dirname + '/lib.uglifyjs.js',
                'utf8'
            ).replace((/^#!/), '//');
        local.assetsDict['/favicon.ico'] = local.assetsDict['/favicon.ico'] || '';
        // if $npm_config_timeout_exit exists,
        // then exit this process after $npm_config_timeout_exit ms
        if (Number(process.env.npm_config_timeout_exit)) {
            setTimeout(process.exit, Number(process.env.npm_config_timeout_exit));
        }
        // start server
        if (local.global.utility2_serverHttp1) {
            break;
        }
        process.env.PORT = process.env.PORT || '8081';
        console.log('server starting on port ' + process.env.PORT);
        local.http.createServer(function (request, response) {
            request.urlParsed = local.url.parse(request.url);
            if (local.assetsDict[request.urlParsed.pathname] !== undefined) {
                response.end(local.assetsDict[request.urlParsed.pathname]);
                return;
            }
            response.statusCode = 404;
            response.end();
        }).listen(process.env.PORT);
        break;
    }
}());

output from electron

screen-capture

output from shell

screen-capture

package.json

{
    "author": "kai zhu <[email protected]>",
    "bin": {
        "uglifyjs-lite": "lib.uglifyjs.js"
    },
    "description": "this zero-dependency package will provide a browser-compatible version of the uglifyjs v1.3.5 javascript-minifier",
    "devDependencies": {
        "electron-lite": "kaizhu256/node-electron-lite#alpha",
        "utility2": "kaizhu256/node-utility2#alpha"
    },
    "engines": {
        "node": ">=4.0"
    },
    "homepage": "https://github.com/kaizhu256/node-uglifyjs-lite",
    "keywords": [
        "browser",
        "minify",
        "obfuscate",
        "uglify",
        "uglifyjs"
    ],
    "license": "MIT",
    "main": "lib.uglifyjs.js",
    "name": "uglifyjs-lite",
    "nameAlias": "uglifyjs",
    "nameOriginal": "uglifyjs-lite",
    "os": [
        "darwin",
        "linux"
    ],
    "repository": {
        "type": "git",
        "url": "https://github.com/kaizhu256/node-uglifyjs-lite.git"
    },
    "scripts": {
        "build-ci": "utility2 shRun shReadmeBuild",
        "heroku-postbuild": "npm install 'kaizhu256/node-utility2#alpha' && utility2 shRun shDeployHeroku",
        "postinstall": "if [ -f lib.uglifyjs-lite.npm-scripts.sh ]; then ./lib.uglifyjs-lite.npm-scripts.sh postinstall; fi",
        "publish-alias": "for ALIAS in uglify-lite; do utility2 shRun shNpmPublish $ALIAS; utility2 shRun shNpmTestPublished $ALIAS || exit $?; done",
        "start": "export PORT=${PORT:-8080} && export npm_config_mode_auto_restart=1 && utility2 shRun shIstanbulCover test.js",
        "test": "export PORT=$(utility2 shServerPortRandom) && utility2 test test.js"
    },
    "version": "2017.2.19"
}

changelog of last 50 commits

screen-capture

internal build-script

  • build.sh
# build.sh

# this shell script will run the build for this package

shBuild() {(set -e
# this function will run the main build
    # init env
    . node_modules/.bin/utility2 && shInit
    # cleanup github-gh-pages dir
    # export BUILD_GITHUB_UPLOAD_PRE_SH="rm -fr build"
    # init github-gh-pages commit-limit
    export COMMIT_LIMIT=20
    case "$CI_BRANCH" in
    alpha)
        shBuildCiDefault
        ;;
    beta)
        shBuildCiDefault
        ;;
    master)
        shBuildCiDefault
        ;;
    esac
)}

shBuildCiTestPost() {(set -e
# this function will run the post-test build
    # if running legacy-node, then return
    [ "$(node --version)" \< "v7.0" ] && return || true
    export NODE_ENV=production
    # deploy app to gh-pages
    (export MODE_BUILD=deployGithub && shDeployGithub) || return $?
    # deploy app to heroku
    (export MODE_BUILD=deployHeroku && shDeployHeroku) || return $?
)}

shBuildCiTestPre() {(set -e
# this function will run the pre-test build
    # test example.js
    (export MODE_BUILD=testExampleJs && shRunScreenCapture shReadmeTestExampleJs) || return $?
    # test published-package
    (export MODE_BUILD=npmTestPublished && shRunScreenCapture shNpmTestPublished) || return $?
)}

shBuild