npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sumup-oss/intl

v3.0.1

Published

Format numbers, currency values, dates, and times for any locale with the ECMAScript Internationalization API

Downloads

4,981

Readme

Intl.js

Coverage License Contributor Covenant

Format 🔢 numbers, 💱 currency values, 📅 dates, and 🕘 times for any locale with the ECMAScript Internationalization API.

Table of contents

Introduction

@sumup-oss/intl is a light abstraction layer on top of the ECMAScript Internationalization API. In addition to a simplified API, it offers the following benefits:

Performance

Creating instances of Intl.* formatters is an expensive operation. @sumup-oss/intl solves this by memoizing the Intl formatters with a cache key based on the arguments passed to the constructor.

Compatibility

@sumup-oss/intl works in modern browsers as well as server runtimes with support for the Intl APIs (such as Node 13+). When the Intl APIs aren't (fully) available, @sumup-oss/intl tries to gracefully degrade. Please refer to the API reference to learn how certain functions behave when the runtime doesn't support the necessary APIs. If you need to support legacy browsers, consider including polyfills.

@sumup-oss/intl integrates temporal-polyfill to support formatting Temporal date-time objects.

Installation

@sumup-oss/intl can be installed as a dependency via the npm package manager. The temporal-polyfill package is a required peer dependency.

npm install @sumup-oss/intl temporal-polyfill

@sumup-oss/intl requires Node v18+.

Usage

The functions exported by @sumup-oss/intl share a similar interface such as the common locales, options, and currency arguments. These are passed on almost unchanged to the Intl.* constructors and thus support the same values. If the locales argument is not provided or is undefined, the runtime's default locale is used. Please refer to the MDN documentation for more details.

Each type of data can be formatted with three increasingly advanced functions:

  1. The format* functions return the formatted value as a string and cover the most common use cases.
  2. The format*ToParts functions return an array of objects representing the value in parts that can be used for custom locale-aware formatting. For example, part of the formatted value could be rendered in bold.
  3. The resolve*Format functions return an object with properties reflecting the locale and collation options computed during initialization of the object. These options can be passed to other functions or libraries to format values, for example react-number-format.

API reference

Number Functions

Currency Functions

Date & Time Functions

Variables

Code of Conduct

We want to foster an inclusive and friendly community around our Open Source efforts. Like all SumUp Open Source projects, this project follows the Contributor Covenant Code of Conduct. Please, read it and follow it.

If you feel another member of the community violated our CoC or you are experiencing problems participating in our community because of another individual's behavior, please get in touch with our maintainers. We will enforce the CoC.

Maintainers

About SumUp

SumUp logo

SumUp is a mobile point-of-sale provider. It is our mission to make easy and fast card payments a reality across the entire world. You can pay with SumUp in more than 30 countries, already. Our engineers work in Berlin, Cologne, Sofia, and Sāo Paulo. They write code in TypeScript, Swift, Ruby, Go, Java, Erlang, Elixir, and more.

Want to come work with us? Head to our careers page to find out more.