@@ -7,43 +7,45 @@ const FILL_RATE = 0.9;
7
7
const DEFAULT_SIZE_LIMIT =
8
8
FILL_RATE * ( LAMBDA_PAYLOAD_LIMIT / BASE64_ENCODING_OVERHEAD ) ;
9
9
10
- const createBaselineLimitedBatchBuilder =
11
- ( options , baselineSizeLimit = DEFAULT_SIZE_LIMIT ) =>
12
- ( tasks , batchSize ) => {
13
- let currentBatch = [ ] ;
14
- let accumulatedBatchSize = 0 ;
15
- let lastFileSize = 200 * 1024 ;
16
- const batches = [ currentBatch ] ;
17
- for ( let i = 0 ; i < tasks . length ; i ++ ) {
18
- const task = tasks [ i ] ;
19
- const { referencePath } = getOutputPaths (
20
- options ,
21
- task . task . configurationName ,
22
- task . task . kind ,
23
- task . task . story
24
- ) ;
25
- let size ;
26
- try {
27
- const stat = fs . statSync ( referencePath ) ;
28
- // eslint-disable-next-line prefer-destructuring
29
- size = stat . size ;
30
- lastFileSize = size ;
31
- } catch ( e ) {
32
- size = lastFileSize ;
33
- }
34
- if (
35
- currentBatch . length >= batchSize ||
36
- ( accumulatedBatchSize + size > baselineSizeLimit &&
37
- currentBatch . length !== 0 )
38
- ) {
39
- currentBatch = [ ] ;
40
- accumulatedBatchSize = 0 ;
41
- batches . push ( currentBatch ) ;
42
- }
43
- currentBatch . push ( task ) ;
44
- accumulatedBatchSize += size ;
10
+ const createBaselineLimitedBatchBuilder = (
11
+ options ,
12
+ baselineSizeLimit = DEFAULT_SIZE_LIMIT
13
+ ) => ( tasks , batchSize ) => {
14
+ let currentBatch = [ ] ;
15
+ let accumulatedBatchSize = 0 ;
16
+ let lastFileSize = 200 * 1024 ;
17
+ const batches = [ currentBatch ] ;
18
+ for ( let i = 0 ; i < tasks . length ; i ++ ) {
19
+ const task = tasks [ i ] ;
20
+ const { referencePath } = getOutputPaths (
21
+ options ,
22
+ task . task . configurationName ,
23
+ task . task . kind ,
24
+ task . task . story ,
25
+ task . task . parameters
26
+ ) ;
27
+ let size ;
28
+ try {
29
+ const stat = fs . statSync ( referencePath ) ;
30
+ // eslint-disable-next-line prefer-destructuring
31
+ size = stat . size ;
32
+ lastFileSize = size ;
33
+ } catch ( e ) {
34
+ size = lastFileSize ;
45
35
}
46
- return batches ;
47
- } ;
36
+ if (
37
+ currentBatch . length >= batchSize ||
38
+ ( accumulatedBatchSize + size > baselineSizeLimit &&
39
+ currentBatch . length !== 0 )
40
+ ) {
41
+ currentBatch = [ ] ;
42
+ accumulatedBatchSize = 0 ;
43
+ batches . push ( currentBatch ) ;
44
+ }
45
+ currentBatch . push ( task ) ;
46
+ accumulatedBatchSize += size ;
47
+ }
48
+ return batches ;
49
+ } ;
48
50
49
51
module . exports = createBaselineLimitedBatchBuilder ;
0 commit comments