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

cc-runner

v0.1.1

Published

Closure Compiler Runner

Downloads

6

Readme

node-cc-runner

NPM Version

Client for Closure Compiler web runner.

Install

npm install cc-runner

Usage

const runner = require('cc-runner');
const compiler = runner();

compiler.start(err => {
  if (err) {
    console.error(err.stack);
    return;
  }

  compiler.status((err, res) => {
    console.log(err || res);
  });

  compiler.compile({
    optimizations: { level: "SIMPLE_OPTIMIZATIONS" },
    sources: [ {
      fileName: 'bar.js',
      code: '(console.log(function(){return 42-9;}));'
    } ]
  }, (err, res) => {
    console.log(err || res);
  });
});

Instantiation

Runner instance will automatically launch child process on first request (if jar option is not false) and kill after last response (after timeout period).

Options

  • jar - path to Closure Compiler web runner jar file (default: automatically downloaded cc-web-runner-standalone-1.0.8.jar).
  • url - Closure Compiler web runner service URL to be used in API calls (default: http://127.0.0.1:8081/).
  • timeout - timeout since last request after which web service is stopped (default: 100ms). If timeout is 0, then web service is not stopped automatically.
const runner = require('cc-runner');

// Custom Closure Compiler web runner build
const customCCWJar = runner({
  jar: '/path/to/cc-web-runner.jar',
  url: 'http://localhost:9080/'
});

customCCWJar.status((err, res) => {
  console.log('Status response from custom build');
  console.log(res);
});

// If Closure Compiler web runner is not already listening
// on 8080 port, start and stop methods will fail on this instance.
// `jar: false` option is useful when Closure Compiler web runner
// service is managed from outside of Node.js process,
// e.g. is running on servlet container.
const clientOnly = runner({
  jar: false,
  url: 'http://localhost:8080/'
});

start([callback])

Start Closure Compiler web runner service. Callback is called after the service started to listen for requests.

Callback arguments:

  • error

stop([callback])

Stop Closure Compiler web runner service.

status([options,] callback)

Options:

  • level String - is of type CompilationLevel, compilation level
  • debug Boolean - whether to call setDebugOptionsForCompilationLevel
  • typeBased Boolean - whether to call setTypeBasedOptimizationOptions
  • wrappedOutput Boolean - whether to call setWrappedOutputOptimizations

Callback arguments:

  • error
  • object
    • options Object - is of type CompilerOptions, compiler options
    • compilerVersions String - Closure Compiler version

externs(callback)

Callback arguments:

  • error
  • object
    • externs Array - is of type List<SourceFile>, array of extern files

compile(data, callback)

Data:

  • externs Array - [{ fileName: String, code: String }], array of extern files
  • sources Array - [{ fileName: String, code: String }], array of source files to compile
  • optimizations
    • level String - is of type CompilationLevel, compilation level
    • debug Boolean - whether to call setDebugOptionsForCompilationLevel
    • typeBased Boolean - whether to call setTypeBasedOptimizationOptions
    • wrappedOutput Boolean - whether to call setWrappedOutputOptimizations
  • options Object - is of type CompilerOptions, compiler options

Callback arguments:

  • error
  • object
    • result Object - is of type Result, compilations results
    • source String - compiled source
    • status String - SUCCESS|ERROR
    • message String - error message if status is 'ERROR'
    • exception Object - is of type Throwable, occurred exception

License

ISC