]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Update deprecate function to expand values of an argument which is an object
authorCorasWorksSolutions <david.smiley@corascloud.com>
Mon, 22 Aug 2016 16:14:09 +0000 (12:14 -0400)
committerIskren Chernev <iskren.chernev@gmail.com>
Sat, 3 Sep 2016 06:32:38 +0000 (23:32 -0700)
src/lib/utils/deprecate.js

index 8ed45e5a6a8f7a5f0d227c1f8b007043fe420b23..8b4c87a280551ce91636911a3fdf81b9bea8b0ae 100644 (file)
@@ -17,7 +17,22 @@ export function deprecate(msg, fn) {
             hooks.deprecationHandler(null, msg);
         }
         if (firstTime) {
-            warn(msg + '\nArguments: ' + Array.prototype.slice.call(arguments).join(', ') + '\n' + (new Error()).stack);
+            var args = [];
+            var arg;
+            for (var i = 0; i < arguments.length; i++) {
+                arg = '';
+                if (typeof arguments[i] === 'object') {
+                    arg += '\n[' + i + '] ';
+                    for (var key in arguments[0]) {
+                        arg += key + ': ' + arguments[0][key] + ', ';
+                    }
+                    arg = arg.slice(0, -2); // Remove trailing comma and space
+                } else {
+                    arg = arguments[i];
+                }
+                args.push(arg);
+            }
+            warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
             firstTime = false;
         }
         return fn.apply(this, arguments);