Skip to content

metadata failure with long arrays  #3

@wtfrank

Description

@wtfrank
import { Codec } from '../src/utf15';
const codec = new Codec({ depth: 8, array: 1});
let data = [];
for (let x = 0; x < 32768; ++x)
    data.push(1);
let enc_str = codec.encode(data);

 RangeError: [utf15][RangeError]: x out of bounds: 32768
  at assert (src/utf15.js:39:30)
  at num_to_code_point (src/utf15.js:44:9)
  at Codec.encode_array (src/utf15.js:107:41)
  at Codec.encode (src/utf15.js:221:36)

It happens when an array of data has a length greater than can be expressed by a 15-bit number.

    if(!depth_is_array) // Save array length as meta
        res += String.fromCodePoint(num_to_code_point(values.length));

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions