JSPM

khmernumber

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q42044F
  • License MIT

Khmer number conversion functions

Package Exports

  • khmernumber
  • khmernumber/index.js
  • khmernumber/index.mjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (khmernumber) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Khmer Number

The smallest (0.25kB) and fastest Khmer number conversion functions.

Installation

npm install khmernumber

Usage

import { toASCII, toKhmer } from "khmernumber";

Khmer Numerals -> ASCII

const result = toASCII("០១២៣៤៥៦៧៨៩");
// => 0123456789

const result = toASCII("០១២៣៤៥៦៧៨៩abc123");
// => 0123456789abc123

ASCII -> Khmer Numerals

const result = toKhmer("0123456789");
// => ០១២៣៤៥៦៧៨៩

const result2 = toKhmer("0123456789abc");
// => ០១២៣៤៥៦៧៨៩abc

Benchmark

khmernumber: 0.686ms
  toASCII x 2,926,953 ops/sec ±1.87% (91 runs sampled)
  toKhmer x 2,446,022 ops/sec ±1.29% (91 runs sampled)
  String.replace: Khmer -> ASCII x 622,731 ops/sec ±1.32% (88 runs sampled)
  String.replace: ASCII -> Khmer x 816,557 ops/sec ±0.33% (97 runs sampled)

License

MIT