Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
18 lines
530 B
Plaintext
18 lines
530 B
Plaintext
import { cache } from 'react';
|
|
import { createFormatter } from 'use-intl/core';
|
|
import getDefaultNow from './getDefaultNow.js';
|
|
|
|
function getFormatterCachedImpl(config) {
|
|
return createFormatter({
|
|
...config,
|
|
// Only init when necessary to avoid triggering a `dynamicIO` error
|
|
// unnecessarily (`now` is only needed for `format.relativeTime`)
|
|
get now() {
|
|
return config.now ?? getDefaultNow();
|
|
}
|
|
});
|
|
}
|
|
const getFormatterCached = cache(getFormatterCachedImpl);
|
|
|
|
export { getFormatterCached as default };
|