@socketsecurity/cli-with-sentry 1.0.79 → 1.0.80

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.
@@ -2,50 +2,11 @@
2
2
 
3
3
  const { freeze: ObjectFreeze } = Object
4
4
 
5
- const { getGlobMatcher } = /*@__PURE__*/ require('./globs')
5
+ const { defaultIgnore, getGlobMatcher } = /*@__PURE__*/ require('./globs')
6
6
  const { naturalCompare } = /*@__PURE__*/ require('./sorts')
7
+ const { pathLikeToString } = /*@__PURE__*/ require('./path')
7
8
  const { stripBom } = /*@__PURE__*/ require('./strings')
8
9
 
9
- const defaultIgnore = ObjectFreeze([
10
- // Most of these ignored files can be included specifically if included in the
11
- // files globs. Exceptions to this are:
12
- // https://docs.npmjs.com/cli/v10/configuring-npm/package-json#files
13
- // These can NOT be included.
14
- // https://github.com/npm/npm-packlist/blob/v10.0.0/lib/index.js#L280
15
- '**/.git',
16
- '**/.npmrc',
17
- // '**/bun.lockb?',
18
- // '**/node_modules',
19
- // '**/package-lock.json',
20
- // '**/pnpm-lock.ya?ml',
21
- // '**/yarn.lock',
22
- // Include npm-packlist defaults:
23
- // https://github.com/npm/npm-packlist/blob/v10.0.0/lib/index.js#L15-L38
24
- '**/.DS_Store',
25
- '**/.gitignore',
26
- '**/.hg',
27
- '**/.lock-wscript',
28
- '**/.npmignore',
29
- '**/.svn',
30
- '**/.wafpickle-*',
31
- '**/.*.swp',
32
- '**/._*/**',
33
- '**/archived-packages/**',
34
- '**/build/config.gypi',
35
- '**/CVS',
36
- '**/npm-debug.log',
37
- '**/*.orig',
38
- // Inline generic .gitignore entries from the socket-registry repository root.
39
- '**/.env',
40
- '**/.eslintcache',
41
- '**/.nvm',
42
- '**/.tap',
43
- '**/.tapci.yaml',
44
- '**/.vscode',
45
- '**/*.tsbuildinfo',
46
- '**/Thumbs.db'
47
- ])
48
-
49
10
  const defaultRemoveOptions = ObjectFreeze({
50
11
  __proto__: null,
51
12
  force: true,
@@ -95,6 +56,12 @@ function innerReadDirNames(dirents, options) {
95
56
  return sort ? names.sort(naturalCompare) : names
96
57
  }
97
58
 
59
+ /*@__NO_SIDE_EFFECTS__*/
60
+ function isDirSync(filepath) {
61
+ const fs = getFs()
62
+ return fs.existsSync(filepath) && !!safeStatsSync(filepath)?.isDirectory()
63
+ }
64
+
98
65
  /*@__NO_SIDE_EFFECTS__*/
99
66
  function isDirEmptySync(dirname, options) {
100
67
  const { ignore = defaultIgnore } = { __proto__: null, ...options }
@@ -105,7 +72,7 @@ function isDirEmptySync(dirname, options) {
105
72
  if (length === 0) {
106
73
  return true
107
74
  }
108
- const matcher = getGlobMatcher(ignore, { cwd: dirname })
75
+ const matcher = getGlobMatcher(ignore, { cwd: pathLikeToString(dirname) })
109
76
  let ignoredCount = 0
110
77
  for (let i = 0; i < length; i += 1) {
111
78
  if (matcher(files[i])) {
@@ -119,7 +86,7 @@ function isDirEmptySync(dirname, options) {
119
86
  }
120
87
 
121
88
  /*@__NO_SIDE_EFFECTS__*/
122
- function isSymbolicLinkSync(filepath) {
89
+ function isSymLinkSync(filepath) {
123
90
  const fs = getFs()
124
91
  try {
125
92
  return fs.lstatSync(filepath).isSymbolicLink()
@@ -129,9 +96,9 @@ function isSymbolicLinkSync(filepath) {
129
96
 
130
97
  /*@__NO_SIDE_EFFECTS__*/
131
98
  function parse(filepath, content, reviver, shouldThrow) {
132
- const str = Buffer.isBuffer(content) ? content.toString('utf8') : content
99
+ const jsonStr = Buffer.isBuffer(content) ? content.toString('utf8') : content
133
100
  try {
134
- return JSON.parse(stripBom(str), reviver)
101
+ return JSON.parse(stripBom(jsonStr), reviver)
135
102
  } catch (e) {
136
103
  if (shouldThrow) {
137
104
  if (e) {
@@ -148,7 +115,10 @@ async function readDirNames(dirname, options) {
148
115
  const fs = getFs()
149
116
  try {
150
117
  return innerReadDirNames(
151
- await fs.promises.readdir(dirname, { withFileTypes: true }),
118
+ await fs.promises.readdir(dirname, {
119
+ __proto__: null,
120
+ withFileTypes: true
121
+ }),
152
122
  options
153
123
  )
154
124
  } catch {}
@@ -160,29 +130,48 @@ function readDirNamesSync(dirname, options) {
160
130
  const fs = getFs()
161
131
  try {
162
132
  return innerReadDirNames(
163
- fs.readdirSync(dirname, { withFileTypes: true }),
133
+ fs.readdirSync(dirname, { __proto__: null, withFileTypes: true }),
164
134
  options
165
135
  )
166
136
  } catch {}
167
137
  return []
168
138
  }
169
139
 
140
+ /*@__NO_SIDE_EFFECTS__*/
141
+ async function readFileBinary(filepath, options) {
142
+ const fs = getFs()
143
+ return await fs.promises.readFile(filepath, {
144
+ signal: /*@__PURE__*/ require('./constants/abort-signal'),
145
+ ...options,
146
+ encoding: 'binary'
147
+ })
148
+ }
149
+
150
+ /*@__NO_SIDE_EFFECTS__*/
151
+ async function readFileUtf8(filepath, options) {
152
+ const fs = getFs()
153
+ return await fs.promises.readFile(filepath, {
154
+ signal: /*@__PURE__*/ require('./constants/abort-signal'),
155
+ ...options,
156
+ encoding: 'utf8'
157
+ })
158
+ }
159
+
170
160
  /*@__NO_SIDE_EFFECTS__*/
171
161
  async function readJson(filepath, options) {
172
162
  if (typeof options === 'string') {
173
163
  options = { encoding: options }
174
164
  }
175
- const { reviver, throws, ...fsOptionsRaw } = { __proto__: null, ...options }
176
- const fsOptions = {
177
- __proto__: null,
178
- encoding: 'utf8',
179
- ...fsOptionsRaw
180
- }
165
+ const { reviver, throws, ...fsOptions } = { __proto__: null, ...options }
181
166
  const fs = getFs()
182
167
  const shouldThrow = throws === undefined || !!throws
183
168
  return parse(
184
169
  filepath,
185
- await fs.promises.readFile(filepath, fsOptions),
170
+ await fs.promises.readFile(filepath, {
171
+ __proto__: null,
172
+ encoding: 'utf8',
173
+ ...fsOptions
174
+ }),
186
175
  reviver,
187
176
  shouldThrow
188
177
  )
@@ -193,17 +182,16 @@ function readJsonSync(filepath, options) {
193
182
  if (typeof options === 'string') {
194
183
  options = { encoding: options }
195
184
  }
196
- const { reviver, throws, ...fsOptionsRaw } = { __proto__: null, ...options }
197
- const fsOptions = {
198
- __proto__: null,
199
- encoding: 'utf8',
200
- ...fsOptionsRaw
201
- }
185
+ const { reviver, throws, ...fsOptions } = { __proto__: null, ...options }
202
186
  const fs = getFs()
203
187
  const shouldThrow = throws === undefined || !!throws
204
188
  return parse(
205
189
  filepath,
206
- fs.readFileSync(filepath, fsOptions),
190
+ fs.readFileSync(filepath, {
191
+ __proto__: null,
192
+ encoding: 'utf8',
193
+ ...fsOptions
194
+ }),
207
195
  reviver,
208
196
  shouldThrow
209
197
  )
@@ -231,6 +219,45 @@ function removeSync(filepath, options) {
231
219
  })
232
220
  }
233
221
 
222
+ /*@__NO_SIDE_EFFECTS__*/
223
+ async function safeReadFile(filepath, options) {
224
+ const fs = getFs()
225
+ try {
226
+ return await fs.promises.readFile(filepath, {
227
+ encoding: 'utf8',
228
+ signal: /*@__PURE__*/ require('./constants/abort-signal'),
229
+ ...(typeof options === 'string' ? { encoding: options } : options)
230
+ })
231
+ } catch {}
232
+ return undefined
233
+ }
234
+
235
+ /*@__NO_SIDE_EFFECTS__*/
236
+ function safeStatsSync(filepath, options) {
237
+ const fs = getFs()
238
+ try {
239
+ return fs.statSync(filepath, {
240
+ __proto__: null,
241
+ throwIfNoEntry: false,
242
+ ...options
243
+ })
244
+ } catch {}
245
+ return undefined
246
+ }
247
+
248
+ /*@__NO_SIDE_EFFECTS__*/
249
+ function safeReadFileSync(filepath, options) {
250
+ const fs = getFs()
251
+ try {
252
+ return fs.readFileSync(filepath, {
253
+ __proto__: null,
254
+ encoding: 'utf8',
255
+ ...(typeof options === 'string' ? { encoding: options } : options)
256
+ })
257
+ } catch {}
258
+ return undefined
259
+ }
260
+
234
261
  /*@__NO_SIDE_EFFECTS__*/
235
262
  function stringify(
236
263
  json,
@@ -257,52 +284,56 @@ function uniqueSync(filepath) {
257
284
  }
258
285
 
259
286
  /*@__NO_SIDE_EFFECTS__*/
260
- async function writeJson(filepath, json, options) {
287
+ async function writeJson(filepath, jsonContent, options) {
261
288
  if (typeof options === 'string') {
262
289
  options = { encoding: options }
263
290
  }
264
- const { EOL, finalEOL, replacer, spaces, ...fsOptionsRaw } = {
291
+ const { EOL, finalEOL, replacer, spaces, ...fsOptions } = {
265
292
  __proto__: null,
266
293
  ...options
267
294
  }
268
- const fsOptions = {
295
+ const fs = getFs()
296
+ const jsonString = stringify(jsonContent, EOL, finalEOL, replacer, spaces)
297
+ await fs.promises.writeFile(filepath, jsonString, {
269
298
  __proto__: null,
270
299
  encoding: 'utf8',
271
- ...fsOptionsRaw
272
- }
273
- const fs = getFs()
274
- const str = stringify(json, EOL, finalEOL, replacer, spaces)
275
- await fs.promises.writeFile(filepath, str, fsOptions)
300
+ ...fsOptions
301
+ })
276
302
  }
277
303
 
278
304
  /*@__NO_SIDE_EFFECTS__*/
279
- function writeJsonSync(filepath, json, options) {
305
+ function writeJsonSync(filepath, jsonContent, options) {
280
306
  if (typeof options === 'string') {
281
307
  options = { encoding: options }
282
308
  }
283
- const { EOL, finalEOL, replacer, spaces, ...fsOptionsRaw } = {
309
+ const { EOL, finalEOL, replacer, spaces, ...fsOptions } = {
284
310
  __proto__: null,
285
311
  ...options
286
312
  }
287
- const fsOptions = {
313
+ const fs = getFs()
314
+ const jsonString = stringify(jsonContent, EOL, finalEOL, replacer, spaces)
315
+ fs.writeFileSync(filepath, jsonString, {
288
316
  __proto__: null,
289
317
  encoding: 'utf8',
290
- ...fsOptionsRaw
291
- }
292
- const fs = getFs()
293
- const str = stringify(json, EOL, finalEOL, replacer, spaces)
294
- fs.writeFileSync(filepath, str, fsOptions)
318
+ ...fsOptions
319
+ })
295
320
  }
296
321
 
297
322
  module.exports = {
323
+ isDirSync,
298
324
  isDirEmptySync,
299
- isSymbolicLinkSync,
325
+ isSymLinkSync,
326
+ readFileBinary,
327
+ readFileUtf8,
300
328
  readJson,
301
329
  readJsonSync,
302
330
  readDirNames,
303
331
  readDirNamesSync,
304
332
  remove,
305
333
  removeSync,
334
+ safeReadFile,
335
+ safeReadFileSync,
336
+ safeStatsSync,
306
337
  uniqueSync,
307
338
  writeJson,
308
339
  writeJsonSync
@@ -1,5 +1,49 @@
1
1
  'use strict'
2
2
 
3
+ const { freeze: ObjectFreeze } = Object
4
+
5
+ const defaultIgnore = ObjectFreeze([
6
+ // Most of these ignored files can be included specifically if included in the
7
+ // files globs. Exceptions to this are:
8
+ // https://docs.npmjs.com/cli/v10/configuring-npm/package-json#files
9
+ // These can NOT be included.
10
+ // https://github.com/npm/npm-packlist/blob/v10.0.0/lib/index.js#L280
11
+ '**/.git',
12
+ '**/.npmrc',
13
+ // '**/bun.lockb?',
14
+ '**/node_modules',
15
+ // '**/package-lock.json',
16
+ // '**/pnpm-lock.ya?ml',
17
+ // '**/yarn.lock',
18
+ // Include npm-packlist defaults:
19
+ // https://github.com/npm/npm-packlist/blob/v10.0.0/lib/index.js#L15-L38
20
+ '**/.DS_Store',
21
+ '**/.gitignore',
22
+ '**/.hg',
23
+ '**/.lock-wscript',
24
+ '**/.npmignore',
25
+ '**/.svn',
26
+ '**/.wafpickle-*',
27
+ '**/.*.swp',
28
+ '**/._*/**',
29
+ '**/archived-packages/**',
30
+ '**/build/config.gypi',
31
+ '**/CVS',
32
+ '**/npm-debug.log',
33
+ '**/*.orig',
34
+ // Inline generic socket-registry .gitignore entries.
35
+ '**/.env',
36
+ '**/.eslintcache',
37
+ '**/.nvm',
38
+ '**/.tap',
39
+ '**/.tapci.yaml',
40
+ '**/.vscode',
41
+ '**/*.tsbuildinfo',
42
+ '**/Thumbs.db',
43
+ // Inline additional ignores.
44
+ '**/bower_components'
45
+ ])
46
+
3
47
  let _picomatch
4
48
  /*@__NO_SIDE_EFFECTS__*/
5
49
  function getPicomatch() {
@@ -28,7 +72,7 @@ function globStreamLicenses(dirname, options) {
28
72
  ...globOptions
29
73
  } = { __proto__: null, ...options }
30
74
  const ignore = [
31
- ...(Array.isArray(ignoreOpt) ? ignoreOpt : []),
75
+ ...(Array.isArray(ignoreOpt) ? ignoreOpt : defaultIgnore),
32
76
  '**/*.{cjs,cts,js,json,mjs,mts,ts}'
33
77
  ]
34
78
  if (ignoreOriginals) {
@@ -74,6 +118,7 @@ function getGlobMatcher(glob, options) {
74
118
  }
75
119
 
76
120
  module.exports = {
121
+ defaultIgnore,
77
122
  getGlobMatcher,
78
123
  globStreamLicenses
79
124
  }
@@ -6,13 +6,37 @@ const leadingDotSlashRegExp = /^\.\.?[/\\]/
6
6
  const slashRegExp = /[/\\]/
7
7
  const nodeModulesPathRegExp = /(?:^|[/\\])node_modules(?:[/\\]|$)/
8
8
 
9
+ let _buffer
9
10
  /*@__NO_SIDE_EFFECTS__*/
10
- function isNodeModules(filepath) {
11
+ function getBuffer() {
12
+ if (_buffer === undefined) {
13
+ // Use non-'node:' prefixed require to avoid Webpack errors.
14
+ // eslint-disable-next-line n/prefer-node-protocol
15
+ _buffer = /*@__PURE__*/ require('buffer')
16
+ }
17
+ return _buffer
18
+ }
19
+
20
+ let _url
21
+ /*@__NO_SIDE_EFFECTS__*/
22
+ function getUrl() {
23
+ if (_url === undefined) {
24
+ // Use non-'node:' prefixed require to avoid Webpack errors.
25
+ // eslint-disable-next-line n/prefer-node-protocol
26
+ _url = /*@__PURE__*/ require('url')
27
+ }
28
+ return _url
29
+ }
30
+
31
+ /*@__NO_SIDE_EFFECTS__*/
32
+ function isNodeModules(pathLike) {
33
+ const filepath = pathLikeToString(pathLike)
11
34
  return nodeModulesPathRegExp.test(filepath)
12
35
  }
13
36
 
14
37
  /*@__NO_SIDE_EFFECTS__*/
15
- function isRelative(filepath) {
38
+ function isRelative(pathLike) {
39
+ const filepath = pathLikeToString(pathLike)
16
40
  if (typeof filepath !== 'string') {
17
41
  return false
18
42
  }
@@ -34,12 +58,13 @@ function isRelative(filepath) {
34
58
  }
35
59
 
36
60
  /*@__NO_SIDE_EFFECTS__*/
37
- function normalizePath(filePath) {
38
- const { length } = filePath
61
+ function normalizePath(pathLike) {
62
+ const filepath = pathLikeToString(pathLike)
63
+ const { length } = filepath
39
64
  if (length < 2) {
40
- return length === 1 && filePath.charCodeAt(0) === 92 /*'\\'*/
65
+ return length === 1 && filepath.charCodeAt(0) === 92 /*'\\'*/
41
66
  ? '/'
42
- : filePath
67
+ : filepath
43
68
  }
44
69
 
45
70
  let code = 0
@@ -53,13 +78,13 @@ function normalizePath(filePath) {
53
78
  // are okay to convert to forward slashes.
54
79
  // https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
55
80
  let prefix = ''
56
- if (length > 4 && filePath.charCodeAt(3) === 92 /*'\\'*/) {
57
- const code2 = filePath.charCodeAt(2)
81
+ if (length > 4 && filepath.charCodeAt(3) === 92 /*'\\'*/) {
82
+ const code2 = filepath.charCodeAt(2)
58
83
  // Look for \\?\ or \\.\
59
84
  if (
60
85
  (code2 === 63 /*'?'*/ || code2 === 46) /*'.'*/ &&
61
- filePath.charCodeAt(0) === 92 /*'\\'*/ &&
62
- filePath.charCodeAt(1) === 92 /*'\\'*/
86
+ filepath.charCodeAt(0) === 92 /*'\\'*/ &&
87
+ filepath.charCodeAt(1) === 92 /*'\\'*/
63
88
  ) {
64
89
  start = 2
65
90
  prefix = '//'
@@ -68,7 +93,7 @@ function normalizePath(filePath) {
68
93
  if (start === 0) {
69
94
  // Trim leading slashes
70
95
  while (
71
- ((code = filePath.charCodeAt(start)),
96
+ ((code = filepath.charCodeAt(start)),
72
97
  code === 47 /*'/'*/ || code === 92) /*'\\'*/
73
98
  ) {
74
99
  start += 1
@@ -77,24 +102,24 @@ function normalizePath(filePath) {
77
102
  prefix = '/'
78
103
  }
79
104
  }
80
- let nextIndex = search(filePath, slashRegExp, start)
105
+ let nextIndex = search(filepath, slashRegExp, start)
81
106
  if (nextIndex === -1) {
82
- return prefix + filePath.slice(start)
107
+ return prefix + filepath.slice(start)
83
108
  }
84
109
  // Discard any empty string segments by collapsing repeated segment separator slashes.
85
110
  while (nextIndex !== -1) {
86
- const segment = filePath.slice(start, nextIndex)
111
+ const segment = filepath.slice(start, nextIndex)
87
112
  collapsed = collapsed + (collapsed.length === 0 ? '' : '/') + segment
88
113
  start = nextIndex + 1
89
114
  while (
90
- ((code = filePath.charCodeAt(start)),
115
+ ((code = filepath.charCodeAt(start)),
91
116
  code === 47 /*'/'*/ || code === 92) /*'\\'*/
92
117
  ) {
93
118
  start += 1
94
119
  }
95
- nextIndex = search(filePath, slashRegExp, start)
120
+ nextIndex = search(filepath, slashRegExp, start)
96
121
  }
97
- const lastSegment = filePath.slice(start)
122
+ const lastSegment = filepath.slice(start)
98
123
  if (lastSegment.length !== 0) {
99
124
  collapsed = collapsed + '/' + lastSegment
100
125
  }
@@ -102,12 +127,30 @@ function normalizePath(filePath) {
102
127
  }
103
128
 
104
129
  /*@__NO_SIDE_EFFECTS__*/
105
- function splitPath(filepath) {
130
+ function pathLikeToString(pathLike) {
131
+ if (typeof pathLike === 'string') {
132
+ return pathLike
133
+ }
134
+ const Buffer = getBuffer()
135
+ if (Buffer.isBuffer(pathLike)) {
136
+ return pathLike.toString('utf8')
137
+ }
138
+ const url = getUrl()
139
+ if (pathLike instanceof URL) {
140
+ return url.fileURLToPath(pathLike)
141
+ }
142
+ return String(pathLike)
143
+ }
144
+
145
+ /*@__NO_SIDE_EFFECTS__*/
146
+ function splitPath(pathLike) {
147
+ const filepath = pathLikeToString(pathLike)
106
148
  return filepath.split(slashRegExp)
107
149
  }
108
150
 
109
151
  /*@__NO_SIDE_EFFECTS__*/
110
- function trimLeadingDotSlash(filepath) {
152
+ function trimLeadingDotSlash(pathLike) {
153
+ const filepath = pathLikeToString(pathLike)
111
154
  return filepath.replace(leadingDotSlashRegExp, '')
112
155
  }
113
156
 
@@ -115,6 +158,7 @@ module.exports = {
115
158
  isNodeModules,
116
159
  isRelative,
117
160
  normalizePath,
161
+ pathLikeToString,
118
162
  splitPath,
119
163
  trimLeadingDotSlash
120
164
  }
@@ -13,6 +13,25 @@ function getTimers() {
13
13
  return _timers
14
14
  }
15
15
 
16
+ /*@__NO_SIDE_EFFECTS__*/
17
+ function normalizeIterationOptions(options) {
18
+ const {
19
+ // The number of concurrent executions performed at one time.
20
+ concurrency = 1,
21
+ // Retries as a number or options object.
22
+ retries,
23
+ // AbortSignal used to support cancellation.
24
+ signal = /*@__PURE__*/ require('./constants/abort-signal')
25
+ } = { __proto__: null, ...options }
26
+ const retryOpts = resolveRetryOptions(retries)
27
+ return {
28
+ __proto__: null,
29
+ concurrency,
30
+ retries: normalizeRetryOptions({ signal, ...retryOpts }),
31
+ signal
32
+ }
33
+ }
34
+
16
35
  /*@__NO_SIDE_EFFECTS__*/
17
36
  function normalizeRetryOptions(options) {
18
37
  const {
@@ -62,23 +81,31 @@ function resolveRetryOptions(options) {
62
81
  }
63
82
 
64
83
  /*@__NO_SIDE_EFFECTS__*/
65
- async function pEach(array, concurrency, callbackFn, options) {
66
- await pEachChunk(arrayChunk(array, concurrency), callbackFn, options)
84
+ async function pEach(array, callbackFn, options) {
85
+ const iterOpts = normalizeIterationOptions(options)
86
+ await pEachChunk(
87
+ arrayChunk(array, iterOpts.concurrency),
88
+ callbackFn,
89
+ iterOpts.retries
90
+ )
67
91
  }
68
92
 
69
93
  /*@__NO_SIDE_EFFECTS__*/
70
- async function pFilter(array, concurrency, callbackFn, options) {
94
+ async function pFilter(array, callbackFn, options) {
95
+ const iterOpts = normalizeIterationOptions(options)
71
96
  return (
72
- await pFilterChunk(arrayChunk(array, concurrency), callbackFn, options)
97
+ await pFilterChunk(
98
+ arrayChunk(array, iterOpts.concurrency),
99
+ callbackFn,
100
+ iterOpts.retries
101
+ )
73
102
  ).flat()
74
103
  }
75
104
 
76
105
  /*@__NO_SIDE_EFFECTS__*/
77
106
  async function pEachChunk(chunks, callbackFn, options) {
78
- const {
79
- retries,
80
- signal = /*@__PURE__*/ require('./constants/abort-signal')
81
- } = { __proto__: null, ...options }
107
+ const retryOpts = normalizeRetryOptions(options)
108
+ const { signal } = retryOpts
82
109
  for (const chunk of chunks) {
83
110
  if (signal?.aborted) {
84
111
  return
@@ -87,8 +114,7 @@ async function pEachChunk(chunks, callbackFn, options) {
87
114
  await Promise.all(
88
115
  chunk.map(value =>
89
116
  pRetry(callbackFn, {
90
- signal,
91
- ...resolveRetryOptions(retries),
117
+ ...retryOpts,
92
118
  args: [value]
93
119
  })
94
120
  )
@@ -98,10 +124,8 @@ async function pEachChunk(chunks, callbackFn, options) {
98
124
 
99
125
  /*@__NO_SIDE_EFFECTS__*/
100
126
  async function pFilterChunk(chunks, callbackFn, options) {
101
- const {
102
- retries,
103
- signal = /*@__PURE__*/ require('./constants/abort-signal')
104
- } = { __proto__: null, ...options }
127
+ const retryOpts = normalizeRetryOptions(options)
128
+ const { signal } = retryOpts
105
129
  const { length } = chunks
106
130
  const filteredChunks = Array(length)
107
131
  for (let i = 0; i < length; i += 1) {
@@ -114,8 +138,7 @@ async function pFilterChunk(chunks, callbackFn, options) {
114
138
  const predicateResults = await Promise.all(
115
139
  chunk.map(value =>
116
140
  pRetry(callbackFn, {
117
- signal,
118
- ...resolveRetryOptions(retries),
141
+ ...retryOpts,
119
142
  args: [value]
120
143
  })
121
144
  )
@@ -197,9 +220,12 @@ async function pRetry(callbackFn, options) {
197
220
  }
198
221
 
199
222
  module.exports = {
223
+ normalizeIterationOptions,
224
+ normalizeRetryOptions,
200
225
  pEach,
201
226
  pEachChunk,
202
227
  pFilter,
203
228
  pFilterChunk,
204
- pRetry
229
+ pRetry,
230
+ resolveRetryOptions
205
231
  }
@@ -1,6 +1,9 @@
1
1
  'use strict'
2
2
 
3
- const { apply: ReflectApply } = Reflect
3
+ const {
4
+ normalizeIterationOptions,
5
+ pRetry
6
+ } = /*@__PURE__*/ require('./promises')
4
7
 
5
8
  let _streamingIterables
6
9
  /*@__NO_SIDE_EFFECTS__*/
@@ -12,26 +15,44 @@ function getStreamingIterables() {
12
15
  }
13
16
 
14
17
  /*@__NO_SIDE_EFFECTS__*/
15
- async function parallelForEach(concurrency, func, iterable) {
16
- for await (const _ of parallelMap(concurrency, func, iterable)) {
18
+ async function parallelEach(iterable, func, options) {
19
+ for await (const _ of parallelMap(iterable, func, options)) {
17
20
  /* empty block */
18
21
  }
19
22
  }
20
23
 
21
24
  /*@__NO_SIDE_EFFECTS__*/
22
- function parallelMap(...args) {
25
+ function parallelMap(iterable, func, options) {
23
26
  const streamingIterables = getStreamingIterables()
24
- return ReflectApply(streamingIterables.parallelMap, undefined, args)
27
+ const opts = normalizeIterationOptions(options)
28
+ return streamingIterables.parallelMap(
29
+ opts.concurrency,
30
+ item =>
31
+ pRetry(func, {
32
+ ...opts.retries,
33
+ args: [item]
34
+ }),
35
+ iterable
36
+ )
25
37
  }
26
38
 
27
39
  /*@__NO_SIDE_EFFECTS__*/
28
- function transform(...args) {
40
+ function transform(iterable, func, options) {
29
41
  const streamingIterables = getStreamingIterables()
30
- return ReflectApply(streamingIterables.transform, undefined, args)
42
+ const opts = normalizeIterationOptions(options)
43
+ return streamingIterables.transform(
44
+ opts.concurrency,
45
+ item =>
46
+ pRetry(func, {
47
+ ...opts.retries,
48
+ args: [item]
49
+ }),
50
+ iterable
51
+ )
31
52
  }
32
53
 
33
54
  module.exports = {
34
- parallelForEach,
55
+ parallelEach,
35
56
  parallelMap,
36
57
  transform
37
58
  }