
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
@opendevtools/rescript-intl
Advanced tools
rescript-intl
helps you with date, number and currency formatting in ReScript.
Everything is built on top of Intl which comes built-in with
browsers >= IE11 as well as Node.
npm install @opendevtools/rescript-intl
Add rescript-intl
in bsconfig.json
{
"dependencies": ["@opendevtools/rescript-intl"]
}
let today = Intl.DateTime.make(~locale=Some("sv-SE"), ());
// today: string = "2020-03-18"
with custom date
let date = Js.Date.makeWithYMD(~year=2020., ~month=11., ~date=12., ());
let futureDate = Intl.DateTime.make(~date, ~locale=Some("sv-SE"), ());
// futureDate: string = "2020-12-12"
with date as string
let futureDate = Intl.DateTime.makeFromString(~date="2020-11-12", ~locale=Some("sv-SE"), ());
// futureDate: string = "2020-11-12"
and with some options
let today =
Intl.DateTime.make(
~locale=Some("sv-SE"),
~options=
Options.make(
~year=Some(`numeric),
~weekday=Some(`long),
~day=Some(`twoDigit),
~era=Some(`narrow),
~month=Some(`long),
(),
),
(),
);
// today: string = "onsdag 18 mars 2020 e.Kr".
let krona =
Intl.NumberFormat.Currency.make(
~value=1000.,
~currency=Some("SEK"),
~locale=Some("sv-SE"),
(),
);
// krona: string = "1 000,00 kr"
let parsedNumber =
Intl.NumberFormat.Decimal.make(~value=1000., ~locale=Some("sv-SE"), ());
// parsedNumber: string = "1 000,00"
let percent =
Intl.NumberFormat.Percent.make(~value=0.3456., ~locale=Some("sv-SE"), ());
// percent: string = "34,56 %"
Node 13 added full ICU support and there should be no issues with wrong
formatting. If you need to
run a Node version before 13 it only has support for en-US
locale by default. If your code is failing
with wrong formatting you'll need to install full locale support using:
npm install -g full-icu
The installer will print out what you need to set the environment variable NODE_ICU_DATA
to in order to get full support.
FAQs
Parse dates and numbers using the Intl API in ReScript
The npm package @opendevtools/rescript-intl receives a total of 10 weekly downloads. As such, @opendevtools/rescript-intl popularity was classified as not popular.
We found that @opendevtools/rescript-intl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.