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

tern-closure

v0.1.3

Published

A Tern plugin adding support for Closure.

Downloads

6

Readme

tern-closure

tern-closure is a plugin which adds support for Closure Compiler annotations and the Closure Library to the Javascript code intelligence system Tern.

Installation

Currently, tern-closure only works with the NodeJS Tern Server, and not within a browser.

The easiest way to install tern-closure is to use a recent version of npm. In the directory where you installed the tern package, simply run

$ npm install tern-closure

Configuration

In order for Tern to load the tern-closure plugin once it is installed, you must include closure in the plugins section of your Tern configuration file. You must also explicitly disable the default doc_comment plugin, which will interfere with tern-closure.

Here is a minimal example .tern-project configuration file:

{
  "plugins": {
    "doc_comment": false,
    "closure": {}
  }
}

Options

  • finder Configuration for finding the files that provide types. See Finders below. Optional. Default: None.
  • debug Whether tern-closure should print debug output. Optional. Default: Match Tern debug option.

Finders

tern-closure uses "finders" to find the files providing Closure names via goog.provide. Finders allow tern-closure to load and interpret the files providing names required via goog.require or referenced in JSDoc type strings so it better understands the context of a given file.

The finder section of the options object for closure in your .tern-project file specifies what finder implementation you want to use, and what options you want to pass to the finder. By default, no finder is used, and files are not automatically loaded. Currently, only one finder implementation is included with tern-closure, grep.

Common finder options:

  • name The name of the finder you want to use. Required.
  • debug Whether the finder should print debug output. Optional. Default: Match tern-closure debug option.

grep

grep is a basic finder which uses the grep command-line utility to search for goog.provide statements at startup and create a map of Closure names to providing files.

Options:

  • dirs An array of path strings indicating which directories to search for files. Paths can either be absolute, or relative to the project directory. Optional. Default: ['.'] (just the project directory).

Here is an example .tern-project file:

{
  "plugins": {
    "doc_comment": false,
    "closure": {
      "finder": {
        "name": "grep",
        "dirs": [
          "relevant/project/subdir",
          "/absolute/path/to/library"
        ]
      }
    }
  }
}

Additional finders

You can easily use a finder not included in this repository, or implement your own. This allows you to search for names in different ways, on demand, and to use existing indexes of your codebase.

Given a finder name name, tern-closure first looks in its own lib/finder directory, then attempts to load name using require(), so a third-party finder module can be installed as an npm package.

A finder module must implement a simple interface:

  • It must export a constructor function(projectDir: string, options: Object) which takes the project directory and an options object as parameters. Options are specified in the Tern configuration file.

  • Instances of that constructor must have a method findFile(name: string, cb: function(file: string)), which takes as arguments a Closure name name to find and a callback function cb to call with the path to file providing name. cb should be called asynchronously, even if the providing file is known when findFile is called. This allows finders to execute I/O operations to find files on demand.

Please note that while tern-closure is in a 0.X.X release, the finder API may be subject to breaking changes.

Bug reports and feature requests

Please file bug reports and feature requests as issues on the issues page of the tern-closure repository.

Contributing

Pull requests to tern-closure are welcome. Please see the CONTRIBUTING.md file for requirements and guidelines.

Disclaimer: tern-closure is not an official Google product, and is maintained on a best-effort basis.