test
This commit is contained in:
parent
41d589ccbc
commit
363492aef5
1 changed files with 3 additions and 1 deletions
|
@ -5,6 +5,8 @@ const writeDB = promisify(fs.writeFile);
|
||||||
|
|
||||||
class MitDB {
|
class MitDB {
|
||||||
readonly db;
|
readonly db;
|
||||||
|
fn: string;
|
||||||
|
options?: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
|
@ -37,7 +39,7 @@ class MitDB {
|
||||||
const data: any[] = JSON.parse(file.toString());
|
const data: any[] = JSON.parse(file.toString());
|
||||||
|
|
||||||
const i = data.findIndex((pair: any) => pair.key == key);
|
const i = data.findIndex((pair: any) => pair.key == key);
|
||||||
|
|
||||||
!data[i] ? data.push({ key, value }) : data[i] = { key, value };
|
!data[i] ? data.push({ key, value }) : data[i] = { key, value };
|
||||||
|
|
||||||
await writeDB(this.db, JSON.stringify(data));
|
await writeDB(this.db, JSON.stringify(data));
|
||||||
|
|
Loading…
Reference in a new issue