@modern-js/create-request 2.5.1-alpha.5 → 2.5.1-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,7 +43,7 @@ const configure = (options) => {
43
43
  realAllowedHeaders = allowedHeaders;
44
44
  }
45
45
  };
46
- const createRequest = (path, method, port, httpMethodDecider = "functionName", fetch2 = originFetch) => {
46
+ const createRequest = (path, method, httpMethodDecider = "functionName", port, fetch2 = originFetch) => {
47
47
  const getFinalPath = (0, import_path_to_regexp.compile)(path, { encode: encodeURIComponent });
48
48
  const keys = [];
49
49
  (0, import_path_to_regexp.pathToRegexp)(path, keys);
@@ -92,7 +92,7 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
92
92
  args
93
93
  });
94
94
  headers = {
95
- ["Content-Type"]: "application/json"
95
+ "Content-Type": "application/json"
96
96
  };
97
97
  }
98
98
  return fetcher(finalURL, {
package/dist/cjs/node.js CHANGED
@@ -45,7 +45,7 @@ const configure = (options) => {
45
45
  realAllowedHeaders = allowedHeaders;
46
46
  }
47
47
  };
48
- const createRequest = (path, method, port, httpMethodDecider = "functionName", fetch = import_node_fetch.default) => {
48
+ const createRequest = (path, method, httpMethodDecider = "functionName", port, fetch = import_node_fetch.default) => {
49
49
  const getFinalPath = (0, import_path_to_regexp.compile)(path, { encode: encodeURIComponent });
50
50
  const keys = [];
51
51
  (0, import_path_to_regexp.pathToRegexp)(path, keys);
@@ -97,7 +97,7 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
97
97
  url = path;
98
98
  body = args;
99
99
  headers = {
100
- ["Content-Type"]: "application/json"
100
+ "Content-Type": "application/json"
101
101
  };
102
102
  }
103
103
  const fetcher = realRequest || originFetch;
@@ -35,19 +35,6 @@ function _asyncToGenerator(fn) {
35
35
  });
36
36
  };
37
37
  }
38
- function _defineProperty(obj, key, value) {
39
- if (key in obj) {
40
- Object.defineProperty(obj, key, {
41
- value: value,
42
- enumerable: true,
43
- configurable: true,
44
- writable: true
45
- });
46
- } else {
47
- obj[key] = value;
48
- }
49
- return obj;
50
- }
51
38
  function _instanceof(left, right) {
52
39
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
53
40
  return !!right[Symbol.hasInstance](left);
@@ -188,8 +175,8 @@ var configure = function(options) {
188
175
  realAllowedHeaders = allowedHeaders;
189
176
  }
190
177
  };
191
- var createRequest = function(path, method, port) {
192
- var httpMethodDecider = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "functionName", fetch2 = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : originFetch;
178
+ var createRequest = function(path, method) {
179
+ var httpMethodDecider = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "functionName", port = arguments.length > 3 ? arguments[3] : void 0, fetch2 = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : originFetch;
193
180
  var getFinalPath = compile(path, {
194
181
  encode: encodeURIComponent
195
182
  });
@@ -243,7 +230,9 @@ var createRequest = function(path, method, port) {
243
230
  body = JSON.stringify({
244
231
  args: args
245
232
  });
246
- headers = _defineProperty({}, "Content-Type", "application/json");
233
+ headers = {
234
+ "Content-Type": "application/json"
235
+ };
247
236
  }
248
237
  return [
249
238
  2,
package/dist/esm/node.js CHANGED
@@ -6,19 +6,6 @@ function _arrayLikeToArray(arr, len) {
6
6
  function _arrayWithoutHoles(arr) {
7
7
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
8
  }
9
- function _defineProperty(obj, key, value) {
10
- if (key in obj) {
11
- Object.defineProperty(obj, key, {
12
- value: value,
13
- enumerable: true,
14
- configurable: true,
15
- writable: true
16
- });
17
- } else {
18
- obj[key] = value;
19
- }
20
- return obj;
21
- }
22
9
  function _iterableToArray(iter) {
23
10
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
24
11
  }
@@ -59,8 +46,8 @@ var configure = function(options) {
59
46
  realAllowedHeaders = allowedHeaders;
60
47
  }
61
48
  };
62
- var createRequest = function(path, method, port) {
63
- var httpMethodDecider = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "functionName", fetch = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : nodeFetch;
49
+ var createRequest = function(path, method) {
50
+ var httpMethodDecider = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "functionName", port = arguments.length > 3 ? arguments[3] : void 0, fetch = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : nodeFetch;
64
51
  var getFinalPath = compile(path, {
65
52
  encode: encodeURIComponent
66
53
  });
@@ -133,7 +120,9 @@ var createRequest = function(path, method, port) {
133
120
  } else {
134
121
  url = path;
135
122
  body = args;
136
- headers = _defineProperty({}, "Content-Type", "application/json");
123
+ headers = {
124
+ "Content-Type": "application/json"
125
+ };
137
126
  }
138
127
  var fetcher = realRequest || originFetch;
139
128
  return fetcher(url, {
@@ -14,7 +14,7 @@ const configure = (options) => {
14
14
  realAllowedHeaders = allowedHeaders;
15
15
  }
16
16
  };
17
- const createRequest = (path, method, port, httpMethodDecider = "functionName", fetch2 = originFetch) => {
17
+ const createRequest = (path, method, httpMethodDecider = "functionName", port, fetch2 = originFetch) => {
18
18
  const getFinalPath = compile(path, { encode: encodeURIComponent });
19
19
  const keys = [];
20
20
  pathToRegexp(path, keys);
@@ -63,7 +63,7 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
63
63
  args
64
64
  });
65
65
  headers = {
66
- ["Content-Type"]: "application/json"
66
+ "Content-Type": "application/json"
67
67
  };
68
68
  }
69
69
  return fetcher(finalURL, {
@@ -16,7 +16,7 @@ const configure = (options) => {
16
16
  realAllowedHeaders = allowedHeaders;
17
17
  }
18
18
  };
19
- const createRequest = (path, method, port, httpMethodDecider = "functionName", fetch = nodeFetch) => {
19
+ const createRequest = (path, method, httpMethodDecider = "functionName", port, fetch = nodeFetch) => {
20
20
  const getFinalPath = compile(path, { encode: encodeURIComponent });
21
21
  const keys = [];
22
22
  pathToRegexp(path, keys);
@@ -68,7 +68,7 @@ const createRequest = (path, method, port, httpMethodDecider = "functionName", f
68
68
  url = path;
69
69
  body = args;
70
70
  headers = {
71
- ["Content-Type"]: "application/json"
71
+ "Content-Type": "application/json"
72
72
  };
73
73
  }
74
74
  const fetcher = realRequest || originFetch;
@@ -14,7 +14,7 @@ export type Fetch = typeof fetch | typeof nodeFetch;
14
14
  export type Sender = ((...args: any[]) => Promise<any>) & {
15
15
  fetch?: Fetch;
16
16
  };
17
- export type RequestCreator = (path: string, method: string, port: number, httpMethodDecider: HttpMethodDecider, fetch?: Fetch) => Sender;
17
+ export type RequestCreator = (path: string, method: string, httpMethodDecider: HttpMethodDecider, port: number, fetch?: Fetch) => Sender;
18
18
  export type IOptions<F = Fetch> = {
19
19
  request?: F;
20
20
  interceptor?: (request: F) => F;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.5.1-alpha.5",
14
+ "version": "2.5.1-alpha.6",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/cjs/index.js",