Compare commits
No commits in common. "main" and "v2023.02.23-1" have entirely different histories.
main
...
v2023.02.2
2 changed files with 11 additions and 15 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mit.db",
|
||||
"version": "2023.04.12",
|
||||
"version": "2023.02.23-1",
|
||||
"description": "An easy and quick database",
|
||||
"main": "build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
|
@ -11,7 +11,7 @@
|
|||
"type": "git",
|
||||
"url": "git+https://github.com/ThunderNetworkRaD/mit.db.git"
|
||||
},
|
||||
"author": "ThunderNetworkRaD | Killer Boss Original",
|
||||
"author": "Thunder Network Development | Killer Boss Original",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/ThunderNetworkRaD/mit.db/issues"
|
||||
|
@ -20,6 +20,6 @@
|
|||
"devDependencies": {
|
||||
"@types/node": "^18.14.0",
|
||||
"tslib": "^2.4.1",
|
||||
"typescript": "^5.0.3"
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
}
|
||||
|
|
18
src/index.ts
18
src/index.ts
|
@ -5,9 +5,6 @@ const writeDB = promisify(fs.writeFile);
|
|||
|
||||
class MitDB {
|
||||
readonly db;
|
||||
filename: string;
|
||||
options: any;
|
||||
dirname: string;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
|
@ -16,18 +13,17 @@ class MitDB {
|
|||
* @param options Options to pass in the constructor
|
||||
* @param options.dirname where to put the database?
|
||||
*/
|
||||
constructor(filename: string, options?: { dirname: string }) {
|
||||
constructor(fn: string, options?: { dirname: string }) {
|
||||
let dirname;
|
||||
if (options && options.dirname) {
|
||||
this.dirname = options.dirname;
|
||||
dirname = options.dirname;
|
||||
} else {
|
||||
this.dirname = 'data';
|
||||
dirname = 'data';
|
||||
}
|
||||
|
||||
this.filename = filename;
|
||||
if (!fs.existsSync(dirname)) fs.mkdirSync(dirname);
|
||||
|
||||
if (!fs.existsSync(this.dirname)) fs.mkdirSync(this.dirname);
|
||||
|
||||
this.db = `./${this.dirname}/${this.filename}`;
|
||||
this.db = `./${dirname}/${fn}`
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,7 +97,7 @@ class MitDB {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param callbackfilename
|
||||
* @param callbackfn
|
||||
*/
|
||||
forEach(callback: (value: any, key: any) => void) {
|
||||
const file = fs.readFileSync(this.db);
|
||||
|
|
Loading…
Reference in a new issue