addData()

in src/data/source.ts [72:96]


    addData(offset: number, istringData: IStringData<S, StringIndex[]>) {
        const indexMapping: StringIndex[] = new Array(istringData.strings.length);
        let iMappingInd = 0;
        for (const s of istringData.strings) {
            const existing = this.#stringIndex.get(s);
            let mappedValue;
            if (existing !== undefined) {
                mappedValue = existing;
            } else {
                if (this.#strings.length === this.#sizeLimit) {
                    if (this.#values.BYTES_PER_ELEMENT === 1) {
                        this.#values = new Uint16Array(this.#values);
                    } else {
                        this.#values = new Uint32Array(this.#values);
                    }
                    this.#sizeLimit = Math.pow(256, this.#values.BYTES_PER_ELEMENT);
                }
                this.#stringIndex.set(s, this.#strings.length);
                mappedValue = this.#strings.length;
                this.#strings.push(s);
            }
            indexMapping[iMappingInd++] = mappedValue;
        }
        this.#values.set(istringData.values.map(v => indexMapping[v]), offset);
    }