Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"eslint/no-unused-private-class-members": "error",
"react/react-in-jsx-scope": "off",
"typescript/no-explicit-any": "error",
"unicorn/no-new-array": "off"
"unicorn/no-new-array": "error"
},
"overrides": [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/hdrify/src/exr/b44Codec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('b44Codec', () => {
});

it('packs a constant block into 3 bytes when flatFields (B44A) is set', () => {
const values = new Array(16).fill(0.5);
const values = Array.from({ length: 16 }).fill(0.5);
const { wcount, decoded } = packAndUnpack(values, true);
expect(wcount).toBe(3);
for (const v of decoded) {
Expand All @@ -43,7 +43,7 @@ describe('b44Codec', () => {
});

it('does not use the 3-byte flat encoding for a constant block when flatFields (B44) is false', () => {
const values = new Array(16).fill(0.5);
const values = Array.from({ length: 16 }).fill(0.5);
const { wcount } = packAndUnpack(values, false);
expect(wcount).toBe(14);
});
Expand Down
16 changes: 8 additions & 8 deletions packages/hdrify/src/exr/pizHuffman.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function getBits(nBits: number, c: number, lc: number, uInt8Array: Uint8Array, i
getBitsReturn.lc = currentLc;
}

const hufTableBuffer = new Array(59);
const hufTableBuffer = Array.from<number>({ length: 59 });

function hufCanonicalCodeTable(hcode: number[]): void {
for (let i = 0; i <= 58; ++i) hufTableBuffer[i] = 0;
Expand Down Expand Up @@ -185,15 +185,15 @@ function hufBuildDecTable(hcode: number[], im: number, iM: number, hdecod: HufDe
pl.lit++;
if (pl.p) {
const p = pl.p;
pl.p = new Array(pl.lit);
pl.p = Array.from({ length: pl.lit });
for (let i = 0; i < pl.lit - 1; ++i) {
const pValue = p[i];
if (pValue !== undefined) {
pl.p[i] = pValue;
}
}
} else {
pl.p = new Array(1);
pl.p = Array.from({ length: 1 });
}
pl.p[pl.lit - 1] = currentIm;
} else if (l) {
Expand Down Expand Up @@ -379,9 +379,9 @@ function countFrequencies(freq: number[], data: Uint16Array, n: number): void {
}

function hufBuildEncTable(frq: number[], im: { value: number }, iM: { value: number }): void {
const hlink = new Array<number>(HUF_ENCSIZE);
const hlink = Array.from<number>({ length: HUF_ENCSIZE });
const fHeap: number[] = [];
const scode = new Array<number>(HUF_ENCSIZE).fill(0);
const scode = Array.from<number>({ length: HUF_ENCSIZE }).fill(0);

im.value = 0;
while (!(frq[im.value] ?? 0)) im.value++;
Expand Down Expand Up @@ -568,7 +568,7 @@ export function hufCompress(raw: Uint16Array): Uint8Array {
const n = raw.length;
if (n === 0) return new Uint8Array(0);

const freq = new Array<number>(HUF_ENCSIZE);
const freq = Array.from<number>({ length: HUF_ENCSIZE });
countFrequencies(freq, raw, n);

const im = { value: 0 };
Expand Down Expand Up @@ -624,8 +624,8 @@ export function hufUncompress(
);
}

const freq = new Array(HUF_ENCSIZE);
const hdec: HufDec[] = new Array(HUF_DECSIZE);
const freq = Array.from<number>({ length: HUF_ENCSIZE });
const hdec: HufDec[] = Array.from({ length: HUF_DECSIZE });
hufClearDecTable(hdec);

const ni = nCompressed - (inOffset.value - initialInOffset);
Expand Down
Loading