@@ -29,14 +29,7 @@ export default class Subspace<KeyIn = NativeValue, KeyOut = Buffer, ValIn = Nati
2929
3030 _bakedKeyXf : Transformer < KeyIn , KeyOut > // This is cached from _prefix + keyXf.
3131
32- _noDefaultPrefix : boolean
33-
34- constructor (
35- rawPrefix : string | Buffer | null ,
36- keyXf ?: Transformer < KeyIn , KeyOut > ,
37- valueXf ?: Transformer < ValIn , ValOut > ,
38- noDefaultPrefix : boolean = false
39- ) {
32+ constructor ( rawPrefix : string | Buffer | null , keyXf ?: Transformer < KeyIn , KeyOut > , valueXf ?: Transformer < ValIn , ValOut > ) {
4033 this . prefix = rawPrefix != null ? Buffer . from ( rawPrefix ) : EMPTY_BUF
4134
4235 // Ugh typing this is a mess. Usually this will be fine since if you say new
@@ -45,24 +38,6 @@ export default class Subspace<KeyIn = NativeValue, KeyOut = Buffer, ValIn = Nati
4538 this . valueXf = valueXf || ( defaultTransformer as Transformer < any , any > )
4639
4740 this . _bakedKeyXf = rawPrefix ? prefixTransformer ( rawPrefix , this . keyXf ) : this . keyXf
48-
49- this . _noDefaultPrefix = noDefaultPrefix
50- }
51-
52- /**
53- * Switch to a new mode of handling ranges. By default, the range operations (`getRange` family
54- * and `clearRange`) treat calls with missing end key as operations on prefix ranges. That means
55- * that a call like `tn.at('a').getRange('x')` acts on prefix `ax`, ie key range `[ax, ay)`. In
56- * the new mode, the missing end key defaults to a subspace end (inclusive), ie that call would
57- * act on a range `[ax, b)`. This enabled specifying key ranges not possible before.
58- *
59- * To specifiy range as a prefix, use `StartsWith` version of those methods (eg
60- * `getRangeAllStartsWith`).
61- *
62- * @see Subspace.packRange
63- */
64- noDefaultPrefix ( ) {
65- return new Subspace ( this . prefix , this . keyXf , this . valueXf , true )
6641 }
6742
6843 // All these template parameters make me question my life choices, but this is
@@ -76,21 +51,21 @@ export default class Subspace<KeyIn = NativeValue, KeyOut = Buffer, ValIn = Nati
7651 // ***
7752 at ( prefix : KeyIn | null , keyXf : Transformer < any , any > = this . keyXf , valueXf : Transformer < any , any > = this . valueXf ) {
7853 const _prefix = prefix == null ? null : this . keyXf . pack ( prefix )
79- return new Subspace ( concatPrefix ( this . prefix , _prefix ) , keyXf , valueXf , this . _noDefaultPrefix )
54+ return new Subspace ( concatPrefix ( this . prefix , _prefix ) , keyXf , valueXf )
8055 }
8156
8257 /** At a child prefix thats specified without reference to the key transformer */
8358 atRaw ( prefix : Buffer ) {
84- return new Subspace ( concatPrefix ( this . prefix , prefix ) , this . keyXf , this . valueXf , this . _noDefaultPrefix )
59+ return new Subspace ( concatPrefix ( this . prefix , prefix ) , this . keyXf , this . valueXf )
8560 }
8661
8762
8863 withKeyEncoding < CKI , CKO > ( keyXf : Transformer < CKI , CKO > ) : Subspace < CKI , CKO , ValIn , ValOut > {
89- return new Subspace ( this . prefix , keyXf , this . valueXf , this . _noDefaultPrefix )
64+ return new Subspace ( this . prefix , keyXf , this . valueXf )
9065 }
9166
9267 withValueEncoding < CVI , CVO > ( valXf : Transformer < CVI , CVO > ) : Subspace < KeyIn , KeyOut , CVI , CVO > {
93- return new Subspace ( this . prefix , this . keyXf , valXf , this . _noDefaultPrefix )
68+ return new Subspace ( this . prefix , this . keyXf , valXf )
9469 }
9570
9671 // GetSubspace implementation
@@ -128,21 +103,10 @@ export default class Subspace<KeyIn = NativeValue, KeyOut = Buffer, ValIn = Nati
128103 * Encodes a range specified by `start`/`end` pair using configured key encoder.
129104 *
130105 * @param start Start of the key range. If undefined, the start of the subspace is assumed.
131- * @param end End of the key range. If undefined, the end of the subspace is assumed, unless
132- * `noDefaultPrefix` flag is set or enabled for this subspace, in which case, start key is treated
133- * as a prefix.
134- * @param noDefaultPrefix Disable treating start key as a prefix if end key is not specified.
106+ * @param end End of the key range. If undefined, the end of the subspace is assumed.
135107 * @returns Encoded range as a `{ begin, end }` record.
136108 */
137- packRange (
138- start ?: KeyIn ,
139- end ?: KeyIn ,
140- noDefaultPrefix : boolean = false
141- ) : { begin : NativeValue , end : NativeValue } {
142- if ( start !== undefined && end === undefined && ! this . _noDefaultPrefix && ! noDefaultPrefix ) {
143- return this . packRangeStartsWith ( start )
144- }
145-
109+ packRange ( start ?: KeyIn , end ?: KeyIn ) : { begin : NativeValue , end : NativeValue } {
146110 return {
147111 begin : start !== undefined ? this . _bakedKeyXf . pack ( start ) : this . prefix ,
148112 end : end !== undefined ? this . _bakedKeyXf . pack ( end ) : strInc ( this . prefix )
0 commit comments