Laden node.js Modul von Strings im Speicher

Wie würde ich require() eine Datei wenn ich den Inhalt der Datei als string im Speicher, ohne schreiben auf die Festplatte? Hier ist ein Beispiel:

//Load the file as a string
var strFileContents = fs.readFileSync( "./myUnalteredModule.js", 'utf8' );

//Do some stuff to the files contents
strFileContents[532] = '6';

//Load it as a node module (how would I do this?)
var loadedModule = require( doMagic(strFileContents) );
Ich habe keine vollständige Antwort für Sie, aber Sie können Kasse, wie Node.js läuft das Modul code. github.com/joyent/node/blob/... betrachten Sie auch bei L813

InformationsquelleAutor ZECTBynmo | 2013-07-10

Schreibe einen Kommentar