Skip to content
Myr

use utils-merge module to mixin object properties

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Roman Shtylman · committed by Roman Shtylman · parent f56a5f0 · Browse files · 5 files+15 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+15 added−11 removed

  • tests:+2 added−2 removed
  • other:+13 added−9 removed

5 files+15 added−11 removed

modified:lib/application.js+4 added-3 removed
1 unmodified line
2 * Module dependencies.3 */45var connect = require('connect')6 , mixin = require('utils-merge')7 , Router = require('./router')8 , methods = require('methods')9 , middleware = require('./middleware')10 , debug = require('debug')('express:application')
396 unmodified lines
407 fn = options, options = {};408 }409410 // merge app.locals410 utils.merge(opts, this.locals);411 mixin(opts, this.locals);412413 // merge options._locals413 if (options._locals) utils.merge(opts, options._locals);414 if (options._locals) mixin(opts, options._locals);415416 // merge options416 utils.merge(opts, options);417 mixin(opts, options);418419 // set .cache unless explicitly provided420 opts.cache = null == opts.cache421 ? this.enabled('view cache')
56 unmodified lines
modified:lib/express.js+5 added-4 removed
modified:lib/response.js+3 added-2 removed
3 unmodified lines
45var http = require('http')6 , path = require('path')7 , connect = require('connect')8 , mixin = require('utils-merge')9 , utils = connect.utils10 , sign = require('cookie-signature').sign11 , normalizeType = require('./utils').normalizeType12 , normalizeTypes = require('./utils').normalizeTypes
544 unmodified lines
557558res.clearCookie = function(name, options){559 var opts = { expires: new Date(1), path: '/' };560 return this.cookie(name, '', options560 ? utils.merge(opts, options)561 ? mixin(opts, options)562 : opts);563};564565/**
19 unmodified lines
585 * @api public586 */587588res.cookie = function(name, val, options){588 options = utils.merge({}, options);589 options = mixin({}, options);590 var secret = this.req.secret;591 var signed = options.signed;592 if (signed && !secret) throw new Error('connect.cookieParser("secret") required for signed cookies');593 if ('number' == typeof val) val = val.toString();
207 unmodified lines
modified:test/res.cookie.js+2 added-2 removed
12var express = require('../')3 , request = require('./support/http')4 , utils = require('connect').utils4 , mixin = require('utils-merge')5 , cookie = require('cookie');67describe('res', function(){8 describe('.cookie(name, object)', function(){
104 unmodified lines
113 it('should not mutate the options object', function(done){114 var app = express();115116 var options = { maxAge: 1000 };117 var optionsCopy = utils.merge({}, options);117 var optionsCopy = mixin({}, options);118119 app.use(function(req, res){120 res.cookie('name', 'tobi', options)121 res.end();
53 unmodified lines
modified:package.json+1 added