diff --git a/lib/database.ts b/lib/database.ts index 41afec6..6c3b0dc 100644 --- a/lib/database.ts +++ b/lib/database.ts @@ -43,15 +43,28 @@ export default class Database(hasSubspace: GetSubspace): Database - /** Create a shallow reference to the database at the subspace of another database reference */ - // at(prefix: KeyIn | null, keyXf?: Transformer, valueXf?: Transformer): Database - - at(prefix: KeyIn | null): Database; - at(prefix: KeyIn | null, keyXf: Transformer): Database; + at(prefix: KeyIn | null, keyXf?: undefined, valueXf?: undefined): Database; + at(prefix: KeyIn | null, keyXf: Transformer, valueXf?: undefined): Database; at(prefix: KeyIn | null, keyXf: undefined, valueXf: Transformer): Database; at(prefix: KeyIn | null, keyXf: Transformer, valueXf: Transformer): Database; - - at(prefixOrSubspace: GetSubspace | KeyIn | null, keyXf?: Transformer, valueXf?: Transformer): Database { + at(prefix: KeyIn | null, keyXf: Transformer, valueXf?: undefined): + | Database + | Database; + at(prefix: KeyIn | null, keyXf: undefined, valueXf?: Transformer): + | Database + | Database; + at(prefix: KeyIn | null, keyXf: Transformer | undefined, valueXf: Transformer): + | Database + | Database; + at(prefix: KeyIn | null, keyXf: Transformer, valueXf?: Transformer): + | Database + | Database; + at(prefix: KeyIn | null, keyXf?: Transformer, valueXf?: Transformer): + | Database + | Database + | Database + | Database; + at(prefixOrSubspace: GetSubspace | KeyIn | null, keyXf?: Transformer, valueXf?: Transformer) { if (isGetSubspace(prefixOrSubspace)) return new Database(this._db, prefixOrSubspace.getSubspace()) else return new Database(this._db, this.subspace.at(prefixOrSubspace, keyXf, valueXf)) } diff --git a/lib/subspace.ts b/lib/subspace.ts index eb52e0c..dca4c69 100644 --- a/lib/subspace.ts +++ b/lib/subspace.ts @@ -41,11 +41,27 @@ export default class Subspace; - at(prefix: KeyIn | null, keyXf: Transformer): Subspace; + at(prefix: KeyIn | null, keyXf?: undefined, valueXf?: undefined): Subspace; + at(prefix: KeyIn | null, keyXf: Transformer, valueXf?: undefined): Subspace; at(prefix: KeyIn | null, keyXf: undefined, valueXf: Transformer): Subspace; - at(prefix: KeyIn | null, keyXf?: Transformer, valueXf?: Transformer): Subspace; - // *** + at(prefix: KeyIn | null, keyXf: Transformer, valueXf: Transformer): Subspace; + at(prefix: KeyIn | null, keyXf: Transformer, valueXf?: undefined): + | Subspace + | Subspace; + at(prefix: KeyIn | null, keyXf: undefined, valueXf?: Transformer): + | Subspace + | Subspace; + at(prefix: KeyIn | null, keyXf: Transformer | undefined, valueXf: Transformer): + | Subspace + | Subspace; + at(prefix: KeyIn | null, keyXf: Transformer, valueXf?: Transformer): + | Subspace + | Subspace; + at(prefix: KeyIn | null, keyXf?: Transformer, valueXf?: Transformer): + | Subspace + | Subspace + | Subspace + | Subspace; at(prefix: KeyIn | null, keyXf: Transformer = this.keyXf, valueXf: Transformer = this.valueXf) { const _prefix = prefix == null ? null : this.keyXf.pack(prefix) return new Subspace(concatPrefix(this.prefix, _prefix), keyXf, valueXf)