updated some stuff
parent
7d3c4196ab
commit
d6e34762d7
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
export {default as Serializable} from './Serializable';
|
export {default as Serializable} from './Serializable.js';
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
Reference in New Issue