Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Returns data from file if cached, caches data if not cached
- AFile.prototype.get = function () {
- var proxyThis = this; // UGLY
- if (this.data === "") {
- console.log(this.filename + " not loaded..");
- return fs.readFileAsync(this.filename).then(function (d) {
- proxyThis.data = d;
- console.log("Loading complete");
- return d;
- });
- } else {
- return Promise.resolve(this.data);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement