I\'m whiting firefox extension. I got function that\'s reading contents of file:
var HelloWorld = {...
getData: function () {
var env = Components.classe
getData: function () {
var env = Components.classes["@mozilla.org/processenvironment;1"].getService(Components.interfaces.nsIEnvironment);
var path = env.get("TEMP");
path = path + "\\lastcall.txt"
alert(path);
Components.utils.import("resource://gre/modules/osfile.jsm");
return OS.File.read(path).then(function(array) {
let decoder = new TextDecoder();
return decoder.decode(array);
});
},
...};
Instead of returning line
you return promise for line, then the caller can do:
var line = getData();
// When you finally need the actual line, unwrap it:
line.then(function(actualLine) {
});