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 🙏

© 2026 – Pkg Stats / Ryan Hefner

korean-search-utils

v1.0.7

Published

한글 초성 검색 및 React 훅 지원 라이브러리

Readme

# korean-search-utils

React 기반 프로젝트에서 **한글 검색**을 지원하는 유틸리티 함수와 커스텀 훅입니다.

## ✨ 주요 기능

- 한글 자모 분리
- 초성 검색 지원
- React에서 사용할 수 있는 커스텀 훅 제공

## 📦 설치

```bash
npm install korean-search-utils
```

📘 사용법

유틸 함수

import { disassembleHangul, isMatch } from "korean-search-utils";

disassembleHangul("한글 hangul"); // "ㅎㅏㄴㄱㅡㄹ"
isMatch("ㅎㄱ HANGUL", "ㅎㄱHANGUL"); // true
isMatch("한글 hangul", "ㅎㄱhangul"); // true
isMatch("한글", "ㅎㄱ"); // true

React 훅 사용 예시

import { useKoreanSearch } from "korean-search-utils";

const fruits = [
  { name: "사과 apple" },
  { name: "오렌지 orange" },
  { name: "바나나 banana" },
];

function FruitSearch() {
  const {
    searchTerm,
    setSearchTerm,
    filteredItems: filteredGroupCodes,
    resetSearch,
  } = useKoreanSearch(list, (fruit) => fruit.name || "");

  return (
    <div>
      <input
        placeholder="과일 검색"
        value={searchTerm}
        onChange={(e) => setSearchTerm(e.target.value)}
      />
      <ul>
        {filteredItems.map((fruit) => (
          <li key={fruit}>{fruit}</li>
        ))}
      </ul>
    </div>
  );
}

매칭 우선순위

  • 검색어가 더 앞에서 매칭되는 항목을 우선 정렬합니다. 예: 목록에 "한글 외국어""외국어 한글"이 있을 때 ㅎㄱ로 검색하면 한글 외국어가 먼저 노출됩니다.
  • 같은 매칭 시작 위치에서는 원본 문자열 길이가 짧은 항목이 우선됩니다.

간단한 예시:

const list = [
  { name: '한글 외국어' },
  { name: '외국어 한글' },
];

// 'ㅎㄱ' 검색 결과 순서
// 1) '한글 외국어'  (매칭 시작 인덱스 0)
// 2) '외국어 한글'  (매칭 시작 인덱스 > 0)

Hook 타입 시그니처

function useKoreanSearch<T>(
  items: T[],
  getText: (item: T) => string
): {
  searchTerm: string;
  setSearchTerm: React.Dispatch<React.SetStateAction<string>>;
  filteredItems: T[];
};