Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support iterators and async iterators #2

Closed
wants to merge 5 commits into from
Closed

feat: support iterators and async iterators #2

wants to merge 5 commits into from

Conversation

achingbrain
Copy link
Member

This allows us to accept async interators as arguments to ipfs.add and friends.

It also allows adding plain old js things like strings and arrays, so hooray for that.

This allows us to accept async interators as arguments to `ipfs.add`
and friends.

It also allows adding plain old js things like strings and arrays,
so hooray for that.
@achingbrain
Copy link
Member Author

PR from my own fork 'cos I don't have push access to this repo.

@@ -14,6 +14,8 @@ const expect = chai.expect

describe('add-input-validation', function () {
it('validates correct primitive input types', function () {
expect(validate('Hello world')).to.be.true()
expect(validate([0, 1, 2, 3])).to.be.true()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ test for async iterator?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@alanshaw
Copy link
Member

@achingbrain there are some lint warnings causing this to fail in CI

@achingbrain
Copy link
Member Author

Should be all good now.

@achingbrain achingbrain mentioned this pull request Aug 29, 2019
Copy link
Member

@hugomrdias hugomrdias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@achingbrain what you wanna do about pull-streams ? should it be removed too ?

@@ -24,7 +22,7 @@ const validateAddInput = (input) => {
if (isInput(input) || (Array.isArray(input) && input.every(isInput))) {
return true
} else {
throw new Error(`Input not supported. Expected Buffer|ReadableStream|PullStream|File|Array<Object> got ${kindOf(input)}. Check the documentation for more info https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#add`)
throw new Error(`Input not supported. Expected Buffer|ReadableStream|PullStream|File|Array<Object>| got ${kindOf(input)}. Check the documentation for more info https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#add`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new Error(`Input not supported. Expected Buffer|ReadableStream|PullStream|File|Array<Object>| got ${kindOf(input)}. Check the documentation for more info https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#add`)
throw new Error(`Input not supported. Expected Iterator|AsyncIterator|PullStream|File|Array<Object>| got ${kindOf(input)}. Check the documentation for more info https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#add`)

@achingbrain
Copy link
Member Author

Closing in favour of #6 which from a branch in this repo..

@achingbrain achingbrain deleted the support-async-iterators branch August 31, 2019 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants