Gathering detailed insights and metrics for @formatjs/intl-utils
Gathering detailed insights and metrics for @formatjs/intl-utils
Gathering detailed insights and metrics for @formatjs/intl-utils
Gathering detailed insights and metrics for @formatjs/intl-utils
The monorepo home to all of the FormatJS related libraries, most notably react-intl.
npm install @formatjs/intl-utils
Typescript
Module System
Node Version
NPM Version
eslint-plugin-formatjs@5.4.0
Updated on Jun 15, 2025
@formatjs/cli@6.7.2
Updated on Jun 15, 2025
@formatjs/cli-lib@7.4.2
Updated on Jun 15, 2025
babel-plugin-formatjs@10.5.39
Updated on Jun 15, 2025
@formatjs/utils@1.9.4
Updated on Jun 15, 2025
@formatjs/ts-transformer@3.14.0
Updated on Jun 15, 2025
TypeScript (86.58%)
Starlark (9.96%)
JavaScript (1.51%)
MDX (1.03%)
CSS (0.25%)
HTML (0.24%)
Vue (0.16%)
Shell (0.16%)
Handlebars (0.11%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
14,537 Stars
5,571 Commits
1,373 Forks
130 Watchers
18 Branches
311 Contributors
Updated on Jul 17, 2025
Latest Version
3.8.4
Package Id
@formatjs/intl-utils@3.8.4
Size
19.82 kB
NPM Version
6.12.0
Node Version
12.13.0
Published on
Aug 17, 2020
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
Provide i18n utilities.
This function determines the best fit
unit based on a specific set of customizable thresholds.
1function selectUnit( 2 from: Date | number, 3 to: Date | number = Date.now(), 4 thresholds = DEFAULT_THRESHOLDS 5): {value: number; unit: Unit};
where thresholds
has the shape of:
1interface Threshold { 2 second: number; 3 minute: number; 4 hour: number; 5 day: number; 6}
month
& year
are based on calendar, thus not customizable.
Example:
1import {selectUnit} from '@formatjs/intl-utils'; 2selectUnit(Date.now() - 1000); // { value: -1, unit: 'second' } 3selectUnit(Date.now() - 44000); // { value: -44, unit: 'second' } 4selectUnit(Date.now() - 50000); // { value: 1, unit: 'minute' }
selectUnit
is meant to be a stepping stone from the old IntlRelativeFormat
to the officially spec-ed Intl.RelativeTimeFormat
. Therefore we don't recommend using this for an extended period of time because of ambiguous editorial issues such as:
From 2019/01/01 -> 2018/11/01 can technically be last year
, 2 months ago
or a quarter ago
.
From 2019/01/02 6am to 2019/01/01 11pm can also be 7 hours ago
or yesterday
. Timezone further complicates the issue.
The examples above have not even tackled the differences in non-Gregorian calendars. There is an issue opened upstream in the spec that potentially introduces a best fit
algorithm. Therefore, we recommend that you implement your own version of selectUnit
that matches your editorial expectation. This will be removed in future releases.
No vulnerabilities found.
Reason
30 commit(s) and 13 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
Found 3/24 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
license file not detected
Details
Reason
security policy file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
56 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More