Skip to content

Commit

Permalink
fix: merge options with nested default nested
Browse files Browse the repository at this point in the history
  • Loading branch information
Almouro committed Sep 19, 2019
1 parent 92a2de1 commit 54dcaef
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 22 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"common-tags": "^1.8.0",
"cross-fetch": "^3.0.4",
"debug": "^4.1.1",
"defaults-deep": "^0.2.4",
"qs": "^6.8.0",
"url-join": "^4.0.1",
"url-parse": "^1.4.7"
Expand Down
45 changes: 24 additions & 21 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const urlJoin = require('url-join');
const URL = require('url-parse');
const debug = require('debug')('frisbee');
const boolean = require('boolean');
const defaults = require('defaults-deep');

// eslint-disable-next-line import/no-unassigned-import
require('cross-fetch/polyfill');
Expand Down Expand Up @@ -94,28 +95,30 @@ function createFrisbeeResponse(origResp) {

class Frisbee {
constructor(opts = {}) {
this.opts = {
parse: {
ignoreQueryPrefix: true
},
stringify: {
addQueryPrefix: true,
format: 'RFC1738',
arrayFormat: 'indices'
this.opts = defaults(
{
preventBodyOnMethods: ['GET', 'HEAD', 'DELETE', 'CONNECT'],
interceptableMethods: METHODS,
mode: 'same-origin',
cache: 'default',
credentials: 'same-origin',
redirect: 'follow',
referrer: 'client',
body: null,
params: null,
logRequest: false,
logResponse: false,
parse: {
ignoreQueryPrefix: true
},
stringify: {
addQueryPrefix: true,
format: 'RFC1738',
arrayFormat: 'indices'
}
},
preventBodyOnMethods: ['GET', 'HEAD', 'DELETE', 'CONNECT'],
interceptableMethods: METHODS,
mode: 'same-origin',
cache: 'default',
credentials: 'same-origin',
redirect: 'follow',
referrer: 'client',
body: null,
params: null,
logRequest: false,
logResponse: false,
...opts
};
opts
);

let localAbortController;
Object.defineProperty(this, 'abortController', {
Expand Down
23 changes: 22 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2863,6 +2863,15 @@ default-require-extensions@^2.0.0:
dependencies:
strip-bom "^3.0.0"

defaults-deep@^0.2.4:
version "0.2.4"
resolved "https://registry.yarnpkg.com/defaults-deep/-/defaults-deep-0.2.4.tgz#a479cfeafce025810fb93aa8d2dde0ee2d677cc6"
integrity sha512-V6BtqzcMvn0EPOy7f+SfMhfmTawq+7UQdt9yZH0EBK89+IHo5f+Hse/qzTorAXOBrQpxpwb6cB/8OgtaMrT+Fg==
dependencies:
for-own "^0.1.3"
is-extendable "^0.1.1"
lazy-cache "^0.2.3"

defaults@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d"
Expand Down Expand Up @@ -4141,11 +4150,18 @@ fn-name@^2.0.1:
resolved "https://registry.yarnpkg.com/fn-name/-/fn-name-2.0.1.tgz#5214d7537a4d06a4a301c0cc262feb84188002e7"
integrity sha1-UhTXU3pNBqSjAcDMJi/rhBiAAuc=

for-in@^1.0.2:
for-in@^1.0.1, for-in@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=

for-own@^0.1.3:
version "0.1.5"
resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce"
integrity sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=
dependencies:
for-in "^1.0.1"

foreach@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
Expand Down Expand Up @@ -5601,6 +5617,11 @@ latest-version@^5.0.0:
dependencies:
package-json "^6.3.0"

lazy-cache@^0.2.3:
version "0.2.7"
resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-0.2.7.tgz#7feddf2dcb6edb77d11ef1d117ab5ffdf0ab1b65"
integrity sha1-f+3fLctu23fRHvHRF6tf/fCrG2U=

levenshtein-edit-distance@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/levenshtein-edit-distance/-/levenshtein-edit-distance-1.0.0.tgz#895baf478cce8b5c1a0d27e45d7c1d978a661e49"
Expand Down

0 comments on commit 54dcaef

Please sign in to comment.