Skip to content

🎥 Make videos programmatically with React

remove array of length

Jonny Burger7769ac453076
diff --git a/packages/compositor-darwin-arm64/remotion b/packages/compositor-darwin-arm64/remotion
index 6067b9a8cc..1ad855df38 100755
Binary files a/packages/compositor-darwin-arm64/remotion and b/packages/compositor-darwin-arm64/remotion differ
diff --git a/packages/paths/src/interpolate-path/array-of-length.ts b/packages/paths/src/interpolate-path/array-of-length.ts
deleted file mode 100644
index d9bc26cbab..0000000000
--- a/packages/paths/src/interpolate-path/array-of-length.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export function arrayOfLength<T>(length: number, value: T): T[] {
- const array = Array(length);
- for (let i = 0; i < length; i++) {
- array[i] = value;
- }
-
- return array;
-}
diff --git a/packages/paths/src/interpolate-path/extend-command.ts b/packages/paths/src/interpolate-path/extend-command.ts
index f711745053..c1401b2d18 100644
--- a/packages/paths/src/interpolate-path/extend-command.ts
+++ b/packages/paths/src/interpolate-path/extend-command.ts
@@ -1,5 +1,4 @@
import type {ReducedInstruction} from '../helpers/types';
-import {arrayOfLength} from './array-of-length';
import {splitSegmentInstructions} from './split-segment';
/**
@@ -29,26 +28,25 @@ export function extendInstruction(
// should be added in that segment (should always be >= 1 since we need each
// point itself).
// 0 = segment 0-1, 1 = segment 1-2, n-1 = last vertex
- const countPointsPerSegment = arrayOfLength<undefined>(
- numReferenceSegments,
- undefined,
- ).reduce(
- (accum, _d, i) => {
- const insertIndex = Math.floor(segmentRatio * i);
+ const countPointsPerSegment = new Array(numReferenceSegments)
+ .fill(undefined)
+ .reduce(
+ (accum, _d, i) => {
+ const insertIndex = Math.floor(segmentRatio * i);
- accum[insertIndex] = (accum[insertIndex] || 0) + 1;
+ accum[insertIndex] = (accum[insertIndex] || 0) + 1;
- return accum;
- },
- [] as (undefined | number)[],
- );
+ return accum;
+ },
+ [] as (undefined | number)[],
+ ) as number[];
// extend each segment to have the correct number of points for a smooth interpolation
const extended = countPointsPerSegment.reduce(
(_extended, segmentCount, i) => {
// if last command, just add `segmentCount` number of times
if (i === commandsToExtend.length - 1) {
- const lastCommandCopies = arrayOfLength(segmentCount as number, {
+ const lastCommandCopies = new Array(segmentCount as number).fill({
...commandsToExtend[commandsToExtend.length - 1],
});
diff --git a/packages/paths/src/interpolate-path/split-segment.ts b/packages/paths/src/interpolate-path/split-segment.ts
index 8222304801..90d248cd43 100644
--- a/packages/paths/src/interpolate-path/split-segment.ts
+++ b/packages/paths/src/interpolate-path/split-segment.ts
@@ -1,5 +1,4 @@
import type {ReducedInstruction} from '../helpers/types';
-import {arrayOfLength} from './array-of-length';
import {splitCurveInstructions} from './split-curve';
/**
@@ -51,7 +50,7 @@ export function splitSegmentInstructions(
: commandStart;
segments = segments.concat(
- arrayOfLength(segmentCount - 1, undefined).map(() => copyCommand),
+ new Array(segmentCount - 1).fill(true).map(() => copyCommand),
);
segments.push(commandEnd);
}