diff --git a/src/nf.js b/src/nf.js index 21c61a1c..a29529cf 100644 --- a/src/nf.js +++ b/src/nf.js @@ -6,8 +6,21 @@ export class NfValueConverter { this.service = i18n; } - toView(value, formatOptions, locale, numberFormat) { - let nf = numberFormat || this.service.nf(formatOptions, locale || this.service.getLocale()); + toView(value, nfOrOptions, locale, nf) { + if (value === null + || typeof value === 'undefined' + || (typeof value === 'string' && value.trim() === '') + ) { + return value; + } + + if (nfOrOptions && (typeof nfOrOptions.format === 'function')) { + return nfOrOptions.format(value); + } else if (nf) { + console.warn('This ValueConverter signature is depcrecated and will be removed in future releases. Please use the signature [nfOrOptions, locale]'); // eslint-disable-line no-console + } else { + nf = this.service.nf(nfOrOptions, locale || this.service.getLocale()); + } return nf.format(value); }