From 244117fa784899a72b13ae7a144255b3aade89bd Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Thu, 28 Mar 2019 06:04:48 -0700 Subject: [PATCH] Create deprecated function for better code reuse --- src/scales/scale.time.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index 8bb98e6c332..1bd110e2da8 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -60,6 +60,14 @@ var INTERVALS = { var UNITS = Object.keys(INTERVALS); +function deprecated(value, previous, current) { + if (value !== undefined) { + console.warn( + 'time scale: "' + previous+ '" is deprecated. ' + + 'Please use "' + current + '" instead'); + } +} + function sorter(a, b) { return a - b; } @@ -481,17 +489,9 @@ module.exports = Scale.extend({ var adapter = me._adapter = new adapters._date(options.adapters.date); // DEPRECATIONS: output a message only one time per update - if (time.format) { - console.warn('options.time.format is deprecated and replaced by options.time.parser.'); - } - - if (time.min) { - console.warn('options.time.min is deprecated. Please use options.ticks.min'); - } - - if (time.max) { - console.warn('options.time.max is deprecated. Please use options.ticks.max'); - } + deprecated(time.format, 'time.format', 'time.parser'); + deprecated(time.min, 'time.min', 'ticks.min'); + deprecated(time.max, 'time.max', 'ticks.max'); // Backward compatibility: before introducing adapter, `displayFormats` was // supposed to contain *all* unit/string pairs but this can't be resolved