2
2
3
3
const ndjson = require ( 'iterable-ndjson' )
4
4
const configure = require ( '../lib/configure' )
5
- const toIterable = require ( '../lib/stream-to-iterable' )
5
+ const toAsyncIterable = require ( '../lib/stream-to-async -iterable' )
6
6
const { toFormData } = require ( './form-data' )
7
7
const toCamel = require ( '../lib/object-to-camel' )
8
8
@@ -16,21 +16,36 @@ module.exports = configure(({ ky }) => {
16
16
if ( options . chunker ) searchParams . set ( 'chunker' , options . chunker )
17
17
if ( options . cidVersion ) searchParams . set ( 'cid-version' , options . cidVersion )
18
18
if ( options . cidBase ) searchParams . set ( 'cid-base' , options . cidBase )
19
- if ( options . enableShardingExperiment != null ) searchParams . set ( 'enable-sharding-experiment' , options . enableShardingExperiment )
19
+ if ( options . enableShardingExperiment != null ) {
20
+ searchParams . set (
21
+ 'enable-sharding-experiment' ,
22
+ options . enableShardingExperiment
23
+ )
24
+ }
20
25
if ( options . hashAlg ) searchParams . set ( 'hash' , options . hashAlg )
21
- if ( options . onlyHash != null ) searchParams . set ( 'only-hash' , options . onlyHash )
26
+ if ( options . onlyHash != null ) { searchParams . set ( 'only-hash' , options . onlyHash ) }
22
27
if ( options . pin != null ) searchParams . set ( 'pin' , options . pin )
23
28
if ( options . progress ) searchParams . set ( 'progress' , true )
24
29
if ( options . quiet != null ) searchParams . set ( 'quiet' , options . quiet )
25
30
if ( options . quieter != null ) searchParams . set ( 'quieter' , options . quieter )
26
- if ( options . rawLeaves != null ) searchParams . set ( 'raw-leaves' , options . rawLeaves )
27
- if ( options . shardSplitThreshold ) searchParams . set ( 'shard-split-threshold' , options . shardSplitThreshold )
31
+ if ( options . rawLeaves != null ) { searchParams . set ( 'raw-leaves' , options . rawLeaves ) }
32
+ if ( options . shardSplitThreshold ) { searchParams . set ( 'shard-split-threshold' , options . shardSplitThreshold ) }
28
33
if ( options . silent ) searchParams . set ( 'silent' , options . silent )
29
34
if ( options . trickle != null ) searchParams . set ( 'trickle' , options . trickle )
30
- if ( options . wrapWithDirectory != null ) searchParams . set ( 'wrap-with-directory' , options . wrapWithDirectory )
35
+ if ( options . wrapWithDirectory != null ) { searchParams . set ( 'wrap-with-directory' , options . wrapWithDirectory ) }
31
36
if ( options . preload != null ) searchParams . set ( 'preload' , options . preload )
32
- if ( options . fileImportConcurrency != null ) searchParams . set ( 'file-import-concurrency' , options . fileImportConcurrency )
33
- if ( options . blockWriteConcurrency != null ) searchParams . set ( 'block-write-concurrency' , options . blockWriteConcurrency )
37
+ if ( options . fileImportConcurrency != null ) {
38
+ searchParams . set (
39
+ 'file-import-concurrency' ,
40
+ options . fileImportConcurrency
41
+ )
42
+ }
43
+ if ( options . blockWriteConcurrency != null ) {
44
+ searchParams . set (
45
+ 'block-write-concurrency' ,
46
+ options . blockWriteConcurrency
47
+ )
48
+ }
34
49
35
50
const res = await ky . post ( 'add' , {
36
51
timeout : options . timeout ,
@@ -40,7 +55,7 @@ module.exports = configure(({ ky }) => {
40
55
body : await toFormData ( input )
41
56
} )
42
57
43
- for await ( let file of ndjson ( toIterable ( res ) ) ) {
58
+ for await ( let file of ndjson ( toAsyncIterable ( res ) ) ) {
44
59
file = toCamel ( file )
45
60
// console.log(file)
46
61
if ( options . progress && file . bytes ) {
0 commit comments