toss / es-hangul

A modern JavaScript library for handling Hangul characters.
https://es-hangul.slash.page/
MIT License
1.26k stars 85 forks source link

feat: 한글 문자열에 대한 검증, assert, parsing 함수를 구현합니다. #136

Closed sa02045 closed 2 months ago

sa02045 commented 2 months ago

Overview

106 이슈에서 제안한 "한글 문자열"만을 다루기 위한 내부 함수를 구현합니다.

한글 문자열임을 보장하기 위해 상황에 따라 검증, assert, parsing 기능을 제공합니다.

** "한글 문자열"에 대한 정의는 다른 이슈를 참고해 "공백포함"인 경우를 생각했습니다.

parsing은 유저 입력같이 런타임 데이터를 주로 다루는 함수에서 사용될 것으로 기대합니다.

example)

export function hangulIncludes(x: string, y: string) {
  const parsedHangulX = safeParseHangul(x)  
  const parsedHangulY = safeParseHangul(y)

  if( !(parsedHangulX.success && parsedHangulY.success) ){
     return false
  }

   // 한글 문자열로 파싱 후 disassemble
  const disassembledX = disassembleHangul(parsedHangulX.data);
  const disassembledY = disassembleHangul(parsedHangulY.data);

  // ...
}

PR Checklist

  1. I have read the Contributing Guide
  2. I have written documents and tests, if needed.
changeset-bot[bot] commented 2 months ago

⚠️ No Changeset found

Latest commit: 2d3974e1dc18909f9ceb12e9334f2e4f3f50346c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
es-hangul ❌ Failed (Inspect) Jun 25, 2024 5:56pm
codecov-commenter commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.58%. Comparing base (db94449) to head (2d3974e).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/toss/es-hangul/pull/136/graphs/tree.svg?width=650&height=150&src=pr&token=My9jTW6bSr&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss)](https://app.codecov.io/gh/toss/es-hangul/pull/136?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss) ```diff @@ Coverage Diff @@ ## main #136 +/- ## ========================================== + Coverage 99.56% 99.58% +0.02% ========================================== Files 14 14 Lines 230 242 +12 Branches 51 53 +2 ========================================== + Hits 229 241 +12 Misses 1 1 ```