MCPcopy Create free account
hub / github.com/SheepChef/Abracadabra / append_code

Function append_code

src/javascript/unishox2.js:169–218  ·  view source on GitHub ↗
(out, olen, ol, code, state, usx_hcodes, usx_hcode_lens)

Source from the content-addressed store, hash-verified

167}
168
169function append_code(out, olen, ol, code, state, usx_hcodes, usx_hcode_lens) {
170 var hcode = code >> 5;
171 var vcode = code & 0x1f;
172 if (usx_hcode_lens[hcode] == 0 && hcode != USX_ALPHA) return [ol, state];
173 switch (hcode) {
174 case USX_ALPHA:
175 if (state != USX_ALPHA) {
176 ol = append_switch_code(out, olen, ol, state);
177 ol = append_bits(
178 out,
179 olen,
180 ol,
181 usx_hcodes[USX_ALPHA],
182 usx_hcode_lens[USX_ALPHA]
183 );
184 state = USX_ALPHA;
185 }
186 break;
187 case USX_SYM:
188 ol = append_switch_code(out, olen, ol, state);
189 ol = append_bits(
190 out,
191 olen,
192 ol,
193 usx_hcodes[USX_SYM],
194 usx_hcode_lens[USX_SYM]
195 );
196 break;
197 case USX_NUM:
198 if (state != USX_NUM) {
199 ol = append_switch_code(out, olen, ol, state);
200 ol = append_bits(
201 out,
202 olen,
203 ol,
204 usx_hcodes[USX_NUM],
205 usx_hcode_lens[USX_NUM]
206 );
207 if (
208 usx_sets[hcode].charCodeAt(vcode) >= 48 &&
209 usx_sets[hcode].charCodeAt(vcode) <= 57
210 )
211 state = USX_NUM;
212 }
213 }
214 return [
215 append_bits(out, olen, ol, usx_vcodes[vcode], usx_vcode_lens[vcode]),
216 state,
217 ];
218}
219
220const count_bit_lens = new Uint8Array([2, 4, 7, 11, 16]);
221const count_adder = [4, 20, 148, 2196, 67732];

Callers 1

unishox2_compressFunction · 0.85

Calls 2

append_switch_codeFunction · 0.85
append_bitsFunction · 0.85

Tested by

no test coverage detected