@faasjs/http 0.0.3-beta.104 → 0.0.3-beta.106

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.
package/dist/index.js CHANGED
@@ -370,6 +370,23 @@ var HttpError = class _HttpError extends Error {
370
370
  }
371
371
  };
372
372
  var Name = "http";
373
+ function deepClone(obj) {
374
+ if (obj === null || typeof obj !== "object")
375
+ return obj;
376
+ if (Array.isArray(obj))
377
+ return JSON.parse(JSON.stringify(obj));
378
+ const clone = {};
379
+ for (const key in obj) {
380
+ if (!obj.hasOwnProperty(key))
381
+ continue;
382
+ if (typeof obj[key] === "function") {
383
+ clone[key] = obj[key].bind(clone);
384
+ continue;
385
+ }
386
+ clone[key] = deepClone(obj[key]);
387
+ }
388
+ return clone;
389
+ }
373
390
  var Http = class {
374
391
  constructor(config) {
375
392
  this.type = Name;
@@ -452,7 +469,7 @@ var Http = class {
452
469
  }
453
470
  if (this.params && typeof this.params === "object" && this.params["_"])
454
471
  delete this.params["_"];
455
- data.event.params = JSON.parse(JSON.stringify(this.params));
472
+ data.event.params = deepClone(this.params);
456
473
  data.logger.debug("[onInvoke] Params: %j", this.params);
457
474
  }
458
475
  this.cookie.invoke(this.headers.cookie, data.logger);
package/dist/index.mjs CHANGED
@@ -368,6 +368,23 @@ var HttpError = class _HttpError extends Error {
368
368
  }
369
369
  };
370
370
  var Name = "http";
371
+ function deepClone(obj) {
372
+ if (obj === null || typeof obj !== "object")
373
+ return obj;
374
+ if (Array.isArray(obj))
375
+ return JSON.parse(JSON.stringify(obj));
376
+ const clone = {};
377
+ for (const key in obj) {
378
+ if (!obj.hasOwnProperty(key))
379
+ continue;
380
+ if (typeof obj[key] === "function") {
381
+ clone[key] = obj[key].bind(clone);
382
+ continue;
383
+ }
384
+ clone[key] = deepClone(obj[key]);
385
+ }
386
+ return clone;
387
+ }
371
388
  var Http = class {
372
389
  constructor(config) {
373
390
  this.type = Name;
@@ -450,7 +467,7 @@ var Http = class {
450
467
  }
451
468
  if (this.params && typeof this.params === "object" && this.params["_"])
452
469
  delete this.params["_"];
453
- data.event.params = JSON.parse(JSON.stringify(this.params));
470
+ data.event.params = deepClone(this.params);
454
471
  data.logger.debug("[onInvoke] Params: %j", this.params);
455
472
  }
456
473
  this.cookie.invoke(this.headers.cookie, data.logger);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/http",
3
- "version": "0.0.3-beta.104",
3
+ "version": "0.0.3-beta.106",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,8 +22,8 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@faasjs/func": "0.0.3-beta.104",
26
- "@faasjs/logger": "0.0.3-beta.104"
25
+ "@faasjs/func": "0.0.3-beta.106",
26
+ "@faasjs/logger": "0.0.3-beta.106"
27
27
  },
28
28
  "engines": {
29
29
  "npm": ">=8.0.0",