Skip to content

Commit

Permalink
Try to add custom shims
Browse files Browse the repository at this point in the history
  • Loading branch information
zjkmxy committed Jan 19, 2024
1 parent ae342f5 commit 20eb143
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
4 changes: 4 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ if (import.meta.main) {
shims: {
// Do not shim Deno. It conflicts with the browser.
deno: false,
custom: [{
module: './types/deno.d.ts',
globalNames: ['Deno'],
}],
},
test: false, // Required due to some dependencies do not include test files.
esModule: true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ucla-irl/ndnts-aux",
"version": "1.0.3",
"version": "1.0.4",
"description": "NDNts Auxiliary Package for Web and Deno",
"scripts": {
"test": "deno test",
Expand Down
1 change: 0 additions & 1 deletion src/storage/deno-kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Storage } from './types.ts';

/**
* A storage based on DenoKV.
* Not actually included in the exported package. May need Custom Shims.
*/
export class DenoKvStorage implements Storage {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/storage/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './types.ts';
export * from './in-memory.ts';
export * from './file-system.ts';
// export * from './deno-kv.ts';
export * from './deno-kv.ts';
29 changes: 29 additions & 0 deletions types/deno.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// declare namespace Deno {
// }
declare namespace Deno {
export function openKv(path?: string): Promise<Deno.Kv>;

export class Kv implements Disposable {
get<T = unknown>(
key: any,
options?: { consistency?: KvConsistencyLevel },
): Promise<T>;

set(
key: any,
value: unknown,
options?: { expireIn?: number },
): Promise<any>;

delete(key: any): Promise<any>;

list(
selector: any,
options?: any,
): any;

close(): void;

[Symbol.dispose](): void;
}
}

0 comments on commit 20eb143

Please sign in to comment.