diff --git a/example/index.js b/example/index.js index f7b04fc..cee67ee 100644 --- a/example/index.js +++ b/example/index.js @@ -1,6 +1,24 @@ /// @ts-check /// +const fs = require('fs'); +const Response = require('node-fetch').Response; + +global["fetch"] = (url) => { + return new Promise((resolve, reject) => { + if (!fs.existsSync(url)) { + reject(`File not found: ${url}`); + } + const readStream = fs.createReadStream(url); + readStream.on('open', function () { + resolve(new Response(readStream, { + status: 200, + statusText: 'OK' + })); + }); + }); +}; + process.chdir(__dirname); global["SystemJS"] = require("systemjs");