From 36ff52d196b2f5c39a1752bf96e8dec53fca7980 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 7 Sep 2023 14:44:17 -0700 Subject: [PATCH] feat: buffer-map added for example client --- example/package.json | 3 +- example/tsconfig.json | 5 ++- example/typings/buffer-maps.d.ts | 53 ++++++++++++++++++++++++++++++++ example/yarn.lock | 5 +++ 4 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 example/typings/buffer-maps.d.ts diff --git a/example/package.json b/example/package.json index 4ec3d13..35f4fa2 100644 --- a/example/package.json +++ b/example/package.json @@ -14,6 +14,7 @@ "leveldown": "^6.1.1", "levelup": "^5.1.1", "ts-node": "^10.9.1", - "typescript": "^5.1.6" + "typescript": "^5.1.6", + "buffer-map": "^0.0.7" } } diff --git a/example/tsconfig.json b/example/tsconfig.json index b444886..6f6f103 100644 --- a/example/tsconfig.json +++ b/example/tsconfig.json @@ -1,4 +1,7 @@ { "extends": "../tsconfig.json", - "include": ["./src/**/*.ts"] + "include": ["./src/**/*.ts", "./typings/**/*.d.ts"], + "ts-node": { + "files": true + }, } diff --git a/example/typings/buffer-maps.d.ts b/example/typings/buffer-maps.d.ts new file mode 100644 index 0000000..078dbba --- /dev/null +++ b/example/typings/buffer-maps.d.ts @@ -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 implements Map, 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; + *values(): Generator; + + toKeys(): Buffer[]; + toValues(): T[]; + toArray(): T[]; + } + + export class BufferSet implements Iterable { + constructor(iterable: Iterable | null | undefined = null); + + readonly size: number; + + has(key: Buffer): boolean; + add(key: Buffer): this; + delete(key: Buffer): boolean; + clear(): void; + + [Symbol.iterator](): Iterator; + + *entries(): Generator<[Buffer, Bufferd]>; + keys(): Iterator; + values(): Iterator; + + forEach( + func: (value: Buffer, key: Buffer, set: BufferSet) => void, + self: BuffSet, + ): void; + + toKeys(): Buffer[]; + toValues(): Buffer[]; + toArray(): Buffer[]; + } +} diff --git a/example/yarn.lock b/example/yarn.lock index f7fc20f..d65c92a 100644 --- a/example/yarn.lock +++ b/example/yarn.lock @@ -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"