{"_id":"drex","_rev":"27-1b97f996f352bc6960c99ceed2038dc8","name":"drex","description":"drex - 'dynamic require() extension'. Dynamic version of Node's require() - loads fresh copy of the module every time the module file is changed.","dist-tags":{"latest":"0.1.4"},"versions":{"0.1.2":{"name":"drex","description":"drex - 'dynamic require() extension'. Dynamic version of Node's require() - loads fresh copy of the module every time the module file is changed.","version":"0.1.2","homepage":"https://github.com/yuryb/drex","engines":["node >= 0.3.6"],"author":{"name":"Yury Bogom","email":"drex@yury.com"},"scripts":{"test":"node example/app.js"},"repository":{"type":"git","url":"git://github.com/yuryb/drex.git"},"licenses":[{"type":"GPL","url":"http://www.gnu.org/licenses/gpl-3.0.txt"}],"readme":"drex\n====\n\n`drex` - \"dynamic require() extension\".\nDynamic version of Node's require() - loads fresh copy of the module every time the module file is changed.\n\nInsanely simple, and/but astonishingly useful grab of bits, which has been brought to this world out of severe necessity.\n>Here is why:\n- all re-loaders I was able to find reload the whole node process, which means that the context of the process is gone;\n- but, sometimes, you don't want that! You want your process to continue running intact, at least for those clients who already deep in it, and would choke if process forgets about them;\n- sometime you have a little (or BIG) piece of code which you constantly change and, for G-d sake, do not want to sacrifice the whole your Node process for, but\n- you don't want to loose the benefits of CommonJS/require supported modularity of your code.\n\nHere comes `drex`, and it comes like this:\n\n```javascript\nvar drex = require('drex');\n\n... node code node code node code ...\n\n// here goes my frea[ky/quently updated] piece of code, which lives in a js file called mucode.js:\ndrex.require('./mucode.js', function(mucode)\n{\n  // at this point my mucode.js has been require()d, just like this: \n  // var mucode = require('./mucode.js');\n  // the code of the required module is the LATEST UPDATE TO mucode.js\n  mucode.muNewFunc();  \n});\n```\n\n#Here is an example (and the reason I had to comeup with drex) from the real life when drex is irreplaceable:#\nfrequently updated/added socket.io event handlers:\n\n```javascript\nio.sockets.on('connection', function (socket) {\n  // I need to do many things here, and these things change all the time!\n  // If I use something like \"forever\", or \"supervisor\" to re-start my Node process every time \n  // when things here should change, all active sessions will be killed!\n  // Oh, no, no, no!\n  // All I want to do here, most of the time, is to put new event handler, which existing sessions \n  // do not even know about!\n  \n  drex.require('./my_module_with_event_handlers_which_I_always_change.js', function(mymod) {\n      // here I can start calling methods from my module like there is no tomorrow!\n      // and I'm guaranteed that every time I update my module, sessions which will come here after the update\n      // will get the new code, but sessions which were opened before the update will still be working with the\n      // code which existed in my module when these sessions were created. That's fair!\n  });\n```\n#API#\n  `drex.require(<module reference>, <callBack>);`\n  \n  where:\n  - `<module reference>` resolvable Node module reference, such as './module.js'\n  - `<callBack>` function which is being called when the module has been `require()d`.\n    \n    callBack signature: `callBack(module, filepath)`\n    \n    where:\n    - `module`: reference to the require()d module, and\n    - `filepath`: full path to the module's file\n\n#Installation using NPM#\n`\nnpm install drex\n`\n#Even more simple installation#\nJust copy `drex.js` to the place where Node can find it, i.e. for `require('./drex.js')` - to the root of your Node project.\n\n#tl;dr#\n`drex` is watching a module for updates and cleanly re-requires the module after the update.\nNew code is being `require()`d as if the new code is a totally different module, so `require.cache` is not a problem.\n\n#License#\nGPL\n\n\nEnjoy\n","_id":"drex@0.1.2","dist":{"shasum":"8a0ab04382bd59a5c8ccaf7041c9983811aa578a","tarball":"https://registry.npmjs.org/drex/-/drex-0.1.2.tgz","integrity":"sha512-fv6KL4Op0Zvm78L4FKkGg95Lf+t4dSrdeknJNuTUuuzm3xwRJdfYe17v/ASNREzZkaHwQtaZeMnBg2St06Pgfg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEIX8n80LrdyVEt7pzxfZAxAzOzv9Zi0qpcPo5kL/5aYAiB2NyOyCfa6nl7YTIp9blDbPMVi4s1GU3w0e42Cr8K8mg=="}]},"maintainers":[{"name":"yuryb","email":"drex@yury.com"}],"directories":{}},"0.1.4":{"name":"drex","description":"drex - 'dynamic require() extension'. Dynamic version of Node's require() - loads fresh copy of the module every time the module file is changed.","version":"0.1.4","homepage":"https://github.com/yuryb/drex","engines":["node >= 0.3.6"],"author":{"name":"Yury Bogom","email":"drex@yury.com"},"scripts":{"test":"node example/app.js"},"repository":{"type":"git","url":"git://github.com/yuryb/drex.git"},"licenses":[{"type":"GPL","url":"http://www.gnu.org/licenses/gpl-3.0.txt"}],"readme":"drex\n====\n\n`drex` - \"dynamic require() extension\".\nDynamic version of Node's require() - loads fresh copy of the module every time the module file is changed.\n\nInsanely simple, and/but astonishingly useful grab of bits, which has been brought to this world out of severe necessity.\n>Here is why:\n- all re-loaders I was able to find reload the whole node process, which means that the context of the process is gone;\n- but, sometimes, you don't want that! You want your process to continue running intact, at least for those clients who already deep in it, and would choke if process forgets about them;\n- sometime you have a little (or BIG) piece of code which you constantly change and, for G-d sake, do not want to sacrifice the whole your Node process for, but\n- you don't want to loose the benefits of CommonJS/require supported modularity of your code.\n\nHere comes `drex`, and it comes like this:\n\n```javascript\nvar drex = require('drex');\n\n... node code node code node code ...\n\n// here goes my frea[ky/quently updated] piece of code, which lives in a js file called mucode.js:\ndrex.require('./mucode.js', function(mucode)\n{\n  // at this point my mucode.js has been require()d, just like this: \n  // var mucode = require('./mucode.js');\n  // the code of the required module is the LATEST UPDATE TO mucode.js\n  mucode.muNewFunc();  \n});\n```\n\n#Here is an example (and the reason I had to comeup with drex) from the real life when drex is irreplaceable:#\nfrequently updated/added socket.io event handlers:\n\n```javascript\nio.sockets.on('connection', function (socket) {\n  // I need to do many things here, and these things change all the time!\n  // If I use something like \"forever\", or \"supervisor\" to re-start my Node process every time \n  // when things here should change, all active sessions will be killed!\n  // Oh, no, no, no!\n  // All I want to do here, most of the time, is to put new event handler, which existing sessions \n  // do not even know about!\n  \n  drex.require('./my_module_with_event_handlers_which_I_always_change.js', function(mymod) {\n      // here I can start calling methods from my module like there is no tomorrow!\n      // and I'm guaranteed that every time I update my module, sessions which will come here after the update\n      // will get the new code, but sessions which were opened before the update will still be working with the\n      // code which existed in my module when these sessions were created. That's fair!\n  });\n```\n#API#\n  `drex.require(<module reference>, <callBack>);`\n  \n  where:\n  - `<module reference>` resolvable Node module reference, such as './module.js'\n  - `<callBack>` function which is being called when the module has been `require()d`.\n    \n    callBack signature: `callBack(module, filepath)`\n    \n    where:\n    - `module`: reference to the require()d module, and\n    - `filepath`: full path to the module's file\n\n#Installation using NPM#\n`\nnpm install drex\n`\n#Even more simple installation#\nJust copy `drex.js` to the place where Node can find it, i.e. for `require('./drex.js')` - to the root of your Node project.\n\n#tl;dr#\n`drex` is watching a module for updates and cleanly re-requires the module after the update.\nNew code is being `require()`d as if the new code is a totally different module, so `require.cache` is not a problem.\n\n#License#\nGPL\n\n\nEnjoy\n","_id":"drex@0.1.4","dist":{"shasum":"79056dabf01138f675f16a4dcd57db39cbee37f9","tarball":"https://registry.npmjs.org/drex/-/drex-0.1.4.tgz","integrity":"sha512-e7R2zA1u+gRxg+MX5JenG3NkJxJkutmSDgAUTrNHv2V6RYKdkFGzGcbTBltoT68WYcWkrhRUBsbU9ZyKHjO5GA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDKRlVYRSze4a6dA6eXFUoY1IWy06hMWXvXlwPvc1CyGQIhAMluDS2eBYYzGshLOVhcnxqCLmSdJBIcdZpxyk66VCpg"}]},"maintainers":[{"name":"yuryb","email":"drex@yury.com"}]}},"readme":"drex\n====\n\n`drex` - \"dynamic require() extension\".\nDynamic version of Node's require() - loads fresh copy of the module every time the module file is changed.\n\nInsanely simple, and/but astonishingly useful grab of bits, which has been brought to this world out of severe necessity.\n>Here is why:\n- all re-loaders I was able to find reload the whole node process, which means that the context of the process is gone;\n- but, sometimes, you don't want that! You want your process to continue running intact, at least for those clients who already deep in it, and would choke if process forgets about them;\n- sometime you have a little (or BIG) piece of code which you constantly change and, for G-d sake, do not want to sacrifice the whole your Node process for, but\n- you don't want to loose the benefits of CommonJS/require supported modularity of your code.\n\nHere comes `drex`, and it comes like this:\n\n```javascript\nvar drex = require('drex');\n\n... node code node code node code ...\n\n// here goes my frea[ky/quently updated] piece of code, which lives in a js file called mucode.js:\ndrex.require('./mucode.js', function(mucode)\n{\n  // at this point my mucode.js has been require()d, just like this: \n  // var mucode = require('./mucode.js');\n  // the code of the required module is the LATEST UPDATE TO mucode.js\n  mucode.muNewFunc();  \n});\n```\n\n#Here is an example (and the reason I had to comeup with drex) from the real life when drex is irreplaceable:#\nfrequently updated/added socket.io event handlers:\n\n```javascript\nio.sockets.on('connection', function (socket) {\n  // I need to do many things here, and these things change all the time!\n  // If I use something like \"forever\", or \"supervisor\" to re-start my Node process every time \n  // when things here should change, all active sessions will be killed!\n  // Oh, no, no, no!\n  // All I want to do here, most of the time, is to put new event handler, which existing sessions \n  // do not even know about!\n  \n  drex.require('./my_module_with_event_handlers_which_I_always_change.js', function(mymod) {\n      // here I can start calling methods from my module like there is no tomorrow!\n      // and I'm guaranteed that every time I update my module, sessions which will come here after the update\n      // will get the new code, but sessions which were opened before the update will still be working with the\n      // code which existed in my module when these sessions were created. That's fair!\n  });\n```\n#Installation#\n`\nnpm install drex\n`\n\n#TL;DR;#\n`drex` is watching a module for updates and cleanly re-requires the module after the update.\nNew code is being require()d as if the new code is a totally different module, so require.cache is not a problem.\n\nEnjoy\n","maintainers":[{"name":"yuryb","email":"drex@yury.com"}],"time":{"modified":"2022-06-16T00:06:48.369Z","created":"2013-01-31T06:00:40.295Z","0.1.2":"2013-02-06T17:25:29.603Z","0.1.4":"2013-02-06T17:26:12.548Z"},"author":{"name":"Yury Bogom","email":"drex@yury.com"},"repository":{"type":"git","url":"git://github.com/yuryb/drex.git"}}