From 8cc518bf5ab7b2bc5b9c2efd02a196a896199394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Thu, 11 Aug 2022 11:18:55 +0200 Subject: [PATCH] Repository(JS): add a file_get_contents() function --- src/Repository.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Repository.js b/src/Repository.js index bea94fa0..9f951665 100644 --- a/src/Repository.js +++ b/src/Repository.js @@ -10,6 +10,27 @@ module.exports = class Repository { } } + file_get_contents (fileName, options, callback) { + let param = [] + param.push('repo=' + encodeURIComponent(this.id)) + param.push('file=' + encodeURIComponent(fileName)) + param.push(config.categoriesRev) + param = param.length ? '?' + param.join('&') : '' + + fetch('repo.php' + param) + .then(res => res.text()) + .then(data => { + global.setTimeout(() => { + callback(null, data) + }, 0) + }) + .catch(err => { + global.setTimeout(() => { + callback(err) + }, 0) + }) + } + load (callback) { if (this.loadCallbacks) { return this.loadCallbacks.push(callback)