strfi 소개: JavaScript 및 TypeScript용 궁극의 문자열 유틸리티 라이브러리
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,swapCaseisUpperCase,isLowerCase,isTitleCase
공백 작업
trim,trimStart,trimEnd,trimChars,trimCharsStart,trimCharsEndcollapseWhitespace,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,isSlugstartsWith,endsWith,contains,containsAll,containsAny,matches,compare,equals,equalsIgnoreCase,isPalindrome,isWhitespace,hasUpperCase,hasLowerCase,hasDigits,hasSpecialChars
인코딩 및 이스케이프
escapeHtml,unescapeHtml,escapeXml,unescapeXml,escapeRegex,escapeSqlLike,escapeShelltoBase64,fromBase64,toBase64Url,fromBase64Url,encodeUrl,decodeUrl,toHex,fromHex,toAsciiCodes,fromAsciiCodes,rot13
검색 및 분석
countOccurrences,countWords,countLines,countSentences,countParagraphscharFrequency,wordFrequency,indicesOf,nthIndexOfextractNumbers,extractWords,extractEmails,extractUrls,extractHashtags,extractMentionslevenshteinDistance,similarity,longestCommonSubstring,longestCommonPrefix,longestCommonSuffix
유니코드 및 국제화
normalize,removeDiacritics,toCodePoints,fromCodePoints,graphemeLength,toGraphemes,toWordsisLetter,isDigit,isSpace,isPunctuation,isRTL,isLTR,getDirectionformatNumber,formatDate,formatCurrency,formatRelativeTime,pluralize,collategetLocaleDisplayName,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!