Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorKyle Robinson Young <kyle@dontkry.com>2012-04-17 09:15:51 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2012-04-17 19:10:42 +0400
commit718aa505c47eecf0ef2c28ec3a7c1f5d63a9d6d6 (patch)
tree4d16dbdc472bef7bb8213d25befcaa379cc86983 /doc
parent7cd1690f3dab62fea1c06ab26ade985cb1c85740 (diff)
doc: add require.extensions to globals
Closes #3028
Diffstat (limited to 'doc')
-rw-r--r--doc/api/globals.markdown18
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/api/globals.markdown b/doc/api/globals.markdown
index 5df0b9e5591..d8fb257e7a4 100644
--- a/doc/api/globals.markdown
+++ b/doc/api/globals.markdown
@@ -61,6 +61,24 @@ but rather than loading the module, just return the resolved filename.
Modules are cached in this object when they are required. By deleting a key
value from this object, the next `require` will reload the module.
+### require.extensions
+
+* {Array}
+
+Instruct `require` on how to handle certain file extensions.
+
+Process files with the extension `.sjs` as `.js`:
+
+ require.extensions['.sjs'] = require.extensions['.js'];
+
+Write your own extension handler:
+
+ require.extensions['.sjs'] = function(module, filename) {
+ var content = fs.readFileSync(filename, 'utf8');
+ // Parse the file content and give to module.exports
+ module.exports = content;
+ };
+
## __filename
<!-- type=var -->