Comparing version 0.1.0 to 0.2.0
@@ -22,3 +22,4 @@ /** | ||
* | ||
* @todo make this function global | ||
* @todo extend require object to require.hot(path, callback); | ||
* require.prototype.hot = function(path, callback) doesn't work. | ||
*/ | ||
@@ -51,2 +52,3 @@ function hotRequire(path, callback) | ||
require.prototype.__proto__.hot = hotRequire; | ||
module.exports = exports = hotRequire; |
{ | ||
"name": "hotrequire", | ||
"description": "hot-load modules into current scope", | ||
"version": "0.1.0", | ||
"description": "Extends require object by adding the require.hot(path, callback) method. This enables you to hot-load modules into the current scope.", | ||
"version": "0.2.0", | ||
"author": "Kai Dorschner https://github.com/krnlde/", | ||
@@ -6,0 +6,0 @@ "repository": { |
# hotRequire | ||
hotRequire hot-loads modules by extending the system's require() function using the fs.fileWatch() routine (which already comes with node). | ||
Hot-loading means it watches the file for changes and then reloades it's parsed content into the variable set by the user. | ||
Hot-loading means it watches the file for changes and then reloades it's eval'd content into the variable set by the user. | ||
Important: It does NOT rewrite the require(); method rahter than utilizing and extending it. | ||
The file watcher emits catchable events to the process. These events are "modified", "removed" and "reloaded". | ||
@@ -10,10 +12,22 @@ | ||
require('./hotrequire.js'); | ||
var hotrequire = require('./hotrequire.js'); | ||
var example = hotrequire('./example.js', function(module) { | ||
example = module | ||
}); | ||
// or | ||
var example = require.hot('./example.js', function(module) { | ||
example = module | ||
}); | ||
console.log(example.message); | ||
hotrequire('./example.js', this, 'module'); | ||
## Requirements | ||
console.log(this.module.message); | ||
* fs.js & node-waf & v8.h (Comes with node) | ||
## Requirements | ||
## Installation | ||
* fs.js & node-waf & v8.h (Comes with node) | ||
npm install hotrequire |
var hotrequire = require('./hotrequire.js'); | ||
var example = hotrequire('./example.js', function(module) { | ||
var example = require.hot('./examplemodule.js', function(module) { | ||
example = module; | ||
@@ -5,0 +5,0 @@ }); |
3949
64
33