mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
7.0.0
This commit is contained in:
@@ -1,8 +1 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.reg = reg;
|
||||
|
||||
function reg(c, a) {
|
||||
return [c].concat(Array.prototype.slice.call(a));
|
||||
}
|
||||
"use strict";exports.__esModule = true;exports.reg = reg;function reg(c,a){return [c].concat(Array.prototype.slice.call(a));}
|
||||
|
||||
@@ -1,149 +1 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
var discrimS = Symbol();
|
||||
var discrimCacheS = Symbol();
|
||||
|
||||
var Cache = (function (_Array) {
|
||||
_inherits(Cache, _Array);
|
||||
|
||||
function Cache(discrim, limit) {
|
||||
_classCallCheck(this, Cache);
|
||||
|
||||
_Array.call(this);
|
||||
this[discrimS] = discrim || "id";
|
||||
this[discrimCacheS] = {};
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
Cache.prototype.get = function get(key, value) {
|
||||
if (typeof key === 'function') {
|
||||
var valid = key;
|
||||
key = null;
|
||||
} else if (key === this[discrimS] && typeof value === "string") {
|
||||
return this[discrimCacheS][value] || null;
|
||||
} else if (value && value.constructor.name === 'RegExp') {
|
||||
var valid = function valid(item) {
|
||||
return value.test(item);
|
||||
};
|
||||
} else if (typeof value !== 'function') {
|
||||
var valid = function valid(item) {
|
||||
return item == value;
|
||||
};
|
||||
}
|
||||
|
||||
for (var _iterator = this, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref = _i.value;
|
||||
}
|
||||
|
||||
var item = _ref;
|
||||
|
||||
if (valid(key == null ? item : item[key])) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
Cache.prototype.has = function has(object) {
|
||||
return !!this.get(this[discrimS], object[this[discrimS]]);
|
||||
};
|
||||
|
||||
Cache.prototype.getAll = function getAll(key, value) {
|
||||
var found = new Cache(this[discrimS]);
|
||||
|
||||
if (typeof key === 'function') {
|
||||
var valid = key;
|
||||
key = null;
|
||||
} else if (value && value.constructor.name === 'RegExp') {
|
||||
var valid = function valid(item) {
|
||||
return value.test(item);
|
||||
};
|
||||
} else if (typeof value !== 'function') {
|
||||
var valid = function valid(item) {
|
||||
return item == value;
|
||||
};
|
||||
}
|
||||
|
||||
for (var _iterator2 = this, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
|
||||
var _ref2;
|
||||
|
||||
if (_isArray2) {
|
||||
if (_i2 >= _iterator2.length) break;
|
||||
_ref2 = _iterator2[_i2++];
|
||||
} else {
|
||||
_i2 = _iterator2.next();
|
||||
if (_i2.done) break;
|
||||
_ref2 = _i2.value;
|
||||
}
|
||||
|
||||
var item = _ref2;
|
||||
|
||||
if (valid(key == null ? item : item[key])) {
|
||||
found.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
};
|
||||
|
||||
Cache.prototype.add = function add(data) {
|
||||
var cacheKey = data[this[discrimS]];
|
||||
if (this[discrimCacheS][cacheKey]) {
|
||||
return this[discrimCacheS][cacheKey];
|
||||
}
|
||||
if (this.limit && this.length >= this.limit) {
|
||||
this.splice(0, 1);
|
||||
}
|
||||
this.push(data);
|
||||
this[discrimCacheS][cacheKey] = data;
|
||||
return data;
|
||||
};
|
||||
|
||||
Cache.prototype.update = function update(old, data) {
|
||||
var obj = this[discrimCacheS][old[this[discrimS]]];
|
||||
if (obj) {
|
||||
for (var key in data) {
|
||||
if (data.hasOwnProperty(key)) {
|
||||
obj[key] = data[key];
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
Cache.prototype.random = function random() {
|
||||
return this[Math.floor(Math.random() * this.length)];
|
||||
};
|
||||
|
||||
Cache.prototype.remove = function remove(data) {
|
||||
delete this[discrimCacheS][data[this[discrimS]]];
|
||||
for (var i in this) {
|
||||
if (this[i][this[discrimS]] === data[this[discrimS]]) {
|
||||
this.splice(i, 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
return Cache;
|
||||
})(Array);
|
||||
|
||||
exports["default"] = Cache;
|
||||
module.exports = exports["default"];
|
||||
"use strict";exports.__esModule = true;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var discrimS=Symbol();var discrimCacheS=Symbol();var Cache=(function(_Array){_inherits(Cache,_Array);function Cache(discrim,limit){_classCallCheck(this,Cache);_Array.call(this);this[discrimS] = discrim || "id";this[discrimCacheS] = {};this.limit = limit;}Cache.prototype.get = function get(key,value){if(typeof key === 'function'){var valid=key;key = null;}else if(key === this[discrimS] && typeof value === "string"){return this[discrimCacheS][value] || null;}else if(value && value.constructor.name === 'RegExp'){var valid=function valid(item){return value.test(item);};}else if(typeof value !== 'function'){var valid=function valid(item){return item == value;};}for(var _iterator=this,_isArray=Array.isArray(_iterator),_i=0,_iterator=_isArray?_iterator:_iterator[Symbol.iterator]();;) {var _ref;if(_isArray){if(_i >= _iterator.length)break;_ref = _iterator[_i++];}else {_i = _iterator.next();if(_i.done)break;_ref = _i.value;}var item=_ref;if(valid(key == null?item:item[key])){return item;}}return null;};Cache.prototype.has = function has(object){return !!this.get(this[discrimS],object[this[discrimS]]);};Cache.prototype.getAll = function getAll(key,value){var found=new Cache(this[discrimS]);if(typeof key === 'function'){var valid=key;key = null;}else if(value && value.constructor.name === 'RegExp'){var valid=function valid(item){return value.test(item);};}else if(typeof value !== 'function'){var valid=function valid(item){return item == value;};}for(var _iterator2=this,_isArray2=Array.isArray(_iterator2),_i2=0,_iterator2=_isArray2?_iterator2:_iterator2[Symbol.iterator]();;) {var _ref2;if(_isArray2){if(_i2 >= _iterator2.length)break;_ref2 = _iterator2[_i2++];}else {_i2 = _iterator2.next();if(_i2.done)break;_ref2 = _i2.value;}var item=_ref2;if(valid(key == null?item:item[key])){found.add(item);}}return found;};Cache.prototype.add = function add(data){var cacheKey=data[this[discrimS]];if(this[discrimCacheS][cacheKey]){return this[discrimCacheS][cacheKey];}if(this.limit && this.length >= this.limit){this.splice(0,1);}this.push(data);this[discrimCacheS][cacheKey] = data;return data;};Cache.prototype.update = function update(old,data){var obj=this[discrimCacheS][old[this[discrimS]]];if(obj){for(var key in data) {if(data.hasOwnProperty(key)){obj[key] = data[key];}}return obj;}return false;};Cache.prototype.random = function random(){return this[Math.floor(Math.random() * this.length)];};Cache.prototype.remove = function remove(data){delete this[discrimCacheS][data[this[discrimS]]];for(var i in this) {if(this[i][this[discrimS]] === data[this[discrimS]]){this.splice(i,1);return true;}}return false;};return Cache;})(Array);exports["default"] = Cache;module.exports = exports["default"];
|
||||
|
||||
@@ -8,38 +8,5 @@
|
||||
instances sometimes.
|
||||
|
||||
Instead, use objectThatExtendsEquality.equals()
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var Equality = (function () {
|
||||
function Equality() {
|
||||
_classCallCheck(this, Equality);
|
||||
}
|
||||
|
||||
Equality.prototype.equals = function equals(object) {
|
||||
return object && object[this.eqDiscriminator] === this[this.eqDiscriminator];
|
||||
};
|
||||
|
||||
Equality.prototype.equalsStrict = function equalsStrict(object) {
|
||||
// override per class type
|
||||
return;
|
||||
};
|
||||
|
||||
_createClass(Equality, [{
|
||||
key: "eqDiscriminator",
|
||||
get: function get() {
|
||||
return "id";
|
||||
}
|
||||
}]);
|
||||
|
||||
return Equality;
|
||||
})();
|
||||
|
||||
exports["default"] = Equality;
|
||||
module.exports = exports["default"];
|
||||
*/"use strict";exports.__esModule = true;var _createClass=(function(){function defineProperties(target,props){for(var i=0;i < props.length;i++) {var descriptor=props[i];descriptor.enumerable = descriptor.enumerable || false;descriptor.configurable = true;if("value" in descriptor)descriptor.writable = true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};})();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var Equality=(function(){function Equality(){_classCallCheck(this,Equality);}Equality.prototype.equals = function equals(object){return object && object[this.eqDiscriminator] === this[this.eqDiscriminator];};Equality.prototype.equalsStrict = function equalsStrict(object){ // override per class type
|
||||
return;};_createClass(Equality,[{key:"eqDiscriminator",get:function get(){return "id";}}]);return Equality;})();exports["default"] = Equality;module.exports = exports["default"];
|
||||
|
||||
@@ -1,29 +1,2 @@
|
||||
// Shim for the token cacher in the browser.
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var TokenCacher = (function () {
|
||||
function TokenCacher() {
|
||||
_classCallCheck(this, TokenCacher);
|
||||
}
|
||||
|
||||
TokenCacher.prototype.setToken = function setToken() {};
|
||||
|
||||
TokenCacher.prototype.save = function save() {};
|
||||
|
||||
TokenCacher.prototype.getToken = function getToken() {
|
||||
return null;
|
||||
};
|
||||
|
||||
TokenCacher.prototype.init = function init(ind) {
|
||||
this.done = true;
|
||||
};
|
||||
|
||||
return TokenCacher;
|
||||
})();
|
||||
|
||||
exports["default"] = TokenCacher;
|
||||
module.exports = exports["default"];
|
||||
"use strict";exports.__esModule = true;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var TokenCacher=(function(){function TokenCacher(){_classCallCheck(this,TokenCacher);}TokenCacher.prototype.setToken = function setToken(){};TokenCacher.prototype.save = function save(){};TokenCacher.prototype.getToken = function getToken(){return null;};TokenCacher.prototype.init = function init(ind){this.done = true;};return TokenCacher;})();exports["default"] = TokenCacher;module.exports = exports["default"];
|
||||
|
||||
@@ -1,157 +1,12 @@
|
||||
"use strict";
|
||||
/* global process */
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
var _fs = require("fs");
|
||||
|
||||
var _fs2 = _interopRequireDefault(_fs);
|
||||
|
||||
var _events = require("events");
|
||||
|
||||
var _events2 = _interopRequireDefault(_events);
|
||||
|
||||
var _crypto = require("crypto");
|
||||
|
||||
var _crypto2 = _interopRequireDefault(_crypto);
|
||||
|
||||
var savePaths = [process.env.APPDATA || (process.platform == "darwin" ? process.env.HOME + "Library/Preference" : "/var/local"), process.env[process.platform == "win32" ? "USERPROFILE" : "HOME"], process.cwd()];
|
||||
|
||||
var algo = "aes-256-ctr";
|
||||
|
||||
function secureEmail(email, password) {
|
||||
return new Buffer(_crypto2["default"].createHash("sha256").update(email + password, "utf8").digest()).toString("hex");
|
||||
}
|
||||
|
||||
function exists(path) {
|
||||
// Node deprecated the `fs.exists` method apparently...
|
||||
try {
|
||||
_fs2["default"].accessSync(path);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var TokenCacher = (function (_EventEmitter) {
|
||||
_inherits(TokenCacher, _EventEmitter);
|
||||
|
||||
function TokenCacher(client, options) {
|
||||
_classCallCheck(this, TokenCacher);
|
||||
|
||||
_EventEmitter.call(this);
|
||||
this.client = client;
|
||||
this.savePath = null;
|
||||
this.error = false;
|
||||
this.done = false;
|
||||
this.data = {};
|
||||
}
|
||||
|
||||
TokenCacher.prototype.setToken = function setToken() {
|
||||
var email = arguments.length <= 0 || arguments[0] === undefined ? "" : arguments[0];
|
||||
var password = arguments.length <= 1 || arguments[1] === undefined ? "" : arguments[1];
|
||||
var token = arguments.length <= 2 || arguments[2] === undefined ? "" : arguments[2];
|
||||
|
||||
email = secureEmail(email, password);
|
||||
var cipher = _crypto2["default"].createCipher(algo, password);
|
||||
var crypted = cipher.update("valid" + token, "utf8", "hex");
|
||||
crypted += cipher.final("hex");
|
||||
this.data[email] = crypted;
|
||||
this.save();
|
||||
};
|
||||
|
||||
TokenCacher.prototype.save = function save() {
|
||||
_fs2["default"].writeFile(this.savePath, JSON.stringify(this.data));
|
||||
};
|
||||
|
||||
TokenCacher.prototype.getToken = function getToken() {
|
||||
var email = arguments.length <= 0 || arguments[0] === undefined ? "" : arguments[0];
|
||||
var password = arguments.length <= 1 || arguments[1] === undefined ? "" : arguments[1];
|
||||
|
||||
email = secureEmail(email, password);
|
||||
|
||||
if (this.data[email]) {
|
||||
|
||||
try {
|
||||
var decipher = _crypto2["default"].createDecipher(algo, password);
|
||||
var dec = decipher.update(this.data[email], "hex", "utf8");
|
||||
dec += decipher.final("utf8");
|
||||
return dec.indexOf("valid") === 0 ? dec.substr(5) : false;
|
||||
} catch (e) {
|
||||
// not a valid token
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
TokenCacher.prototype.init = function init(ind) {
|
||||
var _this = this;
|
||||
|
||||
var self = this;
|
||||
var savePath = savePaths[ind];
|
||||
|
||||
// Use one async function at the beginning, so the entire function is async,
|
||||
// then later use only sync functions to increase readability
|
||||
_fs2["default"].stat(savePath, function (err, dirStats) {
|
||||
// Directory does not exist.
|
||||
if (err) error(err);else {
|
||||
try {
|
||||
var storeDirPath = savePath + "/.discordjs";
|
||||
var filePath = storeDirPath + "/tokens.json";
|
||||
|
||||
if (!exists(storeDirPath)) {
|
||||
// First, make sure the directory exists, otherwise the next
|
||||
// call will fail.
|
||||
_fs2["default"].mkdirSync(storeDirPath);
|
||||
}
|
||||
if (!exists(filePath)) {
|
||||
// This will create an empty file if the file doesn't exist, and error
|
||||
// if it does exist. We previously checked that it doesn't exist so we
|
||||
// can do this safely.
|
||||
_fs2["default"].closeSync(_fs2["default"].openSync(filePath, 'wx'));
|
||||
}
|
||||
|
||||
var data = _fs2["default"].readFileSync(filePath);
|
||||
try {
|
||||
_this.data = JSON.parse(data);
|
||||
_this.savePath = filePath;
|
||||
_this.emit('ready');
|
||||
_this.done = true;
|
||||
} catch (e) {
|
||||
// not valid JSON, make it valid and then write
|
||||
_fs2["default"].writeFileSync(filePath, '{}');
|
||||
_this.savePath = filePath;
|
||||
_this.emit("ready");
|
||||
_this.done = true;
|
||||
}
|
||||
} catch (e) {
|
||||
error(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function error(e) {
|
||||
ind++;
|
||||
if (!savePaths[ind]) {
|
||||
self.emit("error");
|
||||
self.error = e;
|
||||
self.done = true;
|
||||
} else {
|
||||
self.init(ind);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return TokenCacher;
|
||||
})(_events2["default"]);
|
||||
|
||||
exports["default"] = TokenCacher;
|
||||
module.exports = exports["default"];
|
||||
"use strict"; /* global process */exports.__esModule = true;function _interopRequireDefault(obj){return obj && obj.__esModule?obj:{"default":obj};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _inherits(subClass,superClass){if(typeof superClass !== "function" && superClass !== null){throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__ = superClass;}var _fs=require("fs");var _fs2=_interopRequireDefault(_fs);var _events=require("events");var _events2=_interopRequireDefault(_events);var _crypto=require("crypto");var _crypto2=_interopRequireDefault(_crypto);var savePaths=[process.env.APPDATA || (process.platform == "darwin"?process.env.HOME + "Library/Preference":"/var/local"),process.env[process.platform == "win32"?"USERPROFILE":"HOME"],process.cwd()];var algo="aes-256-ctr";function secureEmail(email,password){return new Buffer(_crypto2["default"].createHash("sha256").update(email + password,"utf8").digest()).toString("hex");}function exists(path){ // Node deprecated the `fs.exists` method apparently...
|
||||
try{_fs2["default"].accessSync(path);return true;}catch(e) {return false;}}var TokenCacher=(function(_EventEmitter){_inherits(TokenCacher,_EventEmitter);function TokenCacher(client,options){_classCallCheck(this,TokenCacher);_EventEmitter.call(this);this.client = client;this.savePath = null;this.error = false;this.done = false;this.data = {};}TokenCacher.prototype.setToken = function setToken(){var email=arguments.length <= 0 || arguments[0] === undefined?"":arguments[0];var password=arguments.length <= 1 || arguments[1] === undefined?"":arguments[1];var token=arguments.length <= 2 || arguments[2] === undefined?"":arguments[2];email = secureEmail(email,password);var cipher=_crypto2["default"].createCipher(algo,password);var crypted=cipher.update("valid" + token,"utf8","hex");crypted += cipher.final("hex");this.data[email] = crypted;this.save();};TokenCacher.prototype.save = function save(){_fs2["default"].writeFile(this.savePath,JSON.stringify(this.data));};TokenCacher.prototype.getToken = function getToken(){var email=arguments.length <= 0 || arguments[0] === undefined?"":arguments[0];var password=arguments.length <= 1 || arguments[1] === undefined?"":arguments[1];email = secureEmail(email,password);if(this.data[email]){try{var decipher=_crypto2["default"].createDecipher(algo,password);var dec=decipher.update(this.data[email],"hex","utf8");dec += decipher.final("utf8");return dec.indexOf("valid") === 0?dec.substr(5):false;}catch(e) { // not a valid token
|
||||
return null;}}else {return null;}};TokenCacher.prototype.init = function init(ind){var _this=this;var self=this;var savePath=savePaths[ind]; // Use one async function at the beginning, so the entire function is async,
|
||||
// then later use only sync functions to increase readability
|
||||
_fs2["default"].stat(savePath,function(err,dirStats){ // Directory does not exist.
|
||||
if(err)error(err);else {try{var storeDirPath=savePath + "/.discordjs";var filePath=storeDirPath + "/tokens.json";if(!exists(storeDirPath)){ // First, make sure the directory exists, otherwise the next
|
||||
// call will fail.
|
||||
_fs2["default"].mkdirSync(storeDirPath);}if(!exists(filePath)){ // This will create an empty file if the file doesn't exist, and error
|
||||
// if it does exist. We previously checked that it doesn't exist so we
|
||||
// can do this safely.
|
||||
_fs2["default"].closeSync(_fs2["default"].openSync(filePath,'wx'));}var data=_fs2["default"].readFileSync(filePath);try{_this.data = JSON.parse(data);_this.savePath = filePath;_this.emit('ready');_this.done = true;}catch(e) { // not valid JSON, make it valid and then write
|
||||
_fs2["default"].writeFileSync(filePath,'{}');_this.savePath = filePath;_this.emit("ready");_this.done = true;}}catch(e) {error(e);}}});function error(e){ind++;if(!savePaths[ind]){self.emit("error");self.error = e;self.done = true;}else {self.init(ind);}}};return TokenCacher;})(_events2["default"]);exports["default"] = TokenCacher;module.exports = exports["default"];
|
||||
|
||||
Reference in New Issue
Block a user