fix: append large parser collections safely

This commit is contained in:
2026-07-22 19:59:59 +02:00
parent 622f1e94dd
commit 72b95c828a
4 changed files with 37 additions and 2 deletions

21
tests/append.test.ts Normal file
View File

@@ -0,0 +1,21 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
// SPDX-License-Identifier: MPL-2.0
import { describe, expect, it } from 'vitest';
import { appendItems } from '../src/onenote/model/append.js';
describe('bounded collection append', () => {
it('does not use a variadic call for argument-limit-sized collections', () => {
const source = Array.from({ length: 200_000 }, (_, index) => index);
const target = [-1];
appendItems(target, source);
expect(target).toHaveLength(200_001);
expect(target[0]).toBe(-1);
expect(target.at(-1)).toBe(199_999);
});
});