Skip to content
This repository was archived by the owner on Sep 24, 2025. It is now read-only.

Commit ca6d4bf

Browse files
committed
feat: simplify the ok function
1 parent f0fc75a commit ca6d4bf

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

src/base.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export abstract class BaseMiftahDB implements IMiftahDB {
124124
expiresAtMs(expiresAt)
125125
);
126126

127-
return OK(true);
127+
return OK();
128128
}
129129

130130
@SafeExecution
@@ -153,7 +153,7 @@ export abstract class BaseMiftahDB implements IMiftahDB {
153153
this.addNamespacePrefix(oldKey)
154154
);
155155

156-
return OK(true);
156+
return OK();
157157
}
158158

159159
@SafeExecution
@@ -163,7 +163,7 @@ export abstract class BaseMiftahDB implements IMiftahDB {
163163
this.addNamespacePrefix(key)
164164
);
165165

166-
return OK(true);
166+
return OK();
167167
}
168168

169169
@SafeExecution
@@ -279,7 +279,7 @@ export abstract class BaseMiftahDB implements IMiftahDB {
279279
}
280280
})();
281281

282-
return OK(true);
282+
return OK();
283283
}
284284

285285
@SafeExecution
@@ -301,7 +301,7 @@ export abstract class BaseMiftahDB implements IMiftahDB {
301301
vacuum(): Result<boolean> {
302302
this.statements.vacuum.run();
303303

304-
return OK(true);
304+
return OK();
305305
}
306306

307307
@SafeExecution
@@ -312,7 +312,7 @@ export abstract class BaseMiftahDB implements IMiftahDB {
312312

313313
this.db.close();
314314

315-
return OK(true);
315+
return OK();
316316
}
317317

318318
@SafeExecution
@@ -339,7 +339,7 @@ export abstract class BaseMiftahDB implements IMiftahDB {
339339

340340
await writeFile(path, uint8Array);
341341

342-
return OK(true);
342+
return OK();
343343
}
344344

345345
@SafeExecution
@@ -349,7 +349,7 @@ export abstract class BaseMiftahDB implements IMiftahDB {
349349
this.db = new DB(file);
350350
this.statements = this.prepareStatements();
351351

352-
return OK(true);
352+
return OK();
353353
}
354354

355355
@SafeExecution

src/bun.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class MiftahDB extends BaseMiftahDB {
4848
this.db = DB.deserialize(file);
4949
this.statements = this.prepareStatements();
5050

51-
return OK(true);
51+
return OK();
5252
}
5353

5454
// Overridden due to difference implementation in `bun:sqlite` and `better-sqlite3`
@@ -63,12 +63,10 @@ export class MiftahDB extends BaseMiftahDB {
6363

6464
this.db.close();
6565

66-
return OK(true);
66+
return OK();
6767
}
6868
}
6969

7070
export type { MiftahValue } from "./types";
7171
export type { Result } from "./types";
7272
export type { PromiseResult } from "./types";
73-
74-
const db = new MiftahDB(":memory:");

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function executeOnExit(fn: () => void) {
4444
}
4545
}
4646

47-
export function OK<T>(data: T): Result<T> {
47+
export function OK<T>(data: T = true as T): Result<T> {
4848
return { success: true, data };
4949
}
5050

0 commit comments

Comments
 (0)