Skip to content

Replace deprecated util._extend with Object.assign to ensure compatibility with modern Node.js #491

Description

@ahmedabdou0178

I used patch-package to patch strong-remoting@3.17.0 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/strong-remoting/lib/http-context.js b/node_modules/strong-remoting/lib/http-context.js
index 964411b..a0aaa6b 100644
--- a/node_modules/strong-remoting/lib/http-context.js
+++ b/node_modules/strong-remoting/lib/http-context.js
@@ -357,7 +357,7 @@ function toJSON(input) {
 function toXML(input, options) {
   let xml;
   const xmlDefaultOptions = {declaration: true};
-  const xmlOptions = util._extend(xmlDefaultOptions, options);
+  const xmlOptions = Object.assign(xmlDefaultOptions, options);
   if (input && typeof input.toXML === 'function') {
     xml = input.toXML();
   } else {
diff --git a/node_modules/strong-remoting/lib/rest-adapter.js b/node_modules/strong-remoting/lib/rest-adapter.js
index eb1f48f..615689c 100644
--- a/node_modules/strong-remoting/lib/rest-adapter.js
+++ b/node_modules/strong-remoting/lib/rest-adapter.js
@@ -655,7 +655,7 @@ function RestMethod(restClass, sharedMethod) {
     const routes = this.routes = [];
     methodRoutes.forEach(function(route) {
       restClass.ctor.routes.forEach(function(ctorRoute) {
-        const fullRoute = util._extend({}, route);
+        const fullRoute = Object.assign({}, route);
         fullRoute.path = joinPaths(ctorRoute.path, route.path);
         routes.push(fullRoute);
       });
diff --git a/node_modules/strong-remoting/lib/shared-class.js b/node_modules/strong-remoting/lib/shared-class.js
index 8886fe9..8948b66 100644
--- a/node_modules/strong-remoting/lib/shared-class.js
+++ b/node_modules/strong-remoting/lib/shared-class.js
@@ -20,7 +20,7 @@ module.exports = SharedClass;
 const debug = require('debug')('strong-remoting:shared-class');
 const util = require('util');
 const inherits = util.inherits;
-const extend = util._extend;
+const extend = Object.assign;
 const SharedMethod = require('./shared-method');
 const assert = require('assert');
 
@@ -55,7 +55,7 @@ function SharedClass(name, ctor, options) {
     }
   } else {
     // set http.path using the name unless it is defined
-    this.http = util._extend(defaultHttp, http);
+    this.http = Object.assign(defaultHttp, http);
   }
 
   if (typeof ctor === 'function' && ctor.sharedCtor) {

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions