# @messageformat/number-skeleton

> A parser & formatter for ICU NumberFormat skeleton strings & patterns

Latest version **1.2.0** (published 2023-05-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @messageformat/number-skeleton
pnpm add @messageformat/number-skeleton
yarn add @messageformat/number-skeleton
bun add @messageformat/number-skeleton
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2023-05-27 |
| First published | 2020-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 76.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1770 |
| Maintainers | eemeli |
| Keywords | icu, messageformat, numberformatter, skeleton, parser, formatter |

## Links

- npm: https://www.npmjs.com/package/@messageformat/number-skeleton
- Repository: https://github.com/messageformat/messageformat
- Homepage: http://messageformat.github.io/messageformat/api/number-skeleton/
- Issues: https://github.com/messageformat/messageformat/issues
- npm.io page: https://npm.io/package/@messageformat/number-skeleton

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2023-05-27
- 2.0.0-0 (next) — 2025-03-24
- 1.1.0 — 2022-07-16
- 1.0.0 — 2021-05-13
- 1.0.0-beta.1 — 2020-11-29

## README

# @messageformat/number-skeleton

Tools for working with [ICU NumberFormat skeletons](https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md) and [patterns](http://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns)<!-- -->.

```js
import {
  getNumberFormatter,
  getNumberFormatterSource,
  NumberFormatError,
  parseNumberPattern,
  parseNumberSkeleton,
  Skeleton, // TS only
  Unit // TS only
} from '@messageformat/number-skeleton';
```

The package is released as an ES module only. If using from a CommonJS context, you may need to `import()` it, or use a module loader like [esm](https://www.npmjs.com/package/esm)<!-- -->.

Uses [Intl.NumberFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat) internally, including features provided by the [Unified API Proposal](https://github.com/tc39/proposal-unified-intl-numberformat)<!-- -->.

## Classes

| Class                                                                                                                               | Description                                                                                                                                                                 |
| ----------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [NumberFormatError](https://github.com/messageformat/skeletons/blob/master/docs/messageformat-number-skeleton.numberformaterror.md) | Base class for errors. In addition to a <code>code</code> and a human-friendly <code>message</code>, may also includes the token <code>stem</code> as well as other fields. |

## Functions

| Function                                                                                                                                                                                | Description                                                                                                                                                                                                                                                                                                                        |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [getNumberFormatter(locales, skeleton, currency, onError)](https://github.com/messageformat/skeletons/blob/master/docs/messageformat-number-skeleton.getnumberformatter.md)             | Returns a number formatter function for the given locales and number skeleton                                                                                                                                                                                                                                                      |
| [getNumberFormatterSource(locales, skeleton, currency, onError)](https://github.com/messageformat/skeletons/blob/master/docs/messageformat-number-skeleton.getnumberformattersource.md) | Returns a string of JavaScript source that evaluates to a number formatter function with the same <code>(value: number) =&gt; string</code> signature as the function returned by [getNumberFormatter()](https://github.com/messageformat/skeletons/blob/master/docs/messageformat-number-skeleton.getnumberformatter.md)<!-- -->. |
| [parseNumberPattern(src, currency, onError)](https://github.com/messageformat/skeletons/blob/master/docs/messageformat-number-skeleton.parsenumberpattern.md)                           | Parse an [ICU NumberFormatter pattern](http://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns) string into a [Skeleton](https://github.com/messageformat/skeletons/blob/master/docs/messageformat-number-skeleton.skeleton.md) structure.                                                                        |
| [parseNumberSkeleton(src, onError)](https://github.com/messageformat/skeletons/blob/master/docs/messageformat-number-skeleton.parsenumberskeleton.md)                                   | Parse an [ICU NumberFormatter skeleton](https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md) string into a [Skeleton](https://github.com/messageformat/skeletons/blob/master/docs/messageformat-number-skeleton.skeleton.md) structure.                                                |

## Interfaces

| Interface                                                                                                         | Description                                                                              |
| ----------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| [Skeleton](https://github.com/messageformat/skeletons/blob/master/docs/messageformat-number-skeleton.skeleton.md) | An object representation of a parsed string skeleton, with token values grouped by type. |

## Type Aliases

| Type Alias                                                                                                | Description                                                                                                                |
| --------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| [Unit](https://github.com/messageformat/skeletons/blob/master/docs/messageformat-number-skeleton.unit.md) | Measurement units defined by the [Unicode CLDR](https://github.com/unicode-org/cldr/blob/d4d77a2/common/validity/unit.xml) |

---

[Messageformat] is an OpenJS Foundation project, and we follow its [Code of Conduct].

[messageformat]: https://messageformat.github.io/
[code of conduct]: https://github.com/openjs-foundation/cross-project-council/blob/master/CODE_OF_CONDUCT.md

<a href="https://openjsf.org">
<img width=200 alt="OpenJS Foundation" src="https://messageformat.github.io/messageformat/logo/openjsf.svg" />
</a>

---
_Source: https://npm.io/package/@messageformat/number-skeleton · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
