https://github.com/bramstein/closureloader
Load code using the Closure library dependency syntax in Node.js
https://github.com/bramstein/closureloader
Last synced: about 1 year ago
JSON representation
Load code using the Closure library dependency syntax in Node.js
- Host: GitHub
- URL: https://github.com/bramstein/closureloader
- Owner: bramstein
- Created: 2012-04-27T18:18:51.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2012-05-02T22:48:36.000Z (about 14 years ago)
- Last Synced: 2025-02-09T07:35:59.298Z (over 1 year ago)
- Language: JavaScript
- Size: 102 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Closure Loader
Load code using the Closure library dependency syntax in Node.js
### Installation
npm install closureloader
### Usage
var loader = require('closureloader');
loader('src', function(err, goog) {
if (err) {
throw err;
} else {
goog.require('my.example.Class');
// use it as normal
var c = new my.example.Class();
}
});
The `closureloader` method takes two parameters `path` and `callback`. The `path` parameter can either be a string or an array. It should point to the directory or directories containing the code that uses the Google Closure compiler dependency syntax. The `callback` method should be a function that is called with two parameters, `err` and `goog`. If `err` is not `null`, an error occured while reading the path(s). If everything worked as it should, you can use the second parameter `goog` to `require` your code. The `goog.provide` function is not available on the `goog` object.