strfi 소개: JavaScript 및 TypeScript용 궁극의 문자열 유틸리티 라이브러리

발행: (2026년 1월 4일 오후 05:40 GMT+9)
3 min read
원문: Dev.to

Source: Dev.to

Source:

Introduction

Hey dev.to community! 👋

I’m thrilled to announce strfi – a comprehensive, zero‑dependency, tree‑shakeable collection of over 150 pure string utilities for modern JavaScript and TypeScript projects.

If you’re tired of pulling in heavy libraries for simple string tasks like slugifying text, escaping HTML, calculating edit distance, or formatting bytes, strfi is here to be your lightweight yet powerful string toolkit.

  • Zero runtime dependencies
  • Fully tree‑shakeable – import only the functions you need
  • Excellent TypeScript support with precise types
  • Unicode‑aware and locale‑sensitive where applicable
  • No unsafe practices (no eval(), etc.)
  • Tiny minified bundle: ~22 KB
  • Works everywhere: Node.js 16+, modern browsers, Deno, Bun, React Native, Cloudflare Workers

설치

npm install strfi

또는 Yarn / pnpm을 사용하려면:

yarn add strfi
# or
pnpm add strfi

사용 예시

import {
  slugify,
  escapeHtml,
  capitalize,
  levenshteinDistance,
  formatBytes,
  camelCase,
  truncate,
  isEmail,
} from 'strfi';

console.log(slugify('Hello World! 🚀'));                     // "hello-world"
console.log(escapeHtml('alert("xss")'));                     // "<script>alert("xss")</script>"
console.log(capitalize('javascript'));                     // "Javascript"
console.log(levenshteinDistance('kitten', 'sitting'));     // 3
console.log(formatBytes(1500000));                         // "1.43 MB"
console.log(camelCase('foo-bar_baz'));                     // "fooBarBaz"
console.log(truncate('Very long text here', { length: 10 })); // "Very lo..."
console.log(isEmail('test@example.com'));                  // true

모든 기능 – 카테고리별 그룹

대소문자 변환

  • toUpperCase, toLowerCase, capitalize, uncapitalize, titleCase, camelCase, pascalCase, snakeCase, kebabCase, constantCase, dotCase, pathCase, sentenceCase, swapCase
  • isUpperCase, isLowerCase, isTitleCase

공백 작업

  • trim, trimStart, trimEnd, trimChars, trimCharsStart, trimCharsEnd
  • collapseWhitespace, removeWhitespace, padStart, padEnd, center, repeat, insert, removeAt, indent, dedent

문자열 조작

  • reverse, truncate, truncateMiddle, wordWrap, slugify, between, betweenAll, remove, replaceFirst, replaceLast, replaceAll, mask, shuffle, chunk, splitBy, join, stripTags, normalizeLineEndings, surround, ensurePrefix, ensureSuffix, removePrefix, removeSuffix, lines, first, last

문자열 검증

  • isBlank, isNotBlank, isEmpty, isNotEmpty, isAlpha, isAlphanumeric, isNumeric, isInteger, isDecimal, isAscii, isPrintableAscii, isHexadecimal, isUUID, isEmail, isURL, isJSON, isIPv4, isIPv6, isCreditCard, isSlug
  • startsWith, endsWith, contains, containsAll, containsAny, matches, compare, equals, equalsIgnoreCase, isPalindrome, isWhitespace, hasUpperCase, hasLowerCase, hasDigits, hasSpecialChars

인코딩 및 이스케이프

  • escapeHtml, unescapeHtml, escapeXml, unescapeXml, escapeRegex, escapeSqlLike, escapeShell
  • toBase64, fromBase64, toBase64Url, fromBase64Url, encodeUrl, decodeUrl, toHex, fromHex, toAsciiCodes, fromAsciiCodes, rot13

검색 및 분석

  • countOccurrences, countWords, countLines, countSentences, countParagraphs
  • charFrequency, wordFrequency, indicesOf, nthIndexOf
  • extractNumbers, extractWords, extractEmails, extractUrls, extractHashtags, extractMentions
  • levenshteinDistance, similarity, longestCommonSubstring, longestCommonPrefix, longestCommonSuffix

유니코드 및 국제화

  • normalize, removeDiacritics, toCodePoints, fromCodePoints, graphemeLength, toGraphemes, toWords
  • isLetter, isDigit, isSpace, isPunctuation, isRTL, isLTR, getDirection
  • formatNumber, formatDate, formatCurrency, formatRelativeTime, pluralize, collate
  • getLocaleDisplayName, getRegionDisplayName

포맷팅 및 유틸리티

  • template, format, formatNamed, sprintf, zeroPad, formatThousands, formatBytes, formatDuration, ordinal, loremIpsum, randomString, uuid, hashCode

What’s Next?

  • npm: (패키지 링크)
  • GitHub: (저장소 링크)

If you give strfi a try, let me know in the comments – what’s your favorite utility? Any missing feature you’d love to see?

Stars, feedback, and shares are hugely appreciated. Thank you! 🚀

Happy coding!

Back to Blog

관련 글

더 보기 »

Angular 팁 #4

소개: Angular 작업을 위한 몇 가지 팁 – 프론트엔드 개발자 관점에서 Part 4. 이 팁들은 이미 Angular 경험이 있다고 가정하므로, 우리는 …