22 * Module dependencies.
33 */
44
5+ var deprecate = require ( 'depd' ) ( 'express' ) ;
56var escapeHtml = require ( 'escape-html' ) ;
67var vary = require ( 'vary' ) ;
78var http = require ( 'http' )
@@ -12,7 +13,6 @@ var http = require('http')
1213 , normalizeType = require ( './utils' ) . normalizeType
1314 , normalizeTypes = require ( './utils' ) . normalizeTypes
1415 , setCharset = require ( './utils' ) . setCharset
15- , deprecate = require ( './utils' ) . deprecate
1616 , statusCodes = http . STATUS_CODES
1717 , cookie = require ( 'cookie' )
1818 , send = require ( 'send' )
@@ -196,9 +196,11 @@ res.json = function(obj){
196196 // res.json(body, status) backwards compat
197197 if ( 'number' == typeof arguments [ 1 ] ) {
198198 this . statusCode = arguments [ 1 ] ;
199- return 'number' === typeof obj
200- ? jsonNumDeprecated . call ( this , obj )
201- : jsonDeprecated . call ( this , obj ) ;
199+ if ( typeof obj === 'number' ) {
200+ deprecate ( 'res.json(obj, status): Use res.json(status, obj) instead' ) ;
201+ } else {
202+ deprecate ( 'res.json(num, status): Use res.status(status).json(num) instead' ) ;
203+ }
202204 } else {
203205 this . statusCode = obj ;
204206 obj = arguments [ 1 ] ;
@@ -218,12 +220,6 @@ res.json = function(obj){
218220 return this . send ( body ) ;
219221} ;
220222
221- var jsonDeprecated = deprecate ( res . json ,
222- 'res.json(obj, status): Use res.json(status, obj) instead' ) ;
223-
224- var jsonNumDeprecated = deprecate ( res . json ,
225- 'res.json(num, status): Use res.status(status).json(num) instead' ) ;
226-
227223/**
228224 * Send JSON response with JSONP callback support.
229225 *
@@ -246,9 +242,11 @@ res.jsonp = function(obj){
246242 // res.json(body, status) backwards compat
247243 if ( 'number' == typeof arguments [ 1 ] ) {
248244 this . statusCode = arguments [ 1 ] ;
249- return 'number' === typeof obj
250- ? jsonpNumDeprecated . call ( this , obj )
251- : jsonpDeprecated . call ( this , obj ) ;
245+ if ( typeof obj === 'number' ) {
246+ deprecate ( 'res.jsonp(obj, status): Use res.jsonp(status, obj) instead' ) ;
247+ } else {
248+ deprecate ( 'res.jsonp(num, status): Use res.status(status).jsonp(num) instead' ) ;
249+ }
252250 } else {
253251 this . statusCode = obj ;
254252 obj = arguments [ 1 ] ;
@@ -283,12 +281,6 @@ res.jsonp = function(obj){
283281 return this . send ( body ) ;
284282} ;
285283
286- var jsonpDeprecated = deprecate ( res . json ,
287- 'res.jsonp(obj, status): Use res.jsonp(status, obj) instead' ) ;
288-
289- var jsonpNumDeprecated = deprecate ( res . json ,
290- 'res.jsonp(num, status): Use res.status(status).jsonp(num) instead' ) ;
291-
292284/**
293285 * Transfer the file at the given `path`.
294286 *
0 commit comments