BVB Source Codes

reactide Show intercept.js Source code

Return Download reactide: download intercept.js Source code - Download reactide Source code - Type:.js
  1. /*jshint node: true */
  2. var inserted,
  3.     Module = require('module'),
  4.     fs = require('fs'),
  5.     existingExtFn = Module._extensions['.js'],
  6.     amdefineRegExp = /amdefine\.js/;
  7.  
  8. inserted  = "if (typeof define !== 'function') {var define = require('amdefine')(module)}";
  9.  
  10. //From the node/lib/module.js source:
  11. function stripBOM(content) {
  12.     // Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
  13.     // because the buffer-to-string conversion in `fs.readFileSync()`
  14.     // translates it to FEFF, the UTF-16 BOM.
  15.     if (content.charCodeAt(0) === 0xFEFF) {
  16.         content = content.slice(1);
  17.     }
  18.     return content;
  19. }
  20.  
  21. //Also adapted from the node/lib/module.js source:
  22. function intercept(module, filename) {
  23.     var content = stripBOM(fs.readFileSync(filename, 'utf8'));
  24.  
  25.     if (!amdefineRegExp.test(module.id)) {
  26.         content = inserted + content;
  27.     }
  28.  
  29.     module._compile(content, filename);
  30. }
  31.  
  32. intercept._id = 'amdefine/intercept';
  33.  
  34. if (!existingExtFn._id || existingExtFn._id !== intercept._id) {
  35.     Module._extensions['.js'] = intercept;
  36. }
  37.  
downloadintercept.js Source code - Download reactide Source code
Related Source Codes/Software:
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top