https://github.com/jimmycuadra/extractor
A JavaScript library for managing the global namespace.
https://github.com/jimmycuadra/extractor
coffeescript javascript library
Last synced: 11 months ago
JSON representation
A JavaScript library for managing the global namespace.
- Host: GitHub
- URL: https://github.com/jimmycuadra/extractor
- Owner: jimmycuadra
- License: mit
- Created: 2011-09-16T07:02:51.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2011-10-31T02:20:24.000Z (over 14 years ago)
- Last Synced: 2024-04-09T16:26:19.570Z (about 2 years ago)
- Topics: coffeescript, javascript, library
- Language: CoffeeScript
- Homepage:
- Size: 1.51 MB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```javascript
// Assuming Extractor.js has been included
(function () {
var MyLibrary = {
foo: "bar"
};
Extractor.exports("MyLibrary", MyLibrary);
})();
```
For developers:
### Extracting a library
```javascript
var FooBar = Extractor.require("MyLibrary");
```
### Extracting a single property/function from a library
```javascript
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`.