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 🙏

© 2025 – Pkg Stats / Ryan Hefner

tokrw

v1.0.0

Published

한국 원화(KRW)를 위한 빠르고 간편한 숫자 포맷팅 유틸리티

Readme

toKRW

한국 원화(KRW)를 위한 빠르고 간편한 숫자 포맷팅 유틸리티 라이브러리입니다.

특징

  • 📦 다양한 포맷: 콤마, 한글 단위, 소수점 단위 등 3가지 표시 모드 지원
  • 🔧 TypeScript 지원: 완전한 타입 정의 포함
  • 📱 범용 호환: CommonJS와 ESM 모두 지원

설치

npm install tokrw
yarn add tokrw
pnpm add tokrw

사용 방법

ESM (ES Modules)

import toKRW from "tokrw";

CommonJS

const toKRW = require("tokrw");

Type

interface FormatOptions {
  /**
   * 표시 모드
   * - 'comma': 콤마만 추가 (예: 20,000,000원)
   * - 'unit': 한글 단위 표시 (예: 2천만원, 1억원, 1억 5천만원)
   * - 'decimal': 소수점 단위 표시 (예: 1.5억원)
   * @default 'comma'
   */
  displayMode?: "comma" | "unit" | "decimal";
}

function toKRW(value: number, options?: FormatOptions): string;

toKRW(value, options?)

숫자를 한국 원화 형식으로 포맷팅합니다.

매개변수

  • value (number): 포맷팅할 숫자
  • options (FormatOptions, 선택): 포맷팅 옵션
    • displayMode ('comma' | 'unit' | 'decimal', 기본값: 'comma'): 표시 모드

반환값

  • string: 포맷팅된 문자열 (예: "20,000,000원")

예제

기본 모드 (콤마)

toKRW(1000); // '1,000원'
toKRW(20000000); // '20,000,000원'
toKRW(100000000); // '100,000,000원'
toKRW(150000000); // '150,000,000원'

한글 단위 모드

toKRW(20000000, { displayMode: "unit" }); // '2천만원'
toKRW(100000000, { displayMode: "unit" }); // '1억원'
toKRW(150000000, { displayMode: "unit" }); // '1억 5천만원'
toKRW(123456789, { displayMode: "unit" }); // '1억 2천만 345만 6천 789원'

소수점 단위 모드

toKRW(150000000, { displayMode: "decimal" }); // '1.5억원'
toKRW(25000000, { displayMode: "decimal" }); // '2.5천만원'
toKRW(15000, { displayMode: "decimal" }); // '1.5만원'
toKRW(1500, { displayMode: "decimal" }); // '1.5천원'

엣지 케이스

toKRW(0); // '0원'
toKRW(1); // '1원'
toKRW(-1000); // '-1,000원'
toKRW(-20000000, { displayMode: "unit" }); // '-2천만원'
toKRW(-150000000, { displayMode: "decimal" }); // '-1.5억원'

표시 모드 상세

comma (기본값)

숫자에 콤마만 추가합니다. 가장 일반적인 형식입니다.

toKRW(20000000); // '20,000,000원'

unit

한글 단위(억, 천만, 만, 천)를 사용하여 표시합니다.

toKRW(20000000, { displayMode: "unit" }); // '2천만원'
toKRW(100000000, { displayMode: "unit" }); // '1억원'
toKRW(150000000, { displayMode: "unit" }); // '1억 5천만원'

decimal

소수점을 사용하여 단위를 표시합니다. 소수점 첫째 자리까지만 표시됩니다.

toKRW(150000000, { displayMode: "decimal" }); // '1.5억원'
toKRW(123456789, { displayMode: "decimal" }); // '1.2억원' (반올림)

개발

빌드

npm run build

테스트

npm test

테스트 감시 모드

npm run test:watch

커버리지 리포트

npm run test:coverage

라이선스

ISC

기여

이슈와 풀 리퀘스트를 환영합니다! 프로젝트를 개선하기 위한 모든 기여에 감사드립니다.

버그 리포트

버그를 발견하셨나요? 이슈를 생성해주세요.