updated some stuff
parent
7d3c4196ab
commit
d6e34762d7
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "frigid",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.4",
|
||||
"main": "out/index.js",
|
||||
"types": "out/index.d.ts",
|
||||
"license": "MIT",
|
||||
|
|
|
|||
|
|
@ -152,18 +152,19 @@ export default class Serializable {
|
|||
async restore() {}
|
||||
|
||||
static createFromDisk(filename: string, ...args: any[]) {
|
||||
if(existsSync(filename)) {
|
||||
const instance = this.deserialize(readFileSync(createFilepath(filename)));
|
||||
const filepath = 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-ignore
|
||||
instance[Serializable.PERSIST_LOCATION] = createFilepath(filename);
|
||||
instance[Serializable.PERSIST_LOCATION] = filepath;
|
||||
instance?.restore();
|
||||
return instance;
|
||||
} else {
|
||||
const instance = new this(...args);
|
||||
// again... TS is wrong...
|
||||
// @ts-ignore
|
||||
instance[Serializable.PERSIST_LOCATION] = createFilepath(filename);
|
||||
instance[Serializable.PERSIST_LOCATION] = filepath;
|
||||
instance?.updateDisk();
|
||||
return instance;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
export {default as Serializable} from './Serializable';
|
||||
export {default as Serializable} from './Serializable.js';
|
||||
|
|
@ -4,7 +4,8 @@
|
|||
"module": "ES2020",
|
||||
"moduleResolution": "Node",
|
||||
"outDir": "out",
|
||||
"declaration": true
|
||||
"declaration": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
|
|
|
|||
Reference in New Issue