How to use the intl-relativeformat.__localeData__ function in intl-relativeformat

To help you get started, we’ve selected a few intl-relativeformat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github formatjs / react-intl / test / unit / locale-data-registry.js View on Github external
const emptyLocaleData = () => {
        const emptyObject = (obj) => {
            Object.keys(obj).forEach((prop) => delete obj[prop]);
        };

        emptyObject(IntlRelativeFormat.__localeData__);
    };
github formatjs / react-intl / test / unit / locale-data-registry.js View on Github external
const restoreLocaleData = () => {
        emptyLocaleData();
        Object.assign(IntlRelativeFormat.__localeData__, IRF_LOCALE_DATA);
    };
github formatjs / react-intl / test / unit / locale-data-registry.js View on Github external
describe('locale data registry', () => {
    const IRF_LOCALE_DATA = {...IntlRelativeFormat.__localeData__};

    const emptyLocaleData = () => {
        const emptyObject = (obj) => {
            Object.keys(obj).forEach((prop) => delete obj[prop]);
        };

        emptyObject(IntlRelativeFormat.__localeData__);
    };

    const restoreLocaleData = () => {
        emptyLocaleData();
        Object.assign(IntlRelativeFormat.__localeData__, IRF_LOCALE_DATA);
    };

    afterEach(() => {
        restoreLocaleData();
github formatjs / react-intl / src / locale-data-registry.js View on Github external
function hasIMFAndIRFLocaleData(locale) {
  let normalizedLocale = locale && locale.toLowerCase();

  return !!IntlRelativeFormat.__localeData__[normalizedLocale];
}

intl-relativeformat

Formats JavaScript dates to relative time strings.

BSD-3-Clause
Latest version published 5 years ago

Package Health Score

70 / 100
Full package analysis