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

@intlify/utils

v0.13.0

Published

Collection of i18n utilities

Downloads

683,267

Readme

@intilfy/utils

npm version npm downloads CI

Collection of i18n utilities

🌟 Features

✅️  Modern: ES Modules first and respect Web Standard and ECMAScript Internationalization APIs

✅️  Compatible: support CommonJS and various JS environments

✅️️  Minimal: Small and fully tree-shakable

✅️️  Type Strong: Written in TypeScript, with full JSdoc

💿 Installation

🐢 Node.js

# Using npm
npm install @intlify/utils

# Using yarn
yarn add @intlify/utils

# Using pnpm
pnpm add @intlify/utils

If you are directly using @intlify/utils as a dependency:

{
  "dependencies": {
    "@intlify/utils": "npm:@intlify/utils-edge@latest"
  }
}

Note: Make sure to recreate lockfile and node_modules after reinstall to avoid hoisting issues.

🦕 Deno

You can install via import.

in your code:

/**
 * you can install via other CDN URL such as skypack,
 * or, you can also use import maps
 * https://docs.deno.com/runtime/manual/basics/import_maps
 */
import { ... } from 'https://deno.land/x/intlify_utils/mod.ts'

// something todo
// ...

🥟 Bun

bun install @intlify/utils

🌍 Browser

in your HTML:

<script type="module">
/**
 * you can install via other CDN URL such as skypack,
 * or, you can also use import maps
 */
import { isLocale } from 'https://esm.sh/@intlify/utils'

// something todo
// ...
</script>
import { isLocale } from 'https://esm.sh/@intlify/utils-edge'

// something todo
// ...

🍭 Playground

You can play the below examples:

  • 🐢 Node.js: npm run play:node
  • 🦕 Deno: npm run play:deno
  • 🥟 Bun: npm run play:bun
  • 🌍 Browser: npm run play:browser

🔨 Utilities

Common

  • isLocale
  • toLocale
  • parseAcceptLanguage
  • validateLangTag
  • normalizeLanguageName

You can do import { ... } from '@intlify/utils' the above utilities

Navigator

  • getNavigatorLocales
  • getNavigatorLocale

You can do import { ... } from '@intlify/utils' the above utilities

[!NOTE] for Node.js You need to do import { ... } from '@intlify/utils/node'

HTTP

  • getHeaderLanguages
  • getHeaderLanguage
  • getHeaderLocales
  • getHeaderLocale
  • getCookieLocale
  • setCookieLocale
  • getPathLocale
  • getQueryLocale
  • tryHeaderLocales
  • tryHeaderLocale
  • tryCookieLocale
  • tryPathLocale
  • tryQueryLocale

The about utilies functions accpet Web APIs such as Request and Response that is supported by JS environments (such as Deno, Bun, and Browser)

Specialized environments

If you will use Node.js and H3, You can do import { ... } from '@intlify/utils/{ENV}' the above utilities.

The namespace {ENV} is one of the following:

  • node: accpet IncomingMessage and Outgoing by Node.js http module
  • h3: accept H3Event by HTTP framework h3
  • hono: accept Context by edge-side web framework hono

🙌 Contributing guidelines

If you are interested in contributing to @intlify/utils, I highly recommend checking out the contributing guidelines here. You'll find all the relevant information such as how to make a PR, how to setup development) etc., there.

©️ License

MIT