MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / deprecate

Function deprecate

tests/test_code/js/moment/moment.js:287–325  ·  view source on GitHub ↗
(msg, fn)

Source from the content-addressed store, hash-verified

285 }
286
287 function deprecate(msg, fn) {
288 var firstTime = true;
289
290 return extend(function () {
291 if (hooks.deprecationHandler != null) {
292 hooks.deprecationHandler(null, msg);
293 }
294 if (firstTime) {
295 var args = [],
296 arg,
297 i,
298 key;
299 for (i = 0; i < arguments.length; i++) {
300 arg = '';
301 if (typeof arguments[i] === 'object') {
302 arg += '\n[' + i + '] ';
303 for (key in arguments[0]) {
304 if (hasOwnProp(arguments[0], key)) {
305 arg += key + ': ' + arguments[0][key] + ', ';
306 }
307 }
308 arg = arg.slice(0, -2); // Remove trailing comma and space
309 } else {
310 arg = arguments[i];
311 }
312 args.push(arg);
313 }
314 warn(
315 msg +
316 '\nArguments: ' +
317 Array.prototype.slice.call(args).join('') +
318 '\n' +
319 new Error().stack
320 );
321 firstTime = false;
322 }
323 return fn.apply(this, arguments);
324 }, fn);
325 }
326
327 var deprecations = {};
328

Callers 1

moment.jsFile · 0.85

Calls 4

extendFunction · 0.85
hasOwnPropFunction · 0.85
warnFunction · 0.85
applyMethod · 0.80

Tested by

no test coverage detected