@remotion/serverless-client 4.0.363 → 4.0.365

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/esm/index.mjs +4 -4
  2. package/package.json +5 -5
  3. package/.turbo/turbo-formatting.log +0 -4
  4. package/.turbo/turbo-lint.log +0 -15
  5. package/.turbo/turbo-make.log +0 -3
  6. package/bundle.ts +0 -15
  7. package/dist/test/best-frames.test.d.ts +0 -1
  8. package/dist/test/best-frames.test.js +0 -16
  9. package/dist/test/dont-contain-forbidden.test.d.ts +0 -1
  10. package/dist/test/dont-contain-forbidden.test.js +0 -18
  11. package/dist/test/expected-out-name.test.d.ts +0 -1
  12. package/dist/test/expected-out-name.test.js +0 -168
  13. package/dist/test/min-max.test.d.ts +0 -1
  14. package/dist/test/min-max.test.js +0 -24
  15. package/dist/test/most-expensive-chunks.test.d.ts +0 -1
  16. package/dist/test/most-expensive-chunks.test.js +0 -163
  17. package/eslint.config.mjs +0 -5
  18. package/src/await.ts +0 -1
  19. package/src/best-frames-per-function-param.ts +0 -18
  20. package/src/calculate-chunk-times.ts +0 -42
  21. package/src/compress-props.ts +0 -179
  22. package/src/constants.ts +0 -408
  23. package/src/docs-url.ts +0 -1
  24. package/src/error-category.ts +0 -14
  25. package/src/estimate-price-from-bucket.ts +0 -59
  26. package/src/expected-out-name.ts +0 -83
  27. package/src/format-costs-info.ts +0 -24
  28. package/src/get-custom-out-name.ts +0 -44
  29. package/src/get-files-in-folder.ts +0 -6
  30. package/src/get-or-create-bucket.ts +0 -85
  31. package/src/get-overall-progress-from-storage.ts +0 -47
  32. package/src/get-overall-progress.ts +0 -42
  33. package/src/index.ts +0 -125
  34. package/src/input-props-keys.ts +0 -7
  35. package/src/inspect-error.ts +0 -63
  36. package/src/make-bucket-name.ts +0 -9
  37. package/src/make-timeout-error.ts +0 -51
  38. package/src/make-timeout-message.ts +0 -118
  39. package/src/min-max.ts +0 -34
  40. package/src/most-expensive-chunks.ts +0 -46
  41. package/src/overall-render-progress.ts +0 -30
  42. package/src/progress.ts +0 -330
  43. package/src/provider-implementation.ts +0 -268
  44. package/src/render-has-audio-video.ts +0 -28
  45. package/src/render-metadata.ts +0 -61
  46. package/src/render-progress.ts +0 -58
  47. package/src/return-values.ts +0 -45
  48. package/src/serialize-artifact.ts +0 -66
  49. package/src/stream-to-string.ts +0 -14
  50. package/src/streaming/streaming.ts +0 -148
  51. package/src/test/best-frames.test.ts +0 -15
  52. package/src/test/dont-contain-forbidden.test.ts +0 -14
  53. package/src/test/expected-out-name.test.ts +0 -200
  54. package/src/test/min-max.test.ts +0 -25
  55. package/src/test/most-expensive-chunks.test.ts +0 -167
  56. package/src/truthy.ts +0 -5
  57. package/src/types.ts +0 -82
  58. package/src/validate-bucket-name.ts +0 -34
  59. package/src/validate-download-behavior.ts +0 -26
  60. package/src/validate-frames-per-function.ts +0 -125
  61. package/src/validate-outname.ts +0 -63
  62. package/src/validate-privacy.ts +0 -20
  63. package/src/validate-webhook.ts +0 -18
  64. package/src/webhook-types.ts +0 -36
  65. package/src/write-error-to-storage.ts +0 -23
  66. package/tsconfig.json +0 -18
  67. package/tsconfig.tsbuildinfo +0 -1
@@ -1,14 +0,0 @@
1
- import {expect, test} from 'bun:test';
2
- import path from 'path';
3
-
4
- test('Should not contain forbidden imports', async () => {
5
- const output = await Bun.build({
6
- external: ['@remotion/renderer', 'react/jsx-runtime'],
7
- entrypoints: [path.join(__filename, '..', '..', 'index.ts')],
8
- });
9
- expect(output.outputs.length).toBe(1);
10
- const text = await output.outputs[0].text();
11
- expect(text).not.toContain('jsx-runtime');
12
- expect(text).not.toContain('"@remotion/renderer"');
13
- expect(text).not.toContain("'@remotion/renderer'");
14
- });
@@ -1,200 +0,0 @@
1
- import {expect, test} from 'bun:test';
2
- import {getExpectedOutName} from '../expected-out-name';
3
- import type {RenderMetadata} from '../render-metadata';
4
-
5
- const bucketName = 'remotionlambda-98fsduf';
6
-
7
- type MockProvider = {
8
- type: 'aws';
9
- region: 'eu-central';
10
- receivedArtifactType: {
11
- s3Key: string;
12
- s3Url: string;
13
- };
14
- creationFunctionOptions: {};
15
- storageClass: string;
16
- requestHandler: null;
17
- };
18
-
19
- const testRenderMetadata: RenderMetadata<MockProvider> = {
20
- compositionId: 'react-svg',
21
- estimatedRenderLambdaInvokations: 100,
22
- estimatedTotalLambdaInvokations: 100,
23
- framesPerLambda: 20,
24
- imageFormat: 'png',
25
- type: 'video',
26
- inputProps: {
27
- type: 'payload',
28
- payload: '{}',
29
- },
30
- lambdaVersion: '2022-02-14',
31
- memorySizeInMb: 2048,
32
- functionName: 'remotion-render-4-0-187-mem3000mb-disk10000mb-120sec',
33
- rendererFunctionName: 'remotion-render-4-0-187-mem3000mb-disk10000mb-120sec',
34
- outName: undefined,
35
- region: 'eu-central',
36
- renderId: '9n8dsfafs',
37
- siteId: 'my-site',
38
- startedDate: Date.now(),
39
- totalChunks: 20,
40
- privacy: 'public',
41
- everyNthFrame: 1,
42
- frameRange: [0, 199],
43
- audioCodec: null,
44
- deleteAfter: null,
45
- numberOfGifLoops: null,
46
- downloadBehavior: {type: 'play-in-browser'},
47
- audioBitrate: null,
48
- muted: false,
49
- metadata: null,
50
- codec: 'h264',
51
- dimensions: {
52
- width: 1920,
53
- height: 1080,
54
- },
55
- scale: 1,
56
- };
57
-
58
- test('Should get a custom outname', () => {
59
- expect(
60
- getExpectedOutName({
61
- renderMetadata: testRenderMetadata,
62
- bucketName,
63
- customCredentials: null,
64
- bucketNamePrefix: 'remotionlambda-',
65
- }),
66
- ).toEqual({
67
- customCredentials: null,
68
- renderBucketName: 'remotionlambda-98fsduf',
69
- key: 'renders/9n8dsfafs/out.mp4',
70
- });
71
- });
72
-
73
- test('Should save to a different outname', () => {
74
- const newRenderMetadata: RenderMetadata<MockProvider> = {
75
- ...testRenderMetadata,
76
- outName: {
77
- bucketName: 'my-bucket',
78
- key: 'my-key',
79
- },
80
- };
81
- expect(
82
- getExpectedOutName({
83
- renderMetadata: newRenderMetadata,
84
- bucketName,
85
- customCredentials: null,
86
- bucketNamePrefix: 'remotionlambda-',
87
- }),
88
- ).toEqual({
89
- customCredentials: null,
90
- renderBucketName: 'my-bucket',
91
- key: 'my-key',
92
- });
93
- });
94
-
95
- test('For stills', () => {
96
- const newRenderMetadata: RenderMetadata<MockProvider> = {
97
- ...testRenderMetadata,
98
- codec: null,
99
- type: 'still',
100
- imageFormat: 'png',
101
- };
102
- expect(
103
- getExpectedOutName({
104
- renderMetadata: newRenderMetadata,
105
- bucketName,
106
- customCredentials: null,
107
- bucketNamePrefix: 'remotionlambda-',
108
- }),
109
- ).toEqual({
110
- customCredentials: null,
111
- renderBucketName: 'remotionlambda-98fsduf',
112
- key: 'renders/9n8dsfafs/out.png',
113
- });
114
- });
115
-
116
- test('Just a custom name', () => {
117
- const newRenderMetadata: RenderMetadata<MockProvider> = {
118
- ...testRenderMetadata,
119
- type: 'still',
120
- imageFormat: 'jpeg',
121
- codec: null,
122
- outName: 'justaname.jpeg',
123
- };
124
- expect(
125
- getExpectedOutName({
126
- renderMetadata: newRenderMetadata,
127
- bucketName,
128
- customCredentials: null,
129
- bucketNamePrefix: 'remotionlambda-',
130
- }),
131
- ).toEqual({
132
- customCredentials: null,
133
- renderBucketName: 'remotionlambda-98fsduf',
134
- key: 'renders/9n8dsfafs/justaname.jpeg',
135
- });
136
- });
137
-
138
- test('Should throw on invalid names', () => {
139
- const newRenderMetadata: RenderMetadata<MockProvider> = {
140
- ...testRenderMetadata,
141
- type: 'still',
142
- imageFormat: 'png',
143
- codec: null,
144
- outName: '👺.jpeg',
145
- };
146
- expect(() => {
147
- getExpectedOutName({
148
- renderMetadata: newRenderMetadata,
149
- bucketName,
150
- customCredentials: null,
151
- bucketNamePrefix: 'remotionlambda-',
152
- });
153
- }).toThrow(/The S3 Key must match the RegExp/);
154
- });
155
-
156
- test('Should allow outName an outname with a slash', () => {
157
- const newRenderMetadata: RenderMetadata<MockProvider> = {
158
- ...testRenderMetadata,
159
- codec: null,
160
- audioCodec: null,
161
- type: 'still',
162
- imageFormat: 'jpeg',
163
- outName: 'justa/name.jpeg',
164
- };
165
- expect(
166
- getExpectedOutName({
167
- renderMetadata: newRenderMetadata,
168
- bucketName,
169
- customCredentials: null,
170
- bucketNamePrefix: 'remotionlambda-',
171
- }),
172
- ).toEqual({
173
- customCredentials: null,
174
- key: 'renders/9n8dsfafs/justa/name.jpeg',
175
- renderBucketName: 'remotionlambda-98fsduf',
176
- });
177
- });
178
-
179
- test('Should allow outName an outname with colon', () => {
180
- const newRenderMetadata: RenderMetadata<MockProvider> = {
181
- ...testRenderMetadata,
182
- codec: null,
183
- audioCodec: null,
184
- type: 'still' as const,
185
- imageFormat: 'jpeg',
186
- outName: 'ap-east-1:xxxxxx/video/XXXXX-0b9ba84XXXX.mp4',
187
- };
188
- expect(
189
- getExpectedOutName({
190
- renderMetadata: newRenderMetadata,
191
- bucketName,
192
- customCredentials: null,
193
- bucketNamePrefix: 'remotionlambda-',
194
- }),
195
- ).toEqual({
196
- customCredentials: null,
197
- key: 'renders/9n8dsfafs/ap-east-1:xxxxxx/video/XXXXX-0b9ba84XXXX.mp4',
198
- renderBucketName: 'remotionlambda-98fsduf',
199
- });
200
- });
@@ -1,25 +0,0 @@
1
- import {describe, expect, test} from 'bun:test';
2
- import {max, min} from '../min-max';
3
- describe('min() and max()', () => {
4
- test('Implemented min() functions correctly', () => {
5
- expect(min([0, -30, 90, -120, 0])).toBe(-120);
6
- });
7
- test('Implemented max() functions correctly', () => {
8
- expect(max([0, -30, 90, -120, 0])).toBe(90);
9
- });
10
-
11
- test('min() should throw on empty arr', () => {
12
- expect(() => min([])).toThrow(/Array of 0 length/);
13
- });
14
- test('max() should throw on empty arr', () => {
15
- expect(() => min([])).toThrow(/Array of 0 length/);
16
- });
17
-
18
- const bigArray = new Array(300000).fill(true).map((_, i) => {
19
- return i;
20
- });
21
-
22
- test('Custom max() should not throw', () => {
23
- expect(max(bigArray)).toBe(299999);
24
- });
25
- });
@@ -1,167 +0,0 @@
1
- import {expect, test} from 'bun:test';
2
- import {getMostExpensiveChunks} from '../most-expensive-chunks';
3
-
4
- test('Should calculate most expensive chunks', () => {
5
- const most = getMostExpensiveChunks({
6
- parsedTimings: [
7
- {
8
- chunk: 0,
9
- rendered: 1000,
10
- start: 0,
11
- },
12
- {
13
- chunk: 1,
14
- rendered: 4000,
15
- start: 2000,
16
- },
17
- {
18
- chunk: 2,
19
- rendered: 5000,
20
- start: 2000,
21
- },
22
- {
23
- chunk: 3,
24
- rendered: 3000,
25
- start: 2000,
26
- },
27
- {
28
- chunk: 4,
29
- rendered: 100000,
30
- start: 2000,
31
- },
32
- {
33
- chunk: 5,
34
- rendered: 2001,
35
- start: 2000,
36
- },
37
- {
38
- chunk: 6,
39
- rendered: 2500,
40
- start: 2000,
41
- },
42
- ],
43
- framesPerFunction: 10,
44
- firstFrame: 0,
45
- lastFrame: 99,
46
- });
47
-
48
- expect(most).toEqual([
49
- {timeInMilliseconds: 98000, chunk: 4, frameRange: [40, 49]},
50
- {timeInMilliseconds: 3000, chunk: 2, frameRange: [20, 29]},
51
- {timeInMilliseconds: 2000, chunk: 1, frameRange: [10, 19]},
52
- {timeInMilliseconds: 1000, chunk: 0, frameRange: [0, 9]},
53
- {timeInMilliseconds: 1000, chunk: 3, frameRange: [30, 39]},
54
- ]);
55
- });
56
-
57
- test('Render starting from frame 10 should have correct offset', () => {
58
- const framesPerFunction = 10;
59
- const firstFrame = 10;
60
- const lastFrame = 99;
61
- const most = getMostExpensiveChunks({
62
- parsedTimings: [
63
- {
64
- chunk: 0,
65
- rendered: 1000,
66
- start: 0,
67
- },
68
- {
69
- chunk: 1,
70
- rendered: 4000,
71
- start: 2000,
72
- },
73
- {
74
- chunk: 2,
75
- rendered: 5000,
76
- start: 2000,
77
- },
78
- {
79
- chunk: 3,
80
- rendered: 3000,
81
- start: 2000,
82
- },
83
- {
84
- chunk: 4,
85
- rendered: 100000,
86
- start: 2000,
87
- },
88
- {
89
- chunk: 5,
90
- rendered: 2001,
91
- start: 2000,
92
- },
93
- {
94
- chunk: 6,
95
- rendered: 2500,
96
- start: 2000,
97
- },
98
- ],
99
- framesPerFunction,
100
- firstFrame,
101
- lastFrame,
102
- });
103
-
104
- expect(most).toEqual([
105
- {timeInMilliseconds: 98000, chunk: 4, frameRange: [50, 59]},
106
- {timeInMilliseconds: 3000, chunk: 2, frameRange: [30, 39]},
107
- {timeInMilliseconds: 2000, chunk: 1, frameRange: [20, 29]},
108
- {timeInMilliseconds: 1000, chunk: 0, frameRange: [10, 19]},
109
- {timeInMilliseconds: 1000, chunk: 3, frameRange: [40, 49]},
110
- ]);
111
- });
112
-
113
- test('Render starting from frame 10 and last chunk in most expensive should be corret', () => {
114
- const framesPerFunction = 10;
115
- const firstFrame = 10;
116
- const lastFrame = 79;
117
- const most = getMostExpensiveChunks({
118
- parsedTimings: [
119
- {
120
- chunk: 0,
121
- rendered: 1000,
122
- start: 0,
123
- },
124
- {
125
- chunk: 1,
126
- rendered: 4000,
127
- start: 2000,
128
- },
129
- {
130
- chunk: 2,
131
- rendered: 5000,
132
- start: 2000,
133
- },
134
- {
135
- chunk: 3,
136
- rendered: 3000,
137
- start: 2000,
138
- },
139
- {
140
- chunk: 4,
141
- rendered: 100000,
142
- start: 2000,
143
- },
144
- {
145
- chunk: 5,
146
- rendered: 2001,
147
- start: 2000,
148
- },
149
- {
150
- chunk: 6,
151
- rendered: 125000,
152
- start: 2000,
153
- },
154
- ],
155
- framesPerFunction,
156
- firstFrame,
157
- lastFrame,
158
- });
159
-
160
- expect(most).toEqual([
161
- {timeInMilliseconds: 123000, chunk: 6, frameRange: [70, 79]},
162
- {timeInMilliseconds: 98000, chunk: 4, frameRange: [50, 59]},
163
- {timeInMilliseconds: 3000, chunk: 2, frameRange: [30, 39]},
164
- {timeInMilliseconds: 2000, chunk: 1, frameRange: [20, 29]},
165
- {timeInMilliseconds: 1000, chunk: 0, frameRange: [10, 19]},
166
- ]);
167
- });
package/src/truthy.ts DELETED
@@ -1,5 +0,0 @@
1
- type Truthy<T> = T extends false | '' | 0 | null | undefined ? never : T; // from lodash
2
-
3
- export function truthy<T>(value: T): value is Truthy<T> {
4
- return Boolean(value);
5
- }
package/src/types.ts DELETED
@@ -1,82 +0,0 @@
1
- import type {ServerlessPayloads, ServerlessRoutines} from './constants';
2
-
3
- export interface CloudProvider<
4
- Region extends string = string,
5
- ReceivedArtifactType extends Record<string, unknown> = Record<
6
- string,
7
- unknown
8
- >,
9
- CreateFunctionSpecifics extends Record<string, unknown> = Record<
10
- string,
11
- unknown
12
- >,
13
- StorageClass extends string = string,
14
- RequestHandler extends object = object,
15
- > {
16
- type: string;
17
- region: Region;
18
- receivedArtifactType: ReceivedArtifactType;
19
- creationFunctionOptions: CreateFunctionSpecifics;
20
- storageClass: StorageClass;
21
- requestHandler: RequestHandler | null | undefined;
22
- }
23
-
24
- export type ReceivedArtifact<Provider extends CloudProvider> = {
25
- filename: string;
26
- sizeInBytes: number;
27
- s3Url: string;
28
- s3Key: string;
29
- } & Provider['receivedArtifactType'];
30
-
31
- export type CostsInfo = {
32
- accruedSoFar: number;
33
- displayCost: string;
34
- currency: string;
35
- disclaimer: string;
36
- };
37
-
38
- export type RenderStillFunctionResponsePayload<Provider extends CloudProvider> =
39
- {
40
- type: 'success';
41
- output: string;
42
- outKey: string;
43
- size: number;
44
- bucketName: string;
45
- sizeInBytes: number;
46
- estimatedPrice: CostsInfo;
47
- renderId: string;
48
- receivedArtifacts: ReceivedArtifact<Provider>[];
49
- };
50
-
51
- export type ChunkRetry = {
52
- chunk: number;
53
- attempt: number;
54
- time: number;
55
- };
56
-
57
- export type ParsedTiming = {
58
- chunk: number;
59
- start: number;
60
- rendered: number;
61
- };
62
-
63
- export type CallFunctionOptions<
64
- T extends ServerlessRoutines,
65
- Provider extends CloudProvider,
66
- > = {
67
- functionName: string;
68
- type: T;
69
- payload: ServerlessPayloads<Provider>[T];
70
- region: Provider['region'];
71
- timeoutInTest: number;
72
- requestHandler: Provider['requestHandler'] | null;
73
- };
74
-
75
- export type ObjectChunkTimingData = {
76
- chunk: number;
77
- frameRange: [number, number];
78
- startDate: number;
79
- timings: {
80
- [key: number]: number;
81
- };
82
- };
@@ -1,34 +0,0 @@
1
- export const validateBucketName = ({
2
- bucketName,
3
- bucketNamePrefix,
4
- options,
5
- }: {
6
- bucketName: unknown;
7
- bucketNamePrefix: string;
8
- options: {
9
- mustStartWithRemotion: boolean;
10
- };
11
- }) => {
12
- if (typeof bucketName !== 'string') {
13
- throw new TypeError(
14
- `'bucketName' must be a string, but is ${JSON.stringify(bucketName)}`,
15
- );
16
- }
17
-
18
- if (
19
- options.mustStartWithRemotion &&
20
- !bucketName.startsWith(bucketNamePrefix)
21
- ) {
22
- throw new Error(
23
- `The bucketName parameter must start with ${bucketNamePrefix}.`,
24
- );
25
- }
26
-
27
- if (
28
- !bucketName.match(
29
- /^(?=^.{3,63}$)(?!^(\d+\.)+\d+$)(^(([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])$)/,
30
- )
31
- ) {
32
- throw new Error(`The bucket ${bucketName} `);
33
- }
34
- };
@@ -1,26 +0,0 @@
1
- import type {DownloadBehavior} from 'remotion/no-react';
2
-
3
- export const validateDownloadBehavior = (downloadBehavior: unknown) => {
4
- if (downloadBehavior === null || downloadBehavior === undefined) {
5
- return null;
6
- }
7
-
8
- if (typeof downloadBehavior !== 'object') {
9
- throw new Error('downloadBehavior must be null or an object');
10
- }
11
-
12
- const behavior = downloadBehavior as DownloadBehavior;
13
- if (behavior.type !== 'download' && behavior.type !== 'play-in-browser') {
14
- throw new Error(
15
- 'Download behavior must be either "download" or "play-in-browser"',
16
- );
17
- }
18
-
19
- if (behavior.type === 'download') {
20
- if (typeof behavior.fileName !== 'string' && behavior.fileName !== null) {
21
- throw new Error(
22
- 'If "downloadBehavior.type" is "download", then fileName must be "null" or a string',
23
- );
24
- }
25
- }
26
- };
@@ -1,125 +0,0 @@
1
- import {bestFramesPerFunctionParam} from './best-frames-per-function-param';
2
- import {
3
- MAX_FUNCTIONS_PER_RENDER,
4
- MINIMUM_FRAMES_PER_FUNCTION,
5
- } from './constants';
6
-
7
- export const validateFramesPerFunction = ({
8
- framesPerFunction,
9
- durationInFrames,
10
- concurrency,
11
- }: {
12
- framesPerFunction: number | null;
13
- durationInFrames: number;
14
- concurrency: number | null;
15
- }): number => {
16
- if (concurrency !== null && framesPerFunction !== null) {
17
- throw new TypeError(
18
- `Both 'framesPerLambda' and 'concurrency' were set. Please use only one of them.`,
19
- );
20
- }
21
-
22
- const effectiveMinimum = Math.min(
23
- MINIMUM_FRAMES_PER_FUNCTION,
24
- durationInFrames,
25
- );
26
-
27
- if (concurrency !== null) {
28
- // Validate concurrency is a number
29
- if (typeof concurrency !== 'number') {
30
- throw new TypeError(
31
- `'concurrency' needs to be a number, passed ${JSON.stringify(
32
- concurrency,
33
- )}`,
34
- );
35
- }
36
-
37
- // Validate concurrency is finite
38
- if (!Number.isFinite(concurrency)) {
39
- throw new TypeError(
40
- `'concurrency' needs to be finite, passed ${concurrency}`,
41
- );
42
- }
43
-
44
- // Validate concurrency is not NaN
45
- if (Number.isNaN(concurrency)) {
46
- throw new TypeError(
47
- `'concurrency' needs to be a valid number, passed ${concurrency}`,
48
- );
49
- }
50
-
51
- // Validate concurrency is an integer
52
- if (concurrency % 1 !== 0) {
53
- throw new TypeError(
54
- `'concurrency' needs to be an integer, passed ${concurrency}`,
55
- );
56
- }
57
-
58
- // Validate concurrency is positive
59
- if (concurrency <= 0) {
60
- throw new TypeError(
61
- `'concurrency' needs to be positive, passed ${concurrency}`,
62
- );
63
- }
64
-
65
- // Validate concurrency doesn't exceed maximum
66
- if (concurrency > MAX_FUNCTIONS_PER_RENDER) {
67
- throw new TypeError(
68
- `'concurrency' cannot exceed ${MAX_FUNCTIONS_PER_RENDER}, passed ${concurrency}`,
69
- );
70
- }
71
-
72
- return Math.max(
73
- Math.ceil(durationInFrames / concurrency),
74
- effectiveMinimum,
75
- );
76
- }
77
-
78
- if (framesPerFunction === null) {
79
- return Math.max(
80
- bestFramesPerFunctionParam(durationInFrames),
81
- effectiveMinimum,
82
- );
83
- }
84
-
85
- if (framesPerFunction === undefined) {
86
- return Math.max(
87
- bestFramesPerFunctionParam(durationInFrames),
88
- effectiveMinimum,
89
- );
90
- }
91
-
92
- if (typeof framesPerFunction !== 'number') {
93
- throw new TypeError(
94
- `'framesPerLambda' needs to be a number, passed ${JSON.stringify(
95
- framesPerFunction,
96
- )}`,
97
- );
98
- }
99
-
100
- if (!Number.isFinite(framesPerFunction)) {
101
- throw new TypeError(
102
- `'framesPerLambda' needs to be finite, passed ${framesPerFunction}`,
103
- );
104
- }
105
-
106
- if (Number.isNaN(framesPerFunction)) {
107
- throw new TypeError(
108
- `'framesPerLambda' needs to be NaN, passed ${framesPerFunction}`,
109
- );
110
- }
111
-
112
- if (framesPerFunction % 1 !== 0) {
113
- throw new TypeError(
114
- `'framesPerLambda' needs to be an integer, passed ${framesPerFunction}`,
115
- );
116
- }
117
-
118
- if (framesPerFunction < effectiveMinimum) {
119
- throw new TypeError(
120
- `The framesPerLambda needs to be at least ${effectiveMinimum}, but is ${framesPerFunction}`,
121
- );
122
- }
123
-
124
- return framesPerFunction;
125
- };