corrade-nucleus-nucleons – Blame information for rev 38

Subversion Repositories:
Rev:
Rev Author Line No. Line
38 office 1 import extend from './extend';
2 import { hooks } from './hooks';
3 import isUndefined from './is-undefined';
4  
5 function warn(msg) {
6 if (hooks.suppressDeprecationWarnings === false &&
7 (typeof console !== 'undefined') && console.warn) {
8 console.warn('Deprecation warning: ' + msg);
9 }
10 }
11  
12 export function deprecate(msg, fn) {
13 var firstTime = true;
14  
15 return extend(function () {
16 if (hooks.deprecationHandler != null) {
17 hooks.deprecationHandler(null, msg);
18 }
19 if (firstTime) {
20 var args = [];
21 var arg;
22 for (var i = 0; i < arguments.length; i++) {
23 arg = '';
24 if (typeof arguments[i] === 'object') {
25 arg += '\n[' + i + '] ';
26 for (var key in arguments[0]) {
27 arg += key + ': ' + arguments[0][key] + ', ';
28 }
29 arg = arg.slice(0, -2); // Remove trailing comma and space
30 } else {
31 arg = arguments[i];
32 }
33 args.push(arg);
34 }
35 warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
36 firstTime = false;
37 }
38 return fn.apply(this, arguments);
39 }, fn);
40 }
41  
42 var deprecations = {};
43  
44 export function deprecateSimple(name, msg) {
45 if (hooks.deprecationHandler != null) {
46 hooks.deprecationHandler(name, msg);
47 }
48 if (!deprecations[name]) {
49 warn(msg);
50 deprecations[name] = true;
51 }
52 }
53  
54 hooks.suppressDeprecationWarnings = false;
55 hooks.deprecationHandler = null;