Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A JavaScript library for managing the global namespace.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Cakefile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 extractor.min.js
Octocat-spinner-32 package.json
README.md

Extractor.js

Extractor is a tiny JavaScript library for managing variables in the global namespace. Instead of attaching themselves to the global object, libraries may register with Extractor. Developers can then retrieve registered libraries from Extractor and assign them to a variable of their choice. It achieves an effect similar to jQuery's noConflict function with CommonJS terminology.

Usage

For library authors:

// Assuming Extractor.js has been included

(function () {
  var MyLibrary = {
    foo: "bar"
  };

  Extractor.exports("MyLibrary", MyLibrary);
})();

For developers:

Extracting a library

var FooBar = Extractor.require("MyLibrary");

Extracting a single property/function from a library

var barify = Extractor.extract("MyLibrary").fooify;

This allows developers to extract any module (or any property of a module) into a variable with a name of their choosing.

Listing registered modules

To get an alphabetical list of the names of all modules registered with Extractor, call Extractor.listModules().

Resetting Extractor's registry

If, for some reason, you need to programmatically reset Extractor's registry, call Extractor.reset() to clear all registered modules.

Development

To work on Extractor or to run the included Jasmine specs, you must have Node and NPM installed. Clone the repository and run npm install inside the directory to install the Node dependencies. You should also install CoffeeScript globally with npm install coffee-script -g to get command line access to the Cake tasks. Run cake for a list of available tasks.

License

Extractor is available under the MIT license. See the included LICENSE.

Something went wrong with that request. Please try again.