Created
October 30, 2017 12:35
-
-
Save ericprud/2b25a3bbc183d4465a70ec3304011517 to your computer and use it in GitHub Desktop.
add Event support to file-fetch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /home/eric/checkouts/linkeddata/rabel/node_modules/file-fetch/index-orig.js 2017-10-30 06:33:39.254504474 -0400 | |
+++ /home/eric/checkouts/linkeddata/rabel/node_modules/file-fetch/index.js 2017-10-30 08:20:25.020709986 -0400 | |
@@ -57,6 +57,30 @@ | |
} | |
} | |
+const util = require('util') | |
+const EventEmitter = require('events') | |
+function send (options) { | |
+ if (!(this instanceof send)) | |
+ return new send(options); | |
+ let self = this | |
+ self.path = options.path | |
+ this.end = function () { | |
+ this.finished = true | |
+ this.emit('finish') | |
+ setTimeout(() => { | |
+ setTimeout(() => { | |
+ self.emit('socket', null) | |
+ setTimeout(() => { | |
+ var stream = fs.createReadStream(self.path, {bufferSize: 64 * 1024}) | |
+ self.emit('response', stream) | |
+ }, 0) | |
+ }, 0) | |
+ }) | |
+ } | |
+} | |
+util.inherits(send, EventEmitter) | |
+fetch.request = send | |
+ | |
fetch.Headers = Headers | |
module.exports = fetch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment