Browse Source

Repository(JS): add a file_get_contents() function

master
parent
commit
8cc518bf5a
  1. 21
      src/Repository.js

21
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)

Loading…
Cancel
Save