Skip to content

Commit

Permalink
Remove utils-merge dependency - use spread syntax instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillip9587 committed Dec 17, 2024
1 parent 4e92ac9 commit e86f1be
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 16 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
unreleased
========================

* Remove `utils-merge` dependency - use spread syntax instead
* Remove `Object.setPrototypeOf` polyfill
* cleanup: remove AsyncLocalStorage check from tests
* cleanup: remove unnecessary require for global Buffer
Expand Down
12 changes: 1 addition & 11 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ var http = require('http');
var compileETag = require('./utils').compileETag;
var compileQueryParser = require('./utils').compileQueryParser;
var compileTrust = require('./utils').compileTrust;
var merge = require('utils-merge');
var resolve = require('path').resolve;
var once = require('once')
var Router = require('router');
Expand Down Expand Up @@ -525,7 +524,6 @@ app.render = function render(name, options, callback) {
var done = callback;
var engines = this.engines;
var opts = options;
var renderOptions = {};
var view;

// support callback function as second arg
Expand All @@ -534,16 +532,8 @@ app.render = function render(name, options, callback) {
opts = {};
}

// merge app.locals
merge(renderOptions, this.locals);

// merge options._locals
if (opts._locals) {
merge(renderOptions, opts._locals);
}

// merge options
merge(renderOptions, opts);
var renderOptions = { ...this.locals, ...opts._locals, ...opts };

// set .cache unless explicitly provided
if (renderOptions.cache == null) {
Expand Down
3 changes: 1 addition & 2 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var mime = require('mime-types')
var path = require('path');
var pathIsAbsolute = require('path').isAbsolute;
var statuses = require('statuses')
var merge = require('utils-merge');
var sign = require('cookie-signature').sign;
var normalizeType = require('./utils').normalizeType;
var normalizeTypes = require('./utils').normalizeTypes;
Expand Down Expand Up @@ -732,7 +731,7 @@ res.clearCookie = function clearCookie(name, options) {
*/

res.cookie = function (name, value, options) {
var opts = merge({}, options);
var opts = { ...options };
var secret = this.req.secret;
var signed = opts.signed;

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"serve-static": "^2.1.0",
"statuses": "2.0.1",
"type-is": "^2.0.0",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions test/res.cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
var express = require('../')
, request = require('supertest')
, cookieParser = require('cookie-parser')
var merge = require('utils-merge');

describe('res', function(){
describe('.cookie(name, object)', function(){
Expand Down Expand Up @@ -130,7 +129,7 @@ describe('res', function(){
var app = express();

var options = { maxAge: 1000 };
var optionsCopy = merge({}, options);
var optionsCopy = { ...options };

app.use(function(req, res){
res.cookie('name', 'tobi', options)
Expand Down

0 comments on commit e86f1be

Please sign in to comment.