This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add files.ls streaming methods
N.b will not actually do any streaming until ipfs/kubo#5611 lands
- Loading branch information
1 parent
c191eea
commit c203ede
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict' | ||
|
||
const ls = require('./ls') | ||
const defer = require('pull-defer') | ||
const values = require('pull-stream/sources/values') | ||
|
||
module.exports = (send) => { | ||
return (args, opts) => { | ||
const deferred = defer.source() | ||
|
||
ls(send)(args, opts, (err, entries) => { | ||
if (err) { | ||
return deferred.abort(err) | ||
} | ||
|
||
return deferred.resolve(values(entries)) | ||
}) | ||
|
||
return deferred | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict' | ||
|
||
const lsPullStream = require('./ls-pull-stream') | ||
const toStream = require('pull-stream-to-stream') | ||
|
||
module.exports = (send) => { | ||
return (args, opts) => { | ||
return toStream.source(lsPullStream(send)(args, opts)) | ||
} | ||
} |