Skip to content

Commit

Permalink
refactor: style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Feb 27, 2018
1 parent a09f3a2 commit 94ebc5d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const toTypedArray = require('typedarray-to-buffer')

const makeHeaders = obj => new Headers(obj)

const makeBody = value => {
function makeBody (value) {
// TODO: Streams support.
if (typeof value === 'string') {
value = Buffer.from(value)
Expand Down Expand Up @@ -55,7 +55,7 @@ class R2 {
if (typeof args[0] === 'object') {
opts = Object.assign(opts, args.shift())
}
if (opts.headers) this.setHeaders(opts.headers)
this.setHeaders(opts.headers)
this.opts = opts
}

Expand Down Expand Up @@ -84,16 +84,14 @@ class R2 {

return fetch(url, this.opts)
}
setHeaders (obj) {
setHeaders (obj = {}) {
for (let key in obj) {
this._caseless.set(key, obj[key])
}
return this
}
setHeader (key, value) {
let o = {}
o[key] = value
return this.setHeaders(o)
this.setHeaders({ [key]: value })
}
}

Expand Down

0 comments on commit 94ebc5d

Please sign in to comment.