@naturalcycles/js-lib 14.123.0 → 14.123.2

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.
@@ -24,6 +24,9 @@ const defRetryOptions = {
24
24
  */
25
25
  class Fetcher {
26
26
  constructor(cfg = {}) {
27
+ if (typeof globalThis.fetch !== 'function') {
28
+ throw new TypeError(`globalThis.fetch is not available`);
29
+ }
27
30
  this.cfg = this.normalizeCfg(cfg);
28
31
  // Dynamically create all helper methods
29
32
  http_model_1.HTTP_METHODS.forEach(method => {
@@ -318,10 +321,10 @@ class Fetcher {
318
321
  }
319
322
  req.url = `${baseUrl}/${url}`;
320
323
  }
321
- const searchParams = {
324
+ const searchParams = (0, object_util_1._filterUndefinedValues)({
322
325
  ...this.cfg.searchParams,
323
326
  ...opt.searchParams,
324
- };
327
+ });
325
328
  if (Object.keys(searchParams).length) {
326
329
  const qs = new URLSearchParams(searchParams).toString();
327
330
  req.url += req.url.includes('?') ? '&' : '?' + qs;
@@ -22,6 +22,9 @@ const defRetryOptions = {
22
22
  */
23
23
  export class Fetcher {
24
24
  constructor(cfg = {}) {
25
+ if (typeof globalThis.fetch !== 'function') {
26
+ throw new TypeError(`globalThis.fetch is not available`);
27
+ }
25
28
  this.cfg = this.normalizeCfg(cfg);
26
29
  // Dynamically create all helper methods
27
30
  HTTP_METHODS.forEach(method => {
@@ -348,7 +351,7 @@ export class Fetcher {
348
351
  }
349
352
  req.url = `${baseUrl}/${url}`;
350
353
  }
351
- const searchParams = Object.assign(Object.assign({}, this.cfg.searchParams), opt.searchParams);
354
+ const searchParams = _filterUndefinedValues(Object.assign(Object.assign({}, this.cfg.searchParams), opt.searchParams));
352
355
  if (Object.keys(searchParams).length) {
353
356
  const qs = new URLSearchParams(searchParams).toString();
354
357
  req.url += req.url.includes('?') ? '&' : '?' + qs;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.123.0",
3
+ "version": "14.123.2",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
7
- "docs-serve": "vuepress dev docs",
8
- "docs-build": "vuepress build docs"
7
+ "docs-serve": "NODE_OPTIONS=--openssl-legacy-provider vuepress dev docs",
8
+ "docs-build": "NODE_OPTIONS=--openssl-legacy-provider vuepress build docs"
9
9
  },
10
10
  "dependencies": {
11
11
  "tslib": "^2.0.0"
package/readme.md CHANGED
@@ -15,7 +15,7 @@
15
15
  # Packaging
16
16
 
17
17
  - `engines.node >= Node.js LTS`
18
- - `main: dist/index.js`: commonjs, es2020 - targeting Node.js
18
+ - `main: dist/index.js`: commonjs, es2021 - targeting Node.js
19
19
  - `module: dist-esm/index.js`: esm, es2017 - targeting Browsers
20
20
  - `types: dist/index.d.ts`: typescript types
21
21
  - `/src` folder with source `*.ts` files included
@@ -187,6 +187,10 @@ const defRetryOptions: FetcherRetryOptions = {
187
187
  */
188
188
  export class Fetcher {
189
189
  private constructor(cfg: FetcherCfg & FetcherOptions = {}) {
190
+ if (typeof globalThis.fetch !== 'function') {
191
+ throw new TypeError(`globalThis.fetch is not available`)
192
+ }
193
+
190
194
  this.cfg = this.normalizeCfg(cfg)
191
195
 
192
196
  // Dynamically create all helper methods
@@ -561,10 +565,10 @@ export class Fetcher {
561
565
  req.url = `${baseUrl}/${url}`
562
566
  }
563
567
 
564
- const searchParams = {
568
+ const searchParams = _filterUndefinedValues({
565
569
  ...this.cfg.searchParams,
566
570
  ...opt.searchParams,
567
- }
571
+ })
568
572
 
569
573
  if (Object.keys(searchParams).length) {
570
574
  const qs = new URLSearchParams(searchParams).toString()