@@ -54,6 +54,52 @@ class RoaringBitmap {
5454 }
5555 this . consumed_len_bytes = pspecial - i ;
5656 return this ;
57+ } else if ( u8array [ i ] > 0xe0 ) {
58+ // Special representation of tiny sets that are runs
59+ const lspecial = u8array [ i ] & 0x0f ;
60+ this . keysAndCardinalities = new Uint8Array ( lspecial * 4 ) ;
61+ i += 1 ;
62+ const key = u8array [ i + 2 ] | ( u8array [ i + 3 ] << 8 ) ;
63+ const value = u8array [ i ] | ( u8array [ i + 1 ] << 8 ) ;
64+ const container = new RoaringBitmapRun ( 1 , new Uint8Array ( 4 ) ) ;
65+ container . array [ 0 ] = value & 0xFF ;
66+ container . array [ 1 ] = ( value >> 8 ) & 0xFF ;
67+ container . array [ 2 ] = lspecial - 1 ;
68+ this . containers . push ( container ) ;
69+ this . keysAndCardinalities [ 0 ] = key & 0xFF ;
70+ this . keysAndCardinalities [ 1 ] = ( key >> 8 ) & 0xFF ;
71+ this . keysAndCardinalities [ 2 ] = lspecial - 1 ;
72+ this . consumed_len_bytes = 5 ;
73+ return this ;
74+ } else if ( u8array [ i ] > 0xd0 ) {
75+ // Special representation of tiny sets that are close together
76+ const lspecial = u8array [ i ] & 0x0f ;
77+ this . keysAndCardinalities = new Uint8Array ( lspecial * 4 ) ;
78+ let pspecial = i + 1 ;
79+ let key = u8array [ pspecial + 2 ] | ( u8array [ pspecial + 3 ] << 8 ) ;
80+ let value = u8array [ pspecial ] | ( u8array [ pspecial + 1 ] << 8 ) ;
81+ let entry = ( key << 16 ) | value ;
82+ let container ;
83+ container = new RoaringBitmapArray ( 1 , new Uint8Array ( 4 ) ) ;
84+ container . array [ 0 ] = value & 0xFF ;
85+ container . array [ 1 ] = ( value >> 8 ) & 0xFF ;
86+ this . containers . push ( container ) ;
87+ this . keysAndCardinalities [ 0 ] = key ;
88+ this . keysAndCardinalities [ 1 ] = key >> 8 ;
89+ pspecial += 4 ;
90+ for ( let ispecial = 1 ; ispecial < lspecial ; ispecial += 1 ) {
91+ entry += u8array [ pspecial ] ;
92+ value = entry & 0xffff ;
93+ key = entry >> 16 ;
94+ container = this . addToArrayAt ( key ) ;
95+ const cardinalityOld = container . cardinality ;
96+ container . array [ cardinalityOld * 2 ] = value & 0xFF ;
97+ container . array [ ( cardinalityOld * 2 ) + 1 ] = ( value >> 8 ) & 0xFF ;
98+ container . cardinality = cardinalityOld + 1 ;
99+ pspecial += 1 ;
100+ }
101+ this . consumed_len_bytes = pspecial - i ;
102+ return this ;
57103 } else if ( u8array [ i ] < 0x3a ) {
58104 // Special representation of tiny sets with arbitrary 32-bit integers
59105 const lspecial = u8array [ i ] ;
@@ -2282,7 +2328,7 @@ function loadDatabase(hooks) {
22822328 */
22832329 class InlineNeighborsTree {
22842330 /**
2285- * @param {Uint8Array<ArrayBuffer> } encoded
2331+ * @param {Uint8Array } encoded
22862332 * @param {number } start
22872333 */
22882334 constructor (
@@ -2313,6 +2359,7 @@ function loadDatabase(hooks) {
23132359 leaves_count = 0 ;
23142360 }
23152361 i += 1 ;
2362+ /** @type {Uint8Array } */
23162363 let data = EMPTY_UINT8 ;
23172364 if ( ! is_suffixes_only && dlen !== 0 ) {
23182365 data = encoded . subarray ( i , i + dlen ) ;
@@ -2326,6 +2373,7 @@ function loadDatabase(hooks) {
23262373 const branch_dlen = encoded [ i ] & 0x0f ;
23272374 const branch_leaves_count = ( ( encoded [ i ] >> 4 ) & 0x0f ) + 1 ;
23282375 i += 1 ;
2376+ /** @type {Uint8Array } */
23292377 let branch_data = EMPTY_UINT8 ;
23302378 if ( ! is_suffixes_only && branch_dlen !== 0 ) {
23312379 branch_data = encoded . subarray ( i , i + branch_dlen ) ;
@@ -2654,7 +2702,7 @@ function loadDatabase(hooks) {
26542702
26552703 /**
26562704 * @param {string } inputBase64
2657- * @returns {[Uint8Array<ArrayBuffer> , SearchTree] }
2705+ * @returns {[Uint8Array, SearchTree] }
26582706 */
26592707 function makeSearchTreeFromBase64 ( inputBase64 ) {
26602708 const input = makeUint8ArrayFromBase64 ( inputBase64 ) ;
@@ -3305,7 +3353,7 @@ if (typeof window !== "undefined") {
33053353// eslint-disable-next-line max-len
33063354// polyfill https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/fromBase64
33073355/**
3308- * @type {function(string): Uint8Array<ArrayBuffer> } base64
3356+ * @type {function(string): Uint8Array } base64
33093357 */
33103358//@ts -expect-error
33113359const makeUint8ArrayFromBase64 = Uint8Array . fromBase64 ? Uint8Array . fromBase64 : ( string => {
@@ -3318,7 +3366,7 @@ const makeUint8ArrayFromBase64 = Uint8Array.fromBase64 ? Uint8Array.fromBase64 :
33183366 return bytes ;
33193367} ) ;
33203368/**
3321- * @type {function(string): Uint8Array<ArrayBuffer> } base64
3369+ * @type {function(string): Uint8Array } base64
33223370 */
33233371//@ts -expect-error
33243372const makeUint8ArrayFromHex = Uint8Array . fromHex ? Uint8Array . fromHex : ( string => {
0 commit comments