Skip to content

Commit 244117f

Browse files
committed
Create deprecated function for better code reuse
1 parent 36a657a commit 244117f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/scales/scale.time.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ var INTERVALS = {
6060

6161
var UNITS = Object.keys(INTERVALS);
6262

63+
function deprecated(value, previous, current) {
64+
if (value !== undefined) {
65+
console.warn(
66+
'time scale: "' + previous+ '" is deprecated. ' +
67+
'Please use "' + current + '" instead');
68+
}
69+
}
70+
6371
function sorter(a, b) {
6472
return a - b;
6573
}
@@ -481,17 +489,9 @@ module.exports = Scale.extend({
481489
var adapter = me._adapter = new adapters._date(options.adapters.date);
482490

483491
// DEPRECATIONS: output a message only one time per update
484-
if (time.format) {
485-
console.warn('options.time.format is deprecated and replaced by options.time.parser.');
486-
}
487-
488-
if (time.min) {
489-
console.warn('options.time.min is deprecated. Please use options.ticks.min');
490-
}
491-
492-
if (time.max) {
493-
console.warn('options.time.max is deprecated. Please use options.ticks.max');
494-
}
492+
deprecated(time.format, 'time.format', 'time.parser');
493+
deprecated(time.min, 'time.min', 'ticks.min');
494+
deprecated(time.max, 'time.max', 'ticks.max');
495495

496496
// Backward compatibility: before introducing adapter, `displayFormats` was
497497
// supposed to contain *all* unit/string pairs but this can't be resolved

0 commit comments

Comments
 (0)