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

Style improvements #21

Closed
brianmhunt opened this issue Sep 5, 2017 · 2 comments · Fixed by #56
Closed

Style improvements #21

brianmhunt opened this issue Sep 5, 2017 · 2 comments · Fixed by #56

Comments

@brianmhunt
Copy link

brianmhunt commented Sep 5, 2017

Much like #10, consider some ES6ish things:

  1. The defineProperty code is unnecessarily verbose. Consider
    i. changing the defineProperty to getters e.g. get json () { return this.response.then(resp => resp.clone().json()) } or
    ii. using ['json', 'blob', ...].forEach((n) => Object.defineProperty(this, n, {get: () => this.response.then(r => r.clone()[n]()}) or
    iii. using defineProperties
  2. Define setHeaders(obj = {}) and remove if (opts.headers)
  3. change makeBody to a named function so that its name shows up when debugging
  4. change setHeader (key, value) { this.setHeaders({ [key]: value }) }
  5. have _args return this, then change all the http method methods (get, post, ...) to return this._args(...args)
@gr2m gr2m mentioned this issue Feb 27, 2018
@gr2m
Copy link
Collaborator

gr2m commented Feb 27, 2018

done via #38

  • The defineProperty code is unnecessarily verbose. Consider
    i. changing the defineProperty to getters e.g. get json () { return this.response.then(resp => resp.clone().json()) } or
    ii. using ['json', 'blob', ...].forEach((n) => Object.defineProperty(this, n, {get: () => this.response.then(r => r.clone()[n]()}) or
    iii. using defineProperties

PR at #56

  • change makeBody to a named function so that its name shows up when debugging
  • change setHeader (key, value) { this.setHeaders({ [key]: value }) }
  • Define setHeaders(obj = {}) and remove if (opts.headers)

I think that’s obsolete

  • have _args return this, then change all the http method methods (get, post, ...) to return this._args(...args)

@brianmhunt
Copy link
Author

I find this oddly satisfying. 😉

@gr2m gr2m closed this as completed in #56 May 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants