Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use unknown instead of any in Hyperbee types #946

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions types/hyperbee.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ declare module 'hyperbee' {
type Encoding<T> = 'binary' | 'utf-8' | 'ascii' | 'json' | AbstractEncoding<T>

declare namespace Hyperbee {
interface HyperbeeOptions<T = any> {
interface HyperbeeOptions<T = unknown> {
keyEncoding?: Encoding<T>
valueEncoding?: Encoding<T>
}

interface HyperbeeEntry<T = any> {
interface HyperbeeEntry<T = unknown> {
seq: number
key: string
value: T
}

interface PutOptions<T = any> {
interface PutOptions<T = unknown> {
cas?: (prev: HyperbeeEntry<T>, next: HyperbeeEntry<T>) => boolean
}

interface DelOptions<T = any> {
interface DelOptions<T = unknown> {
cas?: (prev: T) => boolean
}

Expand Down Expand Up @@ -51,7 +51,7 @@ declare module 'hyperbee' {
encoding?: Encoding<T>
}

interface DiffStreamEntry<T = any> {
interface DiffStreamEntry<T = unknown> {
left: T
right: T
}
Expand All @@ -63,14 +63,14 @@ declare module 'hyperbee' {
valueEncoding?: 'binary' | 'utf-8' | 'ascii' | 'json' | AbstractEncoding
}

interface SubDatabaseOptions extends HyperbeeOptions<any> {
interface SubDatabaseOptions extends HyperbeeOptions<unknown> {
sep?: Buffer
}

interface HeaderOptions {}
}

class Hyperbee<T = any> {
class Hyperbee<T = unknown> {
constructor(core: Hypercore, options?: Hyperbee.HyperbeeOptions<T>)

ready(): Promise<void>
Expand All @@ -87,18 +87,18 @@ declare module 'hyperbee' {

put(
key: string,
value?: any,
value?: unknown,
options?: Hyperbee.PutOptions<T>
): Promise<void>
del(key: string, options?: Hyperbee.DelOptions<T>): Promise<void>
get(key: string): Promise<Hyperbee.HyperbeeEntry<T> | null>
getBySeq(
seq: number,
options?: any
options?: unknown
): Promise<Omit<Hyperbee.HyperbeeEntry<T>, 'seq'> | null>

batch(): HyperbeeBatch<T>
replicate(isInitiatorOrStream: any): Readable
replicate(isInitiatorOrStream: unknown): Readable
createReadStream(
range?: Hyperbee.ReadStreamRange,
options?: Hyperbee.ReadStreamOptions
Expand All @@ -123,15 +123,15 @@ declare module 'hyperbee' {
): Promise<EntryWatcher<T>>
watch(
range?: Hyperbee.ReadStreamRange
): AsyncIterable<[any, any]> & { close: () => Promise<void> }
): AsyncIterable<[unknown, unknown]> & { close: () => Promise<void> }

checkout(version: number): Hyperbee
snapshot(): Hyperbee

sub(prefix: string, options?: Hyperbee.SubDatabaseOptions): Hyperbee
getHeader(options?: any): Promise<any>
getHeader(options?: unknown): Promise<unknown>

static isHyperbee(core: Hypercore, options?: any): Promise<boolean>
static isHyperbee(core: Hypercore, options?: unknown): Promise<boolean>
}

class HyperbeeBatch<T> {
Expand All @@ -150,7 +150,7 @@ declare module 'hyperbee' {
close(): Promise<void>
}

interface AbstractEncoding<T = any> {
interface AbstractEncoding<T = unknown> {
encode: (data: T) => Buffer
encode: (data: T, buffer: Buffer) => Buffer
encode: (data: T, buffer: Buffer, offset: number) => Buffer
Expand Down
Loading