Skip to content

Commit

Permalink
deps: Moves peer @types to included deps
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobo committed Oct 8, 2022
1 parent 879e4f6 commit 12af51d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
"packageManager": "yarn@3.2.0",
"dependencies": {
"@brillout/load-module": "^0.1.1",
"@types/lokijs": "^1.5.7",
"@types/pg": "^8",
"abort-controller": "^3.0.0",
"cron-parser": "^4.4.0",
"lokijs": "^1.5.12",
Expand All @@ -97,10 +99,8 @@
"@commitlint/config-conventional": "^15.0.0",
"@types/benchmark": "^2",
"@types/eslint": "*",
"@types/lokijs": "^1.5.7",
"@types/luxon": "^2",
"@types/node": "^17.0.41",
"@types/pg": "^8",
"@types/uuid": "^8",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
Expand Down
17 changes: 13 additions & 4 deletions src/driver/loki.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import { DateTime } from "luxon";
import Loki from "lokijs";
import Loki, { type Collection } from "lokijs";
import { v4 } from "uuid";
import { DriverError, MaxAttemptsExceededError } from "../error.js";
import { QueueDoc } from "../types.js";
import { BaseDriver } from "./base.js";
import { loadModule } from "@brillout/load-module";

// extract the loki memory adapter for convienence
const LokiMemoryAdapter = Loki.LokiMemoryAdapter;
// not exported from @types/lokijs, so replicated here
// src: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lokijs/index.d.ts
interface LokiObj {
$loki: number;
meta: {
created: number; // Date().getTime()
revision: number;
updated: number; // Date().getTime()
version: number;
};
}

/** A modified QueueDoc to support loki dates as strings */
type LokiRepeat = Omit<QueueDoc["repeat"], "last"> & {
Expand Down Expand Up @@ -78,7 +87,7 @@ const nullish = {
export const getClient = (identifier: string) => {
if (!clients[identifier]) {
clients[identifier] = new Loki(identifier, {
adapter: new LokiMemoryAdapter({ asyncResponses: true }),
adapter: new Loki.LokiMemoryAdapter({ asyncResponses: true }),
});
}
return clients[identifier];
Expand Down

0 comments on commit 12af51d

Please # to comment.