Skip to content

Can merge be replaced by ES6 destructuring? #9

Description

@pke

I wonder if the usage of lodash/merge is obsolete for the operations most middlewares do here?
They usually don't do deep merges so couldn't

return fetch(url, extendedFetch.merge({}, options, {
  headers: {
    "Authorization": "Bearer ...",
  }
}))

be replaced with:

return fetch(url, {
  ...options,
  headers: {
    ...options.headers,
    "Authorization": "Bearer ...",
  }
}))
it.only("should not matter", () => {
    const options = {
      body: "Test",
      headers: {
        "Accept": "text/plain",
      },
    }
    expect(extendFetch.merge({}, options, {
      headers: {
        "Content-Type": "text/plain",
      },
    })).toEqual({
      ...options,
      headers: {
        ...options.headers,
        "Content-Type": "text/plain",
      },
    })
  })

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions