Skip to content

Commit

Permalink
feat: buffer-map added for example client
Browse files Browse the repository at this point in the history
  • Loading branch information
jowparks committed Sep 7, 2023
1 parent ed24a5d commit c15a397
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
3 changes: 3 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@
"levelup": "^5.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
},
"dependencies": {
"buffer-map": "^0.0.7"
}
}
5 changes: 4 additions & 1 deletion example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"extends": "../tsconfig.json",
"include": ["./src/**/*.ts"]
"include": ["./src/**/*.ts", "./typings/**/*.d.ts"],
"ts-node": {
"files": true
},
}
53 changes: 53 additions & 0 deletions example/typings/buffer-maps.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

declare module "buffer-map" {
export class BufferMap<T> implements Map<Buffer, T>, Iterable<[Buffer, T]> {
constructor(iterable: Iterable<[Buffer, T]> | null | undefined = null);

readonly size: number;

get(key: Buffer): T | undefined;
has(key: Buffer): boolean;
set(key: Buffer, value: T): this;
delete(key: Buffer): boolean;
clear(): void;

[Symbol.iterator](): Iterator<[Buffer, T]>;

*entries(): Generator<[Buffer, T]>;
*keys(): Generator<Buffer>;
*values(): Generator<T>;

toKeys(): Buffer[];
toValues(): T[];
toArray(): T[];
}

export class BufferSet<T = Buffer> implements Iterable<Buffer> {
constructor(iterable: Iterable<T> | null | undefined = null);

readonly size: number;

has(key: Buffer): boolean;
add(key: Buffer): this;
delete(key: Buffer): boolean;
clear(): void;

[Symbol.iterator](): Iterator<Buffer>;

*entries(): Generator<[Buffer, Bufferd]>;
keys(): Iterator<Buffer>;
values(): Iterator<Buffer>;

forEach(
func: (value: Buffer, key: Buffer, set: BufferSet<T>) => void,
self: BuffSet<T>,
): void;

toKeys(): Buffer[];
toValues(): Buffer[];
toArray(): Buffer[];
}
}
5 changes: 5 additions & 0 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ base64-js@^1.3.1:
resolved "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==

buffer-map@^0.0.7:
version "0.0.7"
resolved "https://registry.yarnpkg.com/buffer-map/-/buffer-map-0.0.7.tgz#5c2db65f7b3a723a2d9dff8e896fada3d2dc1c5d"
integrity sha512-95try3p/vMRkIAAnJDaGkFhGpT/65NoeW6XelEPjAomWYR58RQtW4khn0SwKj34kZoE7uxL7w2koZSwbnszvQQ==

buffer@^6.0.3:
version "6.0.3"
resolved "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
Expand Down

0 comments on commit c15a397

Please sign in to comment.