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: add types, gh actions and remove unused methods #89

Merged
merged 10 commits into from
Jan 15, 2021
Merged

Conversation

hugomrdias
Copy link
Member

  • add http, fetch types
  • remove globalThis, this is supported everywhere now
  • add types for env, path, supports and temp-dir
  • use web-encoding for encoder/decoder
  • add types for files functions
  • remove some files functions that are in ipfs-core-utils

BREAKING CHANGE: removed globalThis and normalise-input, format-mode and format-mtime

Copy link
Member

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

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

Did a fast pass through this. Overall, it looks good from the types perspective.

Ideally, this should be well tested against js-ipfs, to guarantee that the HTTP/Fetch changes do not create regressions.

src/files/glob-source.js Outdated Show resolved Hide resolved

// validate resource type
if (typeof resource !== 'string' && !(resource instanceof URL || resource instanceof Request)) {
throw new TypeError('`resource` must be a string, URL, or Request')
}

// validate resource format and normalize with prefixUrl
Copy link
Member

Choose a reason for hiding this comment

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

Is this not needed anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

URL below this line does the job

src/http.js Outdated Show resolved Hide resolved
Copy link
Contributor

@Gozala Gozala left a comment

Choose a reason for hiding this comment

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

Thanks @hugomrdias for your hard work, this is a lot. I have suggested some improvements that I think would be worth incorporating & also nit picked a bit, but feel free to ignore those.

src/files/glob-source.js Outdated Show resolved Hide resolved
path: string;
content?: AsyncIterable<Uint8Array>;
}>}
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

This reminds me, we really should make this return a Promise<{path: string, content:AsyncIterable<Uint8Array>}> instead (see #53)

}

if (opts.json !== undefined) {
if (json) {
Copy link
Contributor

Choose a reason for hiding this comment

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

null is valid JSON, which would have worked without this change.

...options,
method: 'POST'
})
return this.fetch(resource, { ...options, method: 'POST' })
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think line breaks are good, as they cause less noise when adding or removing an option.

@@ -166,71 +166,56 @@ class HTTP {
}

/**
* @param {string | URL | Request} resource
* @param {APIOptions} options
* @param {string | Request} resource
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think supporting URL instances is a good idea, as unlike strings they do represent valid urls.

src/supports.js Show resolved Hide resolved
test/files/url-source.spec.js Outdated Show resolved Hide resolved
test/http.spec.js Outdated Show resolved Hide resolved
types/electron-fetch/index.d.ts Show resolved Hide resolved
@@ -0,0 +1 @@
export { URL, URLSearchParams }
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, I thought TS did not liked exports of things that aren't defined locally.

Copy link
Member Author

Choose a reason for hiding this comment

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

our config has the browser/dom stuff

Copy link
Member

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

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

LGTM

@achingbrain achingbrain merged commit 707174c into master Jan 15, 2021
@achingbrain achingbrain deleted the feat/types branch January 15, 2021 15:35
This was referenced Jan 15, 2021
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.

4 participants