Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 620ed72

Browse files
author
Alan Shaw
committed
refactor: convert addReadableStream
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
1 parent fb284b3 commit 620ed72

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"is-stream": "^2.0.0",
6262
"iso-stream-http": "~0.1.2",
6363
"iso-url": "~0.4.6",
64+
"it-to-stream": "^0.1.1",
6465
"iterable-ndjson": "^1.1.0",
6566
"just-kebab-case": "^1.1.0",
6667
"just-map-keys": "^1.1.0",

src/lib/iterable.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict'
22

33
const toPull = require('async-iterator-to-pull-stream')
4+
const toStream = require('it-to-stream')
45

56
exports.collectify = fn => async (...args) => {
67
const items = []
@@ -12,3 +13,7 @@ exports.pullify = {
1213
source: fn => (...args) => toPull(fn(...args)),
1314
transform: fn => (...args) => toPull.transform(source => fn(source, ...args))
1415
}
16+
17+
exports.streamify = {
18+
transform: fn => (...args) => toStream.transform(source => fn(source, ...args), { objectMode: true })
19+
}

src/utils/load-commands.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const nodeify = require('promise-nodeify')
4-
const { collectify, pullify } = require('../lib/iterable')
4+
const { collectify, pullify, streamify } = require('../lib/iterable')
55

66
function requireCommands () {
77
return {
@@ -16,8 +16,10 @@ function requireCommands () {
1616
return nodeify(add(input, options), callback)
1717
}
1818
},
19-
// TODO: convert
20-
addReadableStream: require('../files-regular/add-readable-stream'),
19+
addReadableStream: (_, config) => {
20+
const add = require('../add')(config)
21+
return streamify.transform(add)
22+
},
2123
addPullStream: (_, config) => {
2224
const add = require('../add')(config)
2325
return pullify.transform(add)

0 commit comments

Comments
 (0)