updated some stuff

master
Valerie 2021-06-10 01:40:10 -04:00
parent 7d3c4196ab
commit d6e34762d7
4 changed files with 9 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "frigid", "name": "frigid",
"version": "1.0.0", "version": "1.0.4",
"main": "out/index.js", "main": "out/index.js",
"types": "out/index.d.ts", "types": "out/index.d.ts",
"license": "MIT", "license": "MIT",

View File

@ -152,18 +152,19 @@ export default class Serializable {
async restore() {} async restore() {}
static createFromDisk(filename: string, ...args: any[]) { static createFromDisk(filename: string, ...args: any[]) {
if(existsSync(filename)) { const filepath = createFilepath(filename);
const instance = this.deserialize(readFileSync(createFilepath(filename))); if(existsSync(filepath)) {
const instance = this.deserialize(readFileSync(filepath));
// TS is plain and simply wrong... symbols can be used to index object... // TS is plain and simply wrong... symbols can be used to index object...
// @ts-ignore // @ts-ignore
instance[Serializable.PERSIST_LOCATION] = createFilepath(filename); instance[Serializable.PERSIST_LOCATION] = filepath;
instance?.restore(); instance?.restore();
return instance; return instance;
} else { } else {
const instance = new this(...args); const instance = new this(...args);
// again... TS is wrong... // again... TS is wrong...
// @ts-ignore // @ts-ignore
instance[Serializable.PERSIST_LOCATION] = createFilepath(filename); instance[Serializable.PERSIST_LOCATION] = filepath;
instance?.updateDisk(); instance?.updateDisk();
return instance; return instance;
} }

View File

@ -1 +1 @@
export {default as Serializable} from './Serializable'; export {default as Serializable} from './Serializable.js';

View File

@ -4,7 +4,8 @@
"module": "ES2020", "module": "ES2020",
"moduleResolution": "Node", "moduleResolution": "Node",
"outDir": "out", "outDir": "out",
"declaration": true "declaration": true,
"allowSyntheticDefaultImports": true
}, },
"include": [ "include": [
"src/**/*.ts" "src/**/*.ts"