unicode-escaper 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +410 -0
- package/dist/index.cjs +756 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +515 -0
- package/dist/index.d.ts +515 -0
- package/dist/index.js +682 -0
- package/dist/index.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/formats.ts","../src/filters.ts","../src/escape.ts","../src/unescape.ts","../src/utils.ts","../src/stream.ts"],"names":["DEFAULT_OPTIONS","isAscii","isLatin1","isBmp","isHighSurrogate","isLowSurrogate","isSurrogate","toHex","Transform"],"mappings":";;;;;AAKA,SAAS,KAAA,CAAM,SAAA,EAAmB,SAAA,EAAmB,SAAA,EAA4B;AAC/E,EAAA,MAAM,GAAA,GAAM,SAAA,CAAU,QAAA,CAAS,EAAE,CAAA;AACjC,EAAA,MAAM,MAAA,GAAS,GAAA,CAAI,QAAA,CAAS,SAAA,EAAW,GAAG,CAAA;AAC1C,EAAA,OAAO,SAAA,GAAY,MAAA,CAAO,WAAA,EAAY,GAAI,OAAO,WAAA,EAAY;AAC/D;AAKA,SAAS,gBAAgB,SAAA,EAAqC;AAC5D,EAAA,MAAM,SAAS,SAAA,GAAY,KAAA;AAC3B,EAAA,MAAM,aAAA,GAAgB,SAAU,MAAA,IAAU,EAAA,CAAA;AAC1C,EAAA,MAAM,YAAA,GAAe,SAAU,MAAA,GAAS,IAAA,CAAA;AACxC,EAAA,OAAO,CAAC,eAAe,YAAY,CAAA;AACrC;AAKO,IAAM,UAAA,GAAsF;AAAA;AAAA;AAAA;AAAA,EAIjG,OAAA,EAAS,CAAC,SAAA,EAAmB,SAAA,KAA+B;AAC1D,IAAA,IAAI,aAAa,KAAA,EAAQ;AACvB,MAAA,OAAO,CAAA,GAAA,EAAM,KAAA,CAAM,SAAA,EAAW,CAAA,EA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AAA,CAAO,MAAA,EAAQ,OAAO,CAAC,CAAA;AAC1C,QAAA,MAAA,GAAS,EAAA;AAAA,MACX;AAAA,IACF,CAAA;AAAA,IACA,MAAM,UAAA,EAAY;AAChB,MAAA,IAAI,MAAA,CAAO,SAAS,CAAA,EAAG;AACrB,QAAA,UAAA,CAAW,OAAA,CAAQ,MAAA,CAAO,MAAA,EAAQ,OAAO,CAAC,CAAA;AAAA,MAC5C;AAAA,IACF;AAAA,GACD,CAAA;AACH;AAKO,SAAS,uBAAA,CAAwB,OAAA,GAA2B,EAAC,EAAoC;AACtG,EAAA,IAAI,MAAA,GAAS,EAAA;AACb,EAAA,MAAM,WAAA,GAAc,EAAA;AAEpB,EAAA,OAAO,IAAI,eAAA,CAAgC;AAAA,IACzC,SAAA,CAAU,OAAO,UAAA,EAAY;AAC3B,MAAA,MAAA,IAAU,KAAA;AAEV,MAAA,IAAI,MAAA,CAAO,SAAS,WAAA,EAAa;AAC/B,QAAA,MAAM,SAAA,GAAY,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,WAAW,CAAA;AAC9C,QAAA,MAAA,GAAS,MAAA,CAAO,KAAA,CAAM,CAAC,WAAW,CAAA;AAClC,QAAA,UAAA,CAAW,OAAA,CAAQ,QAAA,CAAS,SAAA,EAAW,OAAO,CAAC,CAAA;AAAA,MACjD;AAAA,IACF,CAAA;AAAA,IACA,MAAM,UAAA,EAAY;AAChB,MAAA,IAAI,MAAA,CAAO,SAAS,CAAA,EAAG;AACrB,QAAA,UAAA,CAAW,OAAA,CAAQ,QAAA,CAAS,MAAA,EAAQ,OAAO,CAAC,CAAA;AAAA,MAC9C;AAAA,IACF;AAAA,GACD,CAAA;AACH","file":"index.cjs","sourcesContent":["import type { EscapeFormat } from './types.js';\n\n/**\n * Converts a code point to a hex string with specified padding and case\n */\nfunction toHex(codePoint: number, minLength: number, uppercase: boolean): string {\n const hex = codePoint.toString(16);\n const padded = hex.padStart(minLength, '0');\n return uppercase ? padded.toUpperCase() : padded.toLowerCase();\n}\n\n/**\n * Converts a code point to surrogate pair if needed\n */\nfunction toSurrogatePair(codePoint: number): [number, number] {\n const offset = codePoint - 0x10000;\n const highSurrogate = 0xd800 + (offset >> 10);\n const lowSurrogate = 0xdc00 + (offset & 0x3ff);\n return [highSurrogate, lowSurrogate];\n}\n\n/**\n * Format escape functions - convert a code point to its escaped representation\n */\nexport const formatters: Record<EscapeFormat, (codePoint: number, uppercase: boolean) => string> = {\n /**\n * Unicode escape: \\uXXXX for BMP, surrogate pairs for non-BMP\n */\n unicode: (codePoint: number, uppercase: boolean): string => {\n if (codePoint <= 0xffff) {\n return `\\\\u${toHex(codePoint, 4, uppercase)}`;\n }\n // Non-BMP: use surrogate pairs\n const [high, low] = toSurrogatePair(codePoint);\n return `\\\\u${toHex(high, 4, uppercase)}\\\\u${toHex(low, 4, uppercase)}`;\n },\n\n /**\n * ES6 Unicode escape: \\u{XXXXX} - supports full Unicode range\n */\n 'unicode-es6': (codePoint: number, uppercase: boolean): string => {\n return `\\\\u{${toHex(codePoint, 1, uppercase)}}`;\n },\n\n /**\n * Hex escape: \\xNN - only valid for 0x00-0xFF\n */\n hex: (codePoint: number, uppercase: boolean): string => {\n if (codePoint > 0xff) {\n // Fall back to unicode format for characters outside hex range\n return formatters.unicode(codePoint, uppercase);\n }\n return `\\\\x${toHex(codePoint, 2, uppercase)}`;\n },\n\n /**\n * HTML hex entity: &#xNNNN;\n */\n 'html-hex': (codePoint: number, uppercase: boolean): string => {\n return `&#x${toHex(codePoint, 1, uppercase)};`;\n },\n\n /**\n * HTML decimal entity: &#NNNN;\n */\n 'html-decimal': (codePoint: number, _uppercase: boolean): string => {\n return `&#${codePoint};`;\n },\n\n /**\n * Code point notation: U+XXXX\n */\n codepoint: (codePoint: number, uppercase: boolean): string => {\n return `U+${toHex(codePoint, 4, uppercase)}`;\n },\n};\n\n/**\n * Regular expressions to match each escape format\n */\nexport const unescapePatterns: Record<EscapeFormat, RegExp> = {\n // Matches \\uXXXX including surrogate pairs\n unicode: /\\\\u([0-9A-Fa-f]{4})/g,\n\n // Matches \\u{X} to \\u{XXXXXX}\n 'unicode-es6': /\\\\u\\{([0-9A-Fa-f]{1,6})\\}/g,\n\n // Matches \\xNN\n hex: /\\\\x([0-9A-Fa-f]{2})/g,\n\n // Matches &#xNNNN;\n 'html-hex': /&#x([0-9A-Fa-f]+);/gi,\n\n // Matches &#NNNN;\n 'html-decimal': /&#(\\d+);/g,\n\n // Matches U+XXXX\n codepoint: /U\\+([0-9A-Fa-f]{4,6})/gi,\n};\n\n/**\n * Combined pattern that matches all escape formats\n */\nexport const combinedUnescapePattern =\n /\\\\u\\{([0-9A-Fa-f]{1,6})\\}|\\\\u([0-9A-Fa-f]{4})|\\\\x([0-9A-Fa-f]{2})|&#x([0-9A-Fa-f]+);|&#(\\d+);|U\\+([0-9A-Fa-f]{4,6})/gi;\n\n/**\n * Pattern to match surrogate pairs in unicode format\n */\nexport const surrogatePairPattern = /\\\\u([Dd][89AaBb][0-9A-Fa-f]{2})\\\\u([Dd][CcDdEeFf][0-9A-Fa-f]{2})/g;\n\n/**\n * Validates if a code point is valid Unicode\n */\nexport function isValidCodePoint(codePoint: number): boolean {\n return codePoint >= 0 && codePoint <= 0x10ffff;\n}\n\n/**\n * Validates if a code point is a valid surrogate\n */\nexport function isSurrogateCodePoint(codePoint: number): boolean {\n return codePoint >= 0xd800 && codePoint <= 0xdfff;\n}\n\n/**\n * Converts surrogate pair to code point\n */\nexport function surrogateToCodePoint(high: number, low: number): number {\n return ((high - 0xd800) << 10) + (low - 0xdc00) + 0x10000;\n}\n","import type { FilterFunction } from './types.js';\n\n/**\n * ASCII range: 0x00-0x7F\n */\nconst ASCII_MAX = 0x7f;\n\n/**\n * Latin-1 range: 0x00-0xFF\n */\nconst LATIN1_MAX = 0xff;\n\n/**\n * BMP range: 0x0000-0xFFFF\n */\nconst BMP_MAX = 0xffff;\n\n/**\n * Surrogate range\n */\nconst SURROGATE_HIGH_START = 0xd800;\nconst SURROGATE_HIGH_END = 0xdbff;\nconst SURROGATE_LOW_START = 0xdc00;\nconst SURROGATE_LOW_END = 0xdfff;\n\n/**\n * Returns true if the character is in the ASCII range (0x00-0x7F)\n */\nexport const isAscii: FilterFunction = (_char: string, codePoint: number): boolean => {\n return codePoint <= ASCII_MAX;\n};\n\n/**\n * Returns true if the character is NOT in the ASCII range\n */\nexport const isNotAscii: FilterFunction = (_char: string, codePoint: number): boolean => {\n return codePoint > ASCII_MAX;\n};\n\n/**\n * Returns true if the character is in the Latin-1 range (0x00-0xFF)\n */\nexport const isLatin1: FilterFunction = (_char: string, codePoint: number): boolean => {\n return codePoint <= LATIN1_MAX;\n};\n\n/**\n * Returns true if the character is NOT in the Latin-1 range\n */\nexport const isNotLatin1: FilterFunction = (_char: string, codePoint: number): boolean => {\n return codePoint > LATIN1_MAX;\n};\n\n/**\n * Returns true if the character is in the BMP (0x0000-0xFFFF)\n */\nexport const isBmp: FilterFunction = (_char: string, codePoint: number): boolean => {\n return codePoint <= BMP_MAX;\n};\n\n/**\n * Returns true if the character is NOT in the BMP (supplementary planes)\n */\nexport const isNotBmp: FilterFunction = (_char: string, codePoint: number): boolean => {\n return codePoint > BMP_MAX;\n};\n\n/**\n * Returns true if the character is a high surrogate (0xD800-0xDBFF)\n */\nexport const isHighSurrogate: FilterFunction = (_char: string, codePoint: number): boolean => {\n return codePoint >= SURROGATE_HIGH_START && codePoint <= SURROGATE_HIGH_END;\n};\n\n/**\n * Returns true if the character is a low surrogate (0xDC00-0xDFFF)\n */\nexport const isLowSurrogate: FilterFunction = (_char: string, codePoint: number): boolean => {\n return codePoint >= SURROGATE_LOW_START && codePoint <= SURROGATE_LOW_END;\n};\n\n/**\n * Returns true if the character is any surrogate (0xD800-0xDFFF)\n */\nexport const isSurrogate: FilterFunction = (_char: string, codePoint: number): boolean => {\n return codePoint >= SURROGATE_HIGH_START && codePoint <= SURROGATE_LOW_END;\n};\n\n/**\n * Returns true if the character is a printable ASCII character (0x20-0x7E)\n */\nexport const isPrintableAscii: FilterFunction = (_char: string, codePoint: number): boolean => {\n return codePoint >= 0x20 && codePoint <= 0x7e;\n};\n\n/**\n * Returns true if the character is NOT a printable ASCII character\n */\nexport const isNotPrintableAscii: FilterFunction = (_char: string, codePoint: number): boolean => {\n return codePoint < 0x20 || codePoint > 0x7e;\n};\n\n/**\n * Returns true if the character is a control character (0x00-0x1F or 0x7F)\n */\nexport const isControl: FilterFunction = (_char: string, codePoint: number): boolean => {\n return codePoint <= 0x1f || codePoint === 0x7f;\n};\n\n/**\n * Returns true if the character is a whitespace character\n */\nexport const isWhitespace: FilterFunction = (char: string, _codePoint: number): boolean => {\n return /\\s/.test(char);\n};\n\n/**\n * Creates a filter that matches characters within a specific range\n */\nexport function inRange(start: number, end: number): FilterFunction {\n return (_char: string, codePoint: number): boolean => {\n return codePoint >= start && codePoint <= end;\n };\n}\n\n/**\n * Creates a filter that matches characters outside a specific range\n */\nexport function notInRange(start: number, end: number): FilterFunction {\n return (_char: string, codePoint: number): boolean => {\n return codePoint < start || codePoint > end;\n };\n}\n\n/**\n * Creates a filter that matches any of the specified characters\n */\nexport function oneOf(chars: string): FilterFunction {\n const charSet = new Set([...chars]);\n return (char: string, _codePoint: number): boolean => {\n return charSet.has(char);\n };\n}\n\n/**\n * Creates a filter that matches none of the specified characters\n */\nexport function noneOf(chars: string): FilterFunction {\n const charSet = new Set([...chars]);\n return (char: string, _codePoint: number): boolean => {\n return !charSet.has(char);\n };\n}\n\n/**\n * Combines multiple filters with AND logic (all must return true)\n */\nexport function and(...filters: FilterFunction[]): FilterFunction {\n return (char: string, codePoint: number): boolean => {\n return filters.every((filter) => filter(char, codePoint));\n };\n}\n\n/**\n * Combines multiple filters with OR logic (any must return true)\n */\nexport function or(...filters: FilterFunction[]): FilterFunction {\n return (char: string, codePoint: number): boolean => {\n return filters.some((filter) => filter(char, codePoint));\n };\n}\n\n/**\n * Negates a filter\n */\nexport function not(filter: FilterFunction): FilterFunction {\n return (char: string, codePoint: number): boolean => {\n return !filter(char, codePoint);\n };\n}\n\n/**\n * Always returns true (escape all characters)\n */\nexport const all: FilterFunction = (): boolean => true;\n\n/**\n * Always returns false (escape no characters)\n */\nexport const none: FilterFunction = (): boolean => false;\n","import type { EscapeOptions, EscapeResult, FilterFunction } from './types.js';\nimport { formatters } from './formats.js';\nimport { isNotAscii, isNotLatin1 } from './filters.js';\n\n/**\n * Default options for escape function\n */\nconst DEFAULT_OPTIONS: Required<Omit<EscapeOptions, 'filter'>> = {\n format: 'unicode',\n preserveAscii: true,\n preserveLatin1: false,\n uppercase: true,\n};\n\n/**\n * Creates a filter based on preserve options\n */\nfunction createPreserveFilter(options: EscapeOptions): FilterFunction {\n const { preserveAscii = true, preserveLatin1 = false } = options;\n\n if (preserveLatin1) {\n // Escape only non-Latin-1 characters\n return isNotLatin1;\n }\n if (preserveAscii) {\n // Escape only non-ASCII characters\n return isNotAscii;\n }\n // Escape all characters\n return () => true;\n}\n\n/**\n * Escapes Unicode characters in a string according to the specified options\n *\n * @param input - The string to escape\n * @param options - Escape options\n * @returns The escaped string\n *\n * @example\n * ```ts\n * escape('Hello 世界')\n * // => 'Hello \\\\u4E16\\\\u754C'\n *\n * escape('Hello 世界', { format: 'unicode-es6' })\n * // => 'Hello \\\\u{4E16}\\\\u{754C}'\n *\n * escape('Café', { preserveAscii: true })\n * // => 'Caf\\\\u00E9'\n * ```\n */\nexport function escape(input: string, options: EscapeOptions = {}): string {\n if (typeof input !== 'string') {\n throw new TypeError(`Expected string, got ${typeof input}`);\n }\n\n if (input.length === 0) {\n return '';\n }\n\n const format = options.format ?? DEFAULT_OPTIONS.format;\n const uppercase = options.uppercase ?? DEFAULT_OPTIONS.uppercase;\n const formatter = formatters[format];\n\n if (!formatter) {\n throw new Error(`Unknown escape format: ${format}`);\n }\n\n // Determine which filter to use\n const filter = options.filter ?? createPreserveFilter(options);\n\n const result: string[] = [];\n\n // Iterate over code points (handles surrogate pairs correctly)\n for (const char of input) {\n const codePoint = char.codePointAt(0);\n\n if (codePoint === undefined) {\n // Should never happen, but handle gracefully\n result.push(char);\n continue;\n }\n\n if (filter(char, codePoint)) {\n // Escape this character\n result.push(formatter(codePoint, uppercase));\n } else {\n // Preserve this character\n result.push(char);\n }\n }\n\n return result.join('');\n}\n\n/**\n * Escapes Unicode characters and returns detailed information about the operation\n *\n * @param input - The string to escape\n * @param options - Escape options\n * @returns Object containing escaped string and statistics\n */\nexport function escapeWithInfo(input: string, options: EscapeOptions = {}): EscapeResult {\n if (typeof input !== 'string') {\n throw new TypeError(`Expected string, got ${typeof input}`);\n }\n\n if (input.length === 0) {\n return {\n escaped: '',\n escapedCount: 0,\n preservedCount: 0,\n totalCount: 0,\n };\n }\n\n const format = options.format ?? DEFAULT_OPTIONS.format;\n const uppercase = options.uppercase ?? DEFAULT_OPTIONS.uppercase;\n const formatter = formatters[format];\n\n if (!formatter) {\n throw new Error(`Unknown escape format: ${format}`);\n }\n\n const filter = options.filter ?? createPreserveFilter(options);\n\n const result: string[] = [];\n let escapedCount = 0;\n let preservedCount = 0;\n\n for (const char of input) {\n const codePoint = char.codePointAt(0);\n\n if (codePoint === undefined) {\n result.push(char);\n preservedCount++;\n continue;\n }\n\n if (filter(char, codePoint)) {\n result.push(formatter(codePoint, uppercase));\n escapedCount++;\n } else {\n result.push(char);\n preservedCount++;\n }\n }\n\n return {\n escaped: result.join(''),\n escapedCount,\n preservedCount,\n totalCount: escapedCount + preservedCount,\n };\n}\n\n/**\n * Convenience function: escape to \\uXXXX format\n */\nexport function escapeToUnicode(input: string, options: Omit<EscapeOptions, 'format'> = {}): string {\n return escape(input, { ...options, format: 'unicode' });\n}\n\n/**\n * Convenience function: escape to \\u{XXXXX} ES6 format\n */\nexport function escapeToUnicodeES6(input: string, options: Omit<EscapeOptions, 'format'> = {}): string {\n return escape(input, { ...options, format: 'unicode-es6' });\n}\n\n/**\n * Convenience function: escape to \\xNN format (falls back to \\uXXXX for non-Latin1)\n */\nexport function escapeToHex(input: string, options: Omit<EscapeOptions, 'format'> = {}): string {\n return escape(input, { ...options, format: 'hex' });\n}\n\n/**\n * Convenience function: escape to &#xNNNN; HTML hex entity format\n */\nexport function escapeToHtmlHex(input: string, options: Omit<EscapeOptions, 'format'> = {}): string {\n return escape(input, { ...options, format: 'html-hex' });\n}\n\n/**\n * Convenience function: escape to &#NNNN; HTML decimal entity format\n */\nexport function escapeToHtmlDecimal(input: string, options: Omit<EscapeOptions, 'format'> = {}): string {\n return escape(input, { ...options, format: 'html-decimal' });\n}\n\n/**\n * Convenience function: escape to U+XXXX code point format\n */\nexport function escapeToCodePoint(input: string, options: Omit<EscapeOptions, 'format'> = {}): string {\n return escape(input, { ...options, format: 'codepoint' });\n}\n\n/**\n * Escapes all characters in a string (ignores preserve options)\n */\nexport function escapeAll(input: string, options: Omit<EscapeOptions, 'filter' | 'preserveAscii' | 'preserveLatin1'> = {}): string {\n return escape(input, { ...options, filter: () => true });\n}\n\n/**\n * Escapes only non-printable and control characters\n */\nexport function escapeNonPrintable(input: string, options: Omit<EscapeOptions, 'filter'> = {}): string {\n return escape(input, {\n ...options,\n filter: (_char, codePoint) => {\n // Escape control characters and non-printable\n return codePoint < 0x20 || codePoint === 0x7f || codePoint > 0x7e;\n },\n });\n}\n","import type { EscapeFormat, UnescapeOptions } from './types.js';\nimport {\n unescapePatterns,\n combinedUnescapePattern,\n surrogatePairPattern,\n isValidCodePoint,\n isSurrogateCodePoint,\n surrogateToCodePoint,\n} from './formats.js';\n\n/**\n * Default options for unescape function\n */\nconst DEFAULT_OPTIONS: Required<UnescapeOptions> = {\n formats: ['unicode', 'unicode-es6', 'hex', 'html-hex', 'html-decimal', 'codepoint'],\n lenient: true,\n};\n\n/**\n * Converts a hex string to a code point, with validation\n */\nfunction hexToCodePoint(hex: string, lenient: boolean): number | null {\n const codePoint = parseInt(hex, 16);\n\n if (isNaN(codePoint)) {\n if (lenient) return null;\n throw new Error(`Invalid hex value: ${hex}`);\n }\n\n if (!isValidCodePoint(codePoint)) {\n if (lenient) return null;\n throw new Error(`Invalid code point: U+${hex.toUpperCase()}`);\n }\n\n return codePoint;\n}\n\n/**\n * Converts a decimal string to a code point, with validation\n */\nfunction decimalToCodePoint(decimal: string, lenient: boolean): number | null {\n const codePoint = parseInt(decimal, 10);\n\n if (isNaN(codePoint)) {\n if (lenient) return null;\n throw new Error(`Invalid decimal value: ${decimal}`);\n }\n\n if (!isValidCodePoint(codePoint)) {\n if (lenient) return null;\n throw new Error(`Invalid code point: ${codePoint}`);\n }\n\n return codePoint;\n}\n\n/**\n * Safely converts a code point to a character\n */\nfunction codePointToChar(codePoint: number): string {\n return String.fromCodePoint(codePoint);\n}\n\n/**\n * Unescapes Unicode escape sequences in a string\n *\n * @param input - The string containing escape sequences\n * @param options - Unescape options\n * @returns The unescaped string\n *\n * @example\n * ```ts\n * unescape('Hello \\\\u4E16\\\\u754C')\n * // => 'Hello 世界'\n *\n * unescape('Hello \\\\u{4E16}\\\\u{754C}')\n * // => 'Hello 世界'\n *\n * unescape('Café')\n * // => 'Café'\n * ```\n */\nexport function unescape(input: string, options: UnescapeOptions = {}): string {\n if (typeof input !== 'string') {\n throw new TypeError(`Expected string, got ${typeof input}`);\n }\n\n if (input.length === 0) {\n return '';\n }\n\n const lenient = options.lenient ?? DEFAULT_OPTIONS.lenient;\n const formats = options.formats ?? DEFAULT_OPTIONS.formats;\n\n let result = input;\n\n // Handle surrogate pairs first (before individual \\uXXXX patterns)\n if (formats.includes('unicode')) {\n // Create new regex to avoid lastIndex issues with global flag\n const pairPattern = new RegExp(surrogatePairPattern.source, surrogatePairPattern.flags);\n result = result.replace(pairPattern, (match, highHex: string, lowHex: string) => {\n const high = hexToCodePoint(highHex, lenient);\n const low = hexToCodePoint(lowHex, lenient);\n\n if (high === null || low === null) {\n return match;\n }\n\n const codePoint = surrogateToCodePoint(high, low);\n return codePointToChar(codePoint);\n });\n }\n\n // Process each format\n for (const format of formats) {\n const pattern = unescapePatterns[format];\n if (!pattern) continue;\n\n // Create a new RegExp instance to reset lastIndex\n const regex = new RegExp(pattern.source, pattern.flags);\n\n result = result.replace(regex, (match, captured: string) => {\n let codePoint: number | null;\n\n if (format === 'html-decimal') {\n codePoint = decimalToCodePoint(captured, lenient);\n } else {\n codePoint = hexToCodePoint(captured, lenient);\n }\n\n if (codePoint === null) {\n return match;\n }\n\n // Don't convert standalone surrogates\n if (isSurrogateCodePoint(codePoint)) {\n if (lenient) {\n return match;\n }\n throw new Error(`Standalone surrogate not allowed: U+${codePoint.toString(16).toUpperCase()}`);\n }\n\n return codePointToChar(codePoint);\n });\n }\n\n return result;\n}\n\n/**\n * Unescapes only \\uXXXX format (with surrogate pair support)\n */\nexport function unescapeUnicode(input: string, options: Omit<UnescapeOptions, 'formats'> = {}): string {\n return unescape(input, { ...options, formats: ['unicode'] });\n}\n\n/**\n * Unescapes only \\u{XXXXX} ES6 format\n */\nexport function unescapeUnicodeES6(input: string, options: Omit<UnescapeOptions, 'formats'> = {}): string {\n return unescape(input, { ...options, formats: ['unicode-es6'] });\n}\n\n/**\n * Unescapes only \\xNN format\n */\nexport function unescapeHex(input: string, options: Omit<UnescapeOptions, 'formats'> = {}): string {\n return unescape(input, { ...options, formats: ['hex'] });\n}\n\n/**\n * Unescapes only &#xNNNN; HTML hex entity format\n */\nexport function unescapeHtmlHex(input: string, options: Omit<UnescapeOptions, 'formats'> = {}): string {\n return unescape(input, { ...options, formats: ['html-hex'] });\n}\n\n/**\n * Unescapes only &#NNNN; HTML decimal entity format\n */\nexport function unescapeHtmlDecimal(input: string, options: Omit<UnescapeOptions, 'formats'> = {}): string {\n return unescape(input, { ...options, formats: ['html-decimal'] });\n}\n\n/**\n * Unescapes only U+XXXX code point format\n */\nexport function unescapeCodePoint(input: string, options: Omit<UnescapeOptions, 'formats'> = {}): string {\n return unescape(input, { ...options, formats: ['codepoint'] });\n}\n\n/**\n * Unescapes all HTML entities (both hex and decimal)\n */\nexport function unescapeHtml(input: string, options: Omit<UnescapeOptions, 'formats'> = {}): string {\n return unescape(input, { ...options, formats: ['html-hex', 'html-decimal'] });\n}\n\n/**\n * Unescapes all JavaScript escape formats (\\uXXXX, \\u{XXXXX}, \\xNN)\n */\nexport function unescapeJs(input: string, options: Omit<UnescapeOptions, 'formats'> = {}): string {\n return unescape(input, { ...options, formats: ['unicode', 'unicode-es6', 'hex'] });\n}\n\n/**\n * Checks if a string contains any escape sequences\n */\nexport function hasEscapeSequences(input: string, formats?: EscapeFormat[]): boolean {\n if (typeof input !== 'string' || input.length === 0) {\n return false;\n }\n\n if (formats) {\n return formats.some((format) => {\n const pattern = unescapePatterns[format];\n if (!pattern) return false;\n // Create new regex to avoid lastIndex issues with global flag\n return new RegExp(pattern.source, pattern.flags.replace('g', '')).test(input);\n });\n }\n\n // Create new regex without 'g' flag to avoid lastIndex issues\n return new RegExp(combinedUnescapePattern.source, 'i').test(input);\n}\n\n/**\n * Counts the number of escape sequences in a string\n */\nexport function countEscapeSequences(input: string, formats?: EscapeFormat[]): number {\n if (typeof input !== 'string' || input.length === 0) {\n return 0;\n }\n\n let count = 0;\n\n if (formats) {\n for (const format of formats) {\n const pattern = unescapePatterns[format];\n if (!pattern) continue;\n const matches = input.match(new RegExp(pattern.source, pattern.flags));\n count += matches?.length ?? 0;\n }\n } else {\n const matches = input.match(new RegExp(combinedUnescapePattern.source, combinedUnescapePattern.flags));\n count = matches?.length ?? 0;\n }\n\n return count;\n}\n","import type { CharacterInfo } from './types.js';\n\n/**\n * Gets the Unicode code point of a character\n *\n * @param char - The character (can be a surrogate pair)\n * @returns The code point, or undefined if invalid\n */\nexport function getCodePoint(char: string): number | undefined {\n if (typeof char !== 'string' || char.length === 0) {\n return undefined;\n }\n return char.codePointAt(0);\n}\n\n/**\n * Creates a character from a code point\n *\n * @param codePoint - The Unicode code point\n * @returns The character\n * @throws If the code point is invalid\n */\nexport function fromCodePoint(codePoint: number): string {\n if (typeof codePoint !== 'number' || !Number.isInteger(codePoint)) {\n throw new TypeError('Code point must be an integer');\n }\n if (codePoint < 0 || codePoint > 0x10ffff) {\n throw new RangeError(`Invalid code point: ${codePoint}`);\n }\n return String.fromCodePoint(codePoint);\n}\n\n/**\n * Checks if a character is in the ASCII range (0x00-0x7F)\n */\nexport function isAscii(char: string): boolean {\n const codePoint = getCodePoint(char);\n return codePoint !== undefined && codePoint <= 0x7f;\n}\n\n/**\n * Checks if a character is in the Latin-1 range (0x00-0xFF)\n */\nexport function isLatin1(char: string): boolean {\n const codePoint = getCodePoint(char);\n return codePoint !== undefined && codePoint <= 0xff;\n}\n\n/**\n * Checks if a character is in the BMP (0x0000-0xFFFF)\n */\nexport function isBmp(char: string): boolean {\n const codePoint = getCodePoint(char);\n return codePoint !== undefined && codePoint <= 0xffff;\n}\n\n/**\n * Checks if a code point is a high surrogate (0xD800-0xDBFF)\n */\nexport function isHighSurrogate(codePoint: number): boolean {\n return codePoint >= 0xd800 && codePoint <= 0xdbff;\n}\n\n/**\n * Checks if a code point is a low surrogate (0xDC00-0xDFFF)\n */\nexport function isLowSurrogate(codePoint: number): boolean {\n return codePoint >= 0xdc00 && codePoint <= 0xdfff;\n}\n\n/**\n * Checks if a code point is any surrogate (0xD800-0xDFFF)\n */\nexport function isSurrogate(codePoint: number): boolean {\n return codePoint >= 0xd800 && codePoint <= 0xdfff;\n}\n\n/**\n * Gets detailed information about a character\n */\nexport function getCharInfo(char: string): CharacterInfo | undefined {\n const codePoint = getCodePoint(char);\n if (codePoint === undefined) {\n return undefined;\n }\n\n return {\n char,\n codePoint,\n hex: codePoint.toString(16).toUpperCase().padStart(4, '0'),\n isAscii: codePoint <= 0x7f,\n isBmp: codePoint <= 0xffff,\n isLatin1: codePoint <= 0xff,\n isHighSurrogate: codePoint >= 0xd800 && codePoint <= 0xdbff,\n isLowSurrogate: codePoint >= 0xdc00 && codePoint <= 0xdfff,\n utf16Length: char.length,\n };\n}\n\n/**\n * Iterates over characters in a string, yielding code points\n * (handles surrogate pairs correctly)\n */\nexport function* iterateCodePoints(input: string): Generator<{ char: string; codePoint: number; index: number }> {\n let index = 0;\n for (const char of input) {\n const codePoint = char.codePointAt(0);\n if (codePoint !== undefined) {\n yield { char, codePoint, index };\n }\n index++;\n }\n}\n\n/**\n * Converts a string to an array of code points\n */\nexport function toCodePoints(input: string): number[] {\n const codePoints: number[] = [];\n for (const char of input) {\n const codePoint = char.codePointAt(0);\n if (codePoint !== undefined) {\n codePoints.push(codePoint);\n }\n }\n return codePoints;\n}\n\n/**\n * Converts an array of code points to a string\n */\nexport function fromCodePoints(codePoints: number[]): string {\n return String.fromCodePoint(...codePoints);\n}\n\n/**\n * Gets the length of a string in code points (not UTF-16 code units)\n */\nexport function codePointLength(input: string): number {\n return [...input].length;\n}\n\n/**\n * Converts a code point to its hex representation with optional prefix\n */\nexport function toHex(codePoint: number, options: { prefix?: string; minLength?: number; uppercase?: boolean } = {}): string {\n const { prefix = '', minLength = 4, uppercase = true } = options;\n let hex = codePoint.toString(16);\n hex = hex.padStart(minLength, '0');\n hex = uppercase ? hex.toUpperCase() : hex.toLowerCase();\n return prefix + hex;\n}\n\n/**\n * Parses a hex string (with or without prefix) to a code point\n */\nexport function parseHex(hex: string): number | undefined {\n // Remove common prefixes\n const cleaned = hex.replace(/^(0x|U\\+|\\\\u\\{?|&#x)/i, '').replace(/[}\\;]$/, '');\n const codePoint = parseInt(cleaned, 16);\n if (isNaN(codePoint) || codePoint < 0 || codePoint > 0x10ffff) {\n return undefined;\n }\n return codePoint;\n}\n\n/**\n * Validates if a string contains only valid Unicode characters\n * (no unpaired surrogates)\n */\nexport function isValidUnicode(input: string): boolean {\n for (let i = 0; i < input.length; i++) {\n const code = input.charCodeAt(i);\n if (isHighSurrogate(code)) {\n // Must be followed by a low surrogate\n if (i + 1 >= input.length || !isLowSurrogate(input.charCodeAt(i + 1))) {\n return false;\n }\n i++; // Skip the low surrogate\n } else if (isLowSurrogate(code)) {\n // Low surrogate without preceding high surrogate\n return false;\n }\n }\n return true;\n}\n\n/**\n * Normalizes a string to NFC form\n */\nexport function normalizeNFC(input: string): string {\n return input.normalize('NFC');\n}\n\n/**\n * Normalizes a string to NFD form\n */\nexport function normalizeNFD(input: string): string {\n return input.normalize('NFD');\n}\n\n/**\n * Compares two strings for Unicode equivalence\n */\nexport function unicodeEquals(a: string, b: string): boolean {\n return normalizeNFC(a) === normalizeNFC(b);\n}\n","import { Transform, type TransformCallback, type TransformOptions } from 'node:stream';\nimport type { EscapeOptions, UnescapeOptions } from './types.js';\nimport { escape } from './escape.js';\nimport { unescape } from './unescape.js';\n\n/**\n * Options for stream transformers\n */\nexport interface StreamTransformOptions extends TransformOptions {\n escapeOptions?: EscapeOptions;\n unescapeOptions?: UnescapeOptions;\n}\n\n/**\n * Transform stream that escapes Unicode characters\n *\n * @example\n * ```ts\n * import { createReadStream, createWriteStream } from 'fs';\n * import { EscapeStream } from 'unicode-escaper';\n *\n * createReadStream('input.txt')\n * .pipe(new EscapeStream({ escapeOptions: { format: 'unicode-es6' } }))\n * .pipe(createWriteStream('output.txt'));\n * ```\n */\nexport class EscapeStream extends Transform {\n private readonly escapeOptions: EscapeOptions;\n private buffer: string = '';\n\n constructor(options: StreamTransformOptions = {}) {\n const { escapeOptions, ...transformOptions } = options;\n super({\n ...transformOptions,\n decodeStrings: true,\n encoding: 'utf8',\n });\n this.escapeOptions = escapeOptions ?? {};\n }\n\n override _transform(chunk: Buffer | string, _encoding: BufferEncoding, callback: TransformCallback): void {\n try {\n const str = typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n\n // Append to buffer to handle split surrogate pairs\n this.buffer += str;\n\n // Check if the last character might be a high surrogate\n const lastChar = this.buffer.charCodeAt(this.buffer.length - 1);\n const isHighSurrogate = lastChar >= 0xd800 && lastChar <= 0xdbff;\n\n if (isHighSurrogate) {\n // Keep the last character for the next chunk\n const toProcess = this.buffer.slice(0, -1);\n this.buffer = this.buffer.slice(-1);\n\n if (toProcess.length > 0) {\n this.push(escape(toProcess, this.escapeOptions));\n }\n } else {\n // Process the entire buffer\n this.push(escape(this.buffer, this.escapeOptions));\n this.buffer = '';\n }\n\n callback();\n } catch (error) {\n callback(error instanceof Error ? error : new Error(String(error)));\n }\n }\n\n override _flush(callback: TransformCallback): void {\n try {\n if (this.buffer.length > 0) {\n this.push(escape(this.buffer, this.escapeOptions));\n this.buffer = '';\n }\n callback();\n } catch (error) {\n callback(error instanceof Error ? error : new Error(String(error)));\n }\n }\n}\n\n/**\n * Transform stream that unescapes Unicode sequences\n *\n * @example\n * ```ts\n * import { createReadStream, createWriteStream } from 'fs';\n * import { UnescapeStream } from 'unicode-escaper';\n *\n * createReadStream('escaped.txt')\n * .pipe(new UnescapeStream())\n * .pipe(createWriteStream('output.txt'));\n * ```\n */\nexport class UnescapeStream extends Transform {\n private readonly unescapeOptions: UnescapeOptions;\n private buffer: string = '';\n private readonly maxLookback = 24; // Max length of escape sequence (\\uXXXX\\uXXXX = 12) + safety margin\n\n constructor(options: StreamTransformOptions = {}) {\n const { unescapeOptions, ...transformOptions } = options;\n super({\n ...transformOptions,\n decodeStrings: true,\n encoding: 'utf8',\n });\n this.unescapeOptions = unescapeOptions ?? {};\n }\n\n override _transform(chunk: Buffer | string, _encoding: BufferEncoding, callback: TransformCallback): void {\n try {\n const str = typeof chunk === 'string' ? chunk : chunk.toString('utf8');\n this.buffer += str;\n\n // Keep some characters in buffer to handle split escape sequences\n if (this.buffer.length > this.maxLookback) {\n const toProcess = this.buffer.slice(0, -this.maxLookback);\n this.buffer = this.buffer.slice(-this.maxLookback);\n this.push(unescape(toProcess, this.unescapeOptions));\n }\n\n callback();\n } catch (error) {\n callback(error instanceof Error ? error : new Error(String(error)));\n }\n }\n\n override _flush(callback: TransformCallback): void {\n try {\n if (this.buffer.length > 0) {\n this.push(unescape(this.buffer, this.unescapeOptions));\n this.buffer = '';\n }\n callback();\n } catch (error) {\n callback(error instanceof Error ? error : new Error(String(error)));\n }\n }\n}\n\n/**\n * Creates an escape transform stream\n *\n * @param options - Stream and escape options\n * @returns A transform stream that escapes Unicode characters\n */\nexport function createEscapeStream(options: StreamTransformOptions = {}): EscapeStream {\n return new EscapeStream(options);\n}\n\n/**\n * Creates an unescape transform stream\n *\n * @param options - Stream and unescape options\n * @returns A transform stream that unescapes Unicode sequences\n */\nexport function createUnescapeStream(options: StreamTransformOptions = {}): UnescapeStream {\n return new UnescapeStream(options);\n}\n\n/**\n * Web Streams API support (for browsers and modern Node.js)\n */\n\n/**\n * Creates a TransformStream for escaping (Web Streams API)\n *\n * @example\n * ```ts\n * const response = await fetch('data.txt');\n * const escaped = response.body\n * .pipeThrough(new TextDecoderStream())\n * .pipeThrough(createWebEscapeStream())\n * .pipeThrough(new TextEncoderStream());\n * ```\n */\nexport function createWebEscapeStream(options: EscapeOptions = {}): TransformStream<string, string> {\n let buffer = '';\n\n return new TransformStream<string, string>({\n transform(chunk, controller) {\n buffer += chunk;\n\n const lastChar = buffer.charCodeAt(buffer.length - 1);\n const isHighSurrogate = lastChar >= 0xd800 && lastChar <= 0xdbff;\n\n if (isHighSurrogate) {\n const toProcess = buffer.slice(0, -1);\n buffer = buffer.slice(-1);\n\n if (toProcess.length > 0) {\n controller.enqueue(escape(toProcess, options));\n }\n } else {\n controller.enqueue(escape(buffer, options));\n buffer = '';\n }\n },\n flush(controller) {\n if (buffer.length > 0) {\n controller.enqueue(escape(buffer, options));\n }\n },\n });\n}\n\n/**\n * Creates a TransformStream for unescaping (Web Streams API)\n */\nexport function createWebUnescapeStream(options: UnescapeOptions = {}): TransformStream<string, string> {\n let buffer = '';\n const maxLookback = 12;\n\n return new TransformStream<string, string>({\n transform(chunk, controller) {\n buffer += chunk;\n\n if (buffer.length > maxLookback) {\n const toProcess = buffer.slice(0, -maxLookback);\n buffer = buffer.slice(-maxLookback);\n controller.enqueue(unescape(toProcess, options));\n }\n },\n flush(controller) {\n if (buffer.length > 0) {\n controller.enqueue(unescape(buffer, options));\n }\n },\n });\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
import { Transform, TransformOptions, TransformCallback } from 'node:stream';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Supported escape format types
|
|
5
|
+
*/
|
|
6
|
+
type EscapeFormat = 'unicode' | 'unicode-es6' | 'hex' | 'html-hex' | 'html-decimal' | 'codepoint';
|
|
7
|
+
/**
|
|
8
|
+
* Filter function to determine which characters should be escaped
|
|
9
|
+
* @param char - The character to check
|
|
10
|
+
* @param codePoint - The Unicode code point of the character
|
|
11
|
+
* @returns true if the character should be escaped, false otherwise
|
|
12
|
+
*/
|
|
13
|
+
type FilterFunction = (char: string, codePoint: number) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Options for the escape function
|
|
16
|
+
*/
|
|
17
|
+
interface EscapeOptions {
|
|
18
|
+
/**
|
|
19
|
+
* The escape format to use
|
|
20
|
+
* @default 'unicode'
|
|
21
|
+
*/
|
|
22
|
+
format?: EscapeFormat;
|
|
23
|
+
/**
|
|
24
|
+
* Custom filter function to determine which characters to escape.
|
|
25
|
+
* If provided, this takes precedence over preserveAscii and preserveLatin1.
|
|
26
|
+
*/
|
|
27
|
+
filter?: FilterFunction;
|
|
28
|
+
/**
|
|
29
|
+
* If true, ASCII characters (0x00-0x7F) will not be escaped
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
preserveAscii?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* If true, Latin-1 characters (0x00-0xFF) will not be escaped.
|
|
35
|
+
* Only applies when preserveAscii is also true or undefined.
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
preserveLatin1?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* If true, use uppercase hex digits (A-F), otherwise lowercase (a-f)
|
|
41
|
+
* @default true
|
|
42
|
+
*/
|
|
43
|
+
uppercase?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Options for the unescape function
|
|
47
|
+
*/
|
|
48
|
+
interface UnescapeOptions {
|
|
49
|
+
/**
|
|
50
|
+
* Specific formats to unescape. If not provided, all formats are attempted.
|
|
51
|
+
*/
|
|
52
|
+
formats?: EscapeFormat[];
|
|
53
|
+
/**
|
|
54
|
+
* If true, invalid escape sequences will be left as-is instead of throwing
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
lenient?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Information about a Unicode character
|
|
61
|
+
*/
|
|
62
|
+
interface CharacterInfo {
|
|
63
|
+
/** The character itself */
|
|
64
|
+
char: string;
|
|
65
|
+
/** The Unicode code point */
|
|
66
|
+
codePoint: number;
|
|
67
|
+
/** Hexadecimal representation of the code point */
|
|
68
|
+
hex: string;
|
|
69
|
+
/** Whether the character is in the ASCII range (0x00-0x7F) */
|
|
70
|
+
isAscii: boolean;
|
|
71
|
+
/** Whether the character is in the BMP (0x0000-0xFFFF) */
|
|
72
|
+
isBmp: boolean;
|
|
73
|
+
/** Whether the character is in the Latin-1 range (0x00-0xFF) */
|
|
74
|
+
isLatin1: boolean;
|
|
75
|
+
/** Whether the character is a high surrogate (0xD800-0xDBFF) */
|
|
76
|
+
isHighSurrogate: boolean;
|
|
77
|
+
/** Whether the character is a low surrogate (0xDC00-0xDFFF) */
|
|
78
|
+
isLowSurrogate: boolean;
|
|
79
|
+
/** Length in UTF-16 code units */
|
|
80
|
+
utf16Length: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Result of escaping a string with detailed information
|
|
84
|
+
*/
|
|
85
|
+
interface EscapeResult {
|
|
86
|
+
/** The escaped string */
|
|
87
|
+
escaped: string;
|
|
88
|
+
/** Number of characters that were escaped */
|
|
89
|
+
escapedCount: number;
|
|
90
|
+
/** Number of characters that were preserved */
|
|
91
|
+
preservedCount: number;
|
|
92
|
+
/** Total number of characters processed */
|
|
93
|
+
totalCount: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Stream transformer options
|
|
97
|
+
*/
|
|
98
|
+
interface StreamOptions {
|
|
99
|
+
/** Options passed to escape/unescape */
|
|
100
|
+
escapeOptions?: EscapeOptions;
|
|
101
|
+
unescapeOptions?: UnescapeOptions;
|
|
102
|
+
/** High water mark for the stream buffer */
|
|
103
|
+
highWaterMark?: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Escapes Unicode characters in a string according to the specified options
|
|
108
|
+
*
|
|
109
|
+
* @param input - The string to escape
|
|
110
|
+
* @param options - Escape options
|
|
111
|
+
* @returns The escaped string
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* escape('Hello 世界')
|
|
116
|
+
* // => 'Hello \\u4E16\\u754C'
|
|
117
|
+
*
|
|
118
|
+
* escape('Hello 世界', { format: 'unicode-es6' })
|
|
119
|
+
* // => 'Hello \\u{4E16}\\u{754C}'
|
|
120
|
+
*
|
|
121
|
+
* escape('Café', { preserveAscii: true })
|
|
122
|
+
* // => 'Caf\\u00E9'
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
declare function escape(input: string, options?: EscapeOptions): string;
|
|
126
|
+
/**
|
|
127
|
+
* Escapes Unicode characters and returns detailed information about the operation
|
|
128
|
+
*
|
|
129
|
+
* @param input - The string to escape
|
|
130
|
+
* @param options - Escape options
|
|
131
|
+
* @returns Object containing escaped string and statistics
|
|
132
|
+
*/
|
|
133
|
+
declare function escapeWithInfo(input: string, options?: EscapeOptions): EscapeResult;
|
|
134
|
+
/**
|
|
135
|
+
* Convenience function: escape to \uXXXX format
|
|
136
|
+
*/
|
|
137
|
+
declare function escapeToUnicode(input: string, options?: Omit<EscapeOptions, 'format'>): string;
|
|
138
|
+
/**
|
|
139
|
+
* Convenience function: escape to \u{XXXXX} ES6 format
|
|
140
|
+
*/
|
|
141
|
+
declare function escapeToUnicodeES6(input: string, options?: Omit<EscapeOptions, 'format'>): string;
|
|
142
|
+
/**
|
|
143
|
+
* Convenience function: escape to \xNN format (falls back to \uXXXX for non-Latin1)
|
|
144
|
+
*/
|
|
145
|
+
declare function escapeToHex(input: string, options?: Omit<EscapeOptions, 'format'>): string;
|
|
146
|
+
/**
|
|
147
|
+
* Convenience function: escape to &#xNNNN; HTML hex entity format
|
|
148
|
+
*/
|
|
149
|
+
declare function escapeToHtmlHex(input: string, options?: Omit<EscapeOptions, 'format'>): string;
|
|
150
|
+
/**
|
|
151
|
+
* Convenience function: escape to &#NNNN; HTML decimal entity format
|
|
152
|
+
*/
|
|
153
|
+
declare function escapeToHtmlDecimal(input: string, options?: Omit<EscapeOptions, 'format'>): string;
|
|
154
|
+
/**
|
|
155
|
+
* Convenience function: escape to U+XXXX code point format
|
|
156
|
+
*/
|
|
157
|
+
declare function escapeToCodePoint(input: string, options?: Omit<EscapeOptions, 'format'>): string;
|
|
158
|
+
/**
|
|
159
|
+
* Escapes all characters in a string (ignores preserve options)
|
|
160
|
+
*/
|
|
161
|
+
declare function escapeAll(input: string, options?: Omit<EscapeOptions, 'filter' | 'preserveAscii' | 'preserveLatin1'>): string;
|
|
162
|
+
/**
|
|
163
|
+
* Escapes only non-printable and control characters
|
|
164
|
+
*/
|
|
165
|
+
declare function escapeNonPrintable(input: string, options?: Omit<EscapeOptions, 'filter'>): string;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Unescapes Unicode escape sequences in a string
|
|
169
|
+
*
|
|
170
|
+
* @param input - The string containing escape sequences
|
|
171
|
+
* @param options - Unescape options
|
|
172
|
+
* @returns The unescaped string
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* unescape('Hello \\u4E16\\u754C')
|
|
177
|
+
* // => 'Hello 世界'
|
|
178
|
+
*
|
|
179
|
+
* unescape('Hello \\u{4E16}\\u{754C}')
|
|
180
|
+
* // => 'Hello 世界'
|
|
181
|
+
*
|
|
182
|
+
* unescape('Café')
|
|
183
|
+
* // => 'Café'
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
declare function unescape(input: string, options?: UnescapeOptions): string;
|
|
187
|
+
/**
|
|
188
|
+
* Unescapes only \uXXXX format (with surrogate pair support)
|
|
189
|
+
*/
|
|
190
|
+
declare function unescapeUnicode(input: string, options?: Omit<UnescapeOptions, 'formats'>): string;
|
|
191
|
+
/**
|
|
192
|
+
* Unescapes only \u{XXXXX} ES6 format
|
|
193
|
+
*/
|
|
194
|
+
declare function unescapeUnicodeES6(input: string, options?: Omit<UnescapeOptions, 'formats'>): string;
|
|
195
|
+
/**
|
|
196
|
+
* Unescapes only \xNN format
|
|
197
|
+
*/
|
|
198
|
+
declare function unescapeHex(input: string, options?: Omit<UnescapeOptions, 'formats'>): string;
|
|
199
|
+
/**
|
|
200
|
+
* Unescapes only &#xNNNN; HTML hex entity format
|
|
201
|
+
*/
|
|
202
|
+
declare function unescapeHtmlHex(input: string, options?: Omit<UnescapeOptions, 'formats'>): string;
|
|
203
|
+
/**
|
|
204
|
+
* Unescapes only &#NNNN; HTML decimal entity format
|
|
205
|
+
*/
|
|
206
|
+
declare function unescapeHtmlDecimal(input: string, options?: Omit<UnescapeOptions, 'formats'>): string;
|
|
207
|
+
/**
|
|
208
|
+
* Unescapes only U+XXXX code point format
|
|
209
|
+
*/
|
|
210
|
+
declare function unescapeCodePoint(input: string, options?: Omit<UnescapeOptions, 'formats'>): string;
|
|
211
|
+
/**
|
|
212
|
+
* Unescapes all HTML entities (both hex and decimal)
|
|
213
|
+
*/
|
|
214
|
+
declare function unescapeHtml(input: string, options?: Omit<UnescapeOptions, 'formats'>): string;
|
|
215
|
+
/**
|
|
216
|
+
* Unescapes all JavaScript escape formats (\uXXXX, \u{XXXXX}, \xNN)
|
|
217
|
+
*/
|
|
218
|
+
declare function unescapeJs(input: string, options?: Omit<UnescapeOptions, 'formats'>): string;
|
|
219
|
+
/**
|
|
220
|
+
* Checks if a string contains any escape sequences
|
|
221
|
+
*/
|
|
222
|
+
declare function hasEscapeSequences(input: string, formats?: EscapeFormat[]): boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Counts the number of escape sequences in a string
|
|
225
|
+
*/
|
|
226
|
+
declare function countEscapeSequences(input: string, formats?: EscapeFormat[]): number;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Returns true if the character is in the ASCII range (0x00-0x7F)
|
|
230
|
+
*/
|
|
231
|
+
declare const isAscii$1: FilterFunction;
|
|
232
|
+
/**
|
|
233
|
+
* Returns true if the character is NOT in the ASCII range
|
|
234
|
+
*/
|
|
235
|
+
declare const isNotAscii: FilterFunction;
|
|
236
|
+
/**
|
|
237
|
+
* Returns true if the character is in the Latin-1 range (0x00-0xFF)
|
|
238
|
+
*/
|
|
239
|
+
declare const isLatin1$1: FilterFunction;
|
|
240
|
+
/**
|
|
241
|
+
* Returns true if the character is NOT in the Latin-1 range
|
|
242
|
+
*/
|
|
243
|
+
declare const isNotLatin1: FilterFunction;
|
|
244
|
+
/**
|
|
245
|
+
* Returns true if the character is in the BMP (0x0000-0xFFFF)
|
|
246
|
+
*/
|
|
247
|
+
declare const isBmp$1: FilterFunction;
|
|
248
|
+
/**
|
|
249
|
+
* Returns true if the character is NOT in the BMP (supplementary planes)
|
|
250
|
+
*/
|
|
251
|
+
declare const isNotBmp: FilterFunction;
|
|
252
|
+
/**
|
|
253
|
+
* Returns true if the character is a high surrogate (0xD800-0xDBFF)
|
|
254
|
+
*/
|
|
255
|
+
declare const isHighSurrogate$1: FilterFunction;
|
|
256
|
+
/**
|
|
257
|
+
* Returns true if the character is a low surrogate (0xDC00-0xDFFF)
|
|
258
|
+
*/
|
|
259
|
+
declare const isLowSurrogate$1: FilterFunction;
|
|
260
|
+
/**
|
|
261
|
+
* Returns true if the character is any surrogate (0xD800-0xDFFF)
|
|
262
|
+
*/
|
|
263
|
+
declare const isSurrogate$1: FilterFunction;
|
|
264
|
+
/**
|
|
265
|
+
* Returns true if the character is a printable ASCII character (0x20-0x7E)
|
|
266
|
+
*/
|
|
267
|
+
declare const isPrintableAscii: FilterFunction;
|
|
268
|
+
/**
|
|
269
|
+
* Returns true if the character is NOT a printable ASCII character
|
|
270
|
+
*/
|
|
271
|
+
declare const isNotPrintableAscii: FilterFunction;
|
|
272
|
+
/**
|
|
273
|
+
* Returns true if the character is a control character (0x00-0x1F or 0x7F)
|
|
274
|
+
*/
|
|
275
|
+
declare const isControl: FilterFunction;
|
|
276
|
+
/**
|
|
277
|
+
* Returns true if the character is a whitespace character
|
|
278
|
+
*/
|
|
279
|
+
declare const isWhitespace: FilterFunction;
|
|
280
|
+
/**
|
|
281
|
+
* Creates a filter that matches characters within a specific range
|
|
282
|
+
*/
|
|
283
|
+
declare function inRange(start: number, end: number): FilterFunction;
|
|
284
|
+
/**
|
|
285
|
+
* Creates a filter that matches characters outside a specific range
|
|
286
|
+
*/
|
|
287
|
+
declare function notInRange(start: number, end: number): FilterFunction;
|
|
288
|
+
/**
|
|
289
|
+
* Creates a filter that matches any of the specified characters
|
|
290
|
+
*/
|
|
291
|
+
declare function oneOf(chars: string): FilterFunction;
|
|
292
|
+
/**
|
|
293
|
+
* Creates a filter that matches none of the specified characters
|
|
294
|
+
*/
|
|
295
|
+
declare function noneOf(chars: string): FilterFunction;
|
|
296
|
+
/**
|
|
297
|
+
* Combines multiple filters with AND logic (all must return true)
|
|
298
|
+
*/
|
|
299
|
+
declare function and(...filters: FilterFunction[]): FilterFunction;
|
|
300
|
+
/**
|
|
301
|
+
* Combines multiple filters with OR logic (any must return true)
|
|
302
|
+
*/
|
|
303
|
+
declare function or(...filters: FilterFunction[]): FilterFunction;
|
|
304
|
+
/**
|
|
305
|
+
* Negates a filter
|
|
306
|
+
*/
|
|
307
|
+
declare function not(filter: FilterFunction): FilterFunction;
|
|
308
|
+
/**
|
|
309
|
+
* Always returns true (escape all characters)
|
|
310
|
+
*/
|
|
311
|
+
declare const all: FilterFunction;
|
|
312
|
+
/**
|
|
313
|
+
* Always returns false (escape no characters)
|
|
314
|
+
*/
|
|
315
|
+
declare const none: FilterFunction;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Gets the Unicode code point of a character
|
|
319
|
+
*
|
|
320
|
+
* @param char - The character (can be a surrogate pair)
|
|
321
|
+
* @returns The code point, or undefined if invalid
|
|
322
|
+
*/
|
|
323
|
+
declare function getCodePoint(char: string): number | undefined;
|
|
324
|
+
/**
|
|
325
|
+
* Creates a character from a code point
|
|
326
|
+
*
|
|
327
|
+
* @param codePoint - The Unicode code point
|
|
328
|
+
* @returns The character
|
|
329
|
+
* @throws If the code point is invalid
|
|
330
|
+
*/
|
|
331
|
+
declare function fromCodePoint(codePoint: number): string;
|
|
332
|
+
/**
|
|
333
|
+
* Checks if a character is in the ASCII range (0x00-0x7F)
|
|
334
|
+
*/
|
|
335
|
+
declare function isAscii(char: string): boolean;
|
|
336
|
+
/**
|
|
337
|
+
* Checks if a character is in the Latin-1 range (0x00-0xFF)
|
|
338
|
+
*/
|
|
339
|
+
declare function isLatin1(char: string): boolean;
|
|
340
|
+
/**
|
|
341
|
+
* Checks if a character is in the BMP (0x0000-0xFFFF)
|
|
342
|
+
*/
|
|
343
|
+
declare function isBmp(char: string): boolean;
|
|
344
|
+
/**
|
|
345
|
+
* Checks if a code point is a high surrogate (0xD800-0xDBFF)
|
|
346
|
+
*/
|
|
347
|
+
declare function isHighSurrogate(codePoint: number): boolean;
|
|
348
|
+
/**
|
|
349
|
+
* Checks if a code point is a low surrogate (0xDC00-0xDFFF)
|
|
350
|
+
*/
|
|
351
|
+
declare function isLowSurrogate(codePoint: number): boolean;
|
|
352
|
+
/**
|
|
353
|
+
* Checks if a code point is any surrogate (0xD800-0xDFFF)
|
|
354
|
+
*/
|
|
355
|
+
declare function isSurrogate(codePoint: number): boolean;
|
|
356
|
+
/**
|
|
357
|
+
* Gets detailed information about a character
|
|
358
|
+
*/
|
|
359
|
+
declare function getCharInfo(char: string): CharacterInfo | undefined;
|
|
360
|
+
/**
|
|
361
|
+
* Iterates over characters in a string, yielding code points
|
|
362
|
+
* (handles surrogate pairs correctly)
|
|
363
|
+
*/
|
|
364
|
+
declare function iterateCodePoints(input: string): Generator<{
|
|
365
|
+
char: string;
|
|
366
|
+
codePoint: number;
|
|
367
|
+
index: number;
|
|
368
|
+
}>;
|
|
369
|
+
/**
|
|
370
|
+
* Converts a string to an array of code points
|
|
371
|
+
*/
|
|
372
|
+
declare function toCodePoints(input: string): number[];
|
|
373
|
+
/**
|
|
374
|
+
* Converts an array of code points to a string
|
|
375
|
+
*/
|
|
376
|
+
declare function fromCodePoints(codePoints: number[]): string;
|
|
377
|
+
/**
|
|
378
|
+
* Gets the length of a string in code points (not UTF-16 code units)
|
|
379
|
+
*/
|
|
380
|
+
declare function codePointLength(input: string): number;
|
|
381
|
+
/**
|
|
382
|
+
* Converts a code point to its hex representation with optional prefix
|
|
383
|
+
*/
|
|
384
|
+
declare function toHex(codePoint: number, options?: {
|
|
385
|
+
prefix?: string;
|
|
386
|
+
minLength?: number;
|
|
387
|
+
uppercase?: boolean;
|
|
388
|
+
}): string;
|
|
389
|
+
/**
|
|
390
|
+
* Parses a hex string (with or without prefix) to a code point
|
|
391
|
+
*/
|
|
392
|
+
declare function parseHex(hex: string): number | undefined;
|
|
393
|
+
/**
|
|
394
|
+
* Validates if a string contains only valid Unicode characters
|
|
395
|
+
* (no unpaired surrogates)
|
|
396
|
+
*/
|
|
397
|
+
declare function isValidUnicode(input: string): boolean;
|
|
398
|
+
/**
|
|
399
|
+
* Normalizes a string to NFC form
|
|
400
|
+
*/
|
|
401
|
+
declare function normalizeNFC(input: string): string;
|
|
402
|
+
/**
|
|
403
|
+
* Normalizes a string to NFD form
|
|
404
|
+
*/
|
|
405
|
+
declare function normalizeNFD(input: string): string;
|
|
406
|
+
/**
|
|
407
|
+
* Compares two strings for Unicode equivalence
|
|
408
|
+
*/
|
|
409
|
+
declare function unicodeEquals(a: string, b: string): boolean;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Options for stream transformers
|
|
413
|
+
*/
|
|
414
|
+
interface StreamTransformOptions extends TransformOptions {
|
|
415
|
+
escapeOptions?: EscapeOptions;
|
|
416
|
+
unescapeOptions?: UnescapeOptions;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Transform stream that escapes Unicode characters
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* ```ts
|
|
423
|
+
* import { createReadStream, createWriteStream } from 'fs';
|
|
424
|
+
* import { EscapeStream } from 'unicode-escaper';
|
|
425
|
+
*
|
|
426
|
+
* createReadStream('input.txt')
|
|
427
|
+
* .pipe(new EscapeStream({ escapeOptions: { format: 'unicode-es6' } }))
|
|
428
|
+
* .pipe(createWriteStream('output.txt'));
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
431
|
+
declare class EscapeStream extends Transform {
|
|
432
|
+
private readonly escapeOptions;
|
|
433
|
+
private buffer;
|
|
434
|
+
constructor(options?: StreamTransformOptions);
|
|
435
|
+
_transform(chunk: Buffer | string, _encoding: BufferEncoding, callback: TransformCallback): void;
|
|
436
|
+
_flush(callback: TransformCallback): void;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Transform stream that unescapes Unicode sequences
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```ts
|
|
443
|
+
* import { createReadStream, createWriteStream } from 'fs';
|
|
444
|
+
* import { UnescapeStream } from 'unicode-escaper';
|
|
445
|
+
*
|
|
446
|
+
* createReadStream('escaped.txt')
|
|
447
|
+
* .pipe(new UnescapeStream())
|
|
448
|
+
* .pipe(createWriteStream('output.txt'));
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
declare class UnescapeStream extends Transform {
|
|
452
|
+
private readonly unescapeOptions;
|
|
453
|
+
private buffer;
|
|
454
|
+
private readonly maxLookback;
|
|
455
|
+
constructor(options?: StreamTransformOptions);
|
|
456
|
+
_transform(chunk: Buffer | string, _encoding: BufferEncoding, callback: TransformCallback): void;
|
|
457
|
+
_flush(callback: TransformCallback): void;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Creates an escape transform stream
|
|
461
|
+
*
|
|
462
|
+
* @param options - Stream and escape options
|
|
463
|
+
* @returns A transform stream that escapes Unicode characters
|
|
464
|
+
*/
|
|
465
|
+
declare function createEscapeStream(options?: StreamTransformOptions): EscapeStream;
|
|
466
|
+
/**
|
|
467
|
+
* Creates an unescape transform stream
|
|
468
|
+
*
|
|
469
|
+
* @param options - Stream and unescape options
|
|
470
|
+
* @returns A transform stream that unescapes Unicode sequences
|
|
471
|
+
*/
|
|
472
|
+
declare function createUnescapeStream(options?: StreamTransformOptions): UnescapeStream;
|
|
473
|
+
/**
|
|
474
|
+
* Web Streams API support (for browsers and modern Node.js)
|
|
475
|
+
*/
|
|
476
|
+
/**
|
|
477
|
+
* Creates a TransformStream for escaping (Web Streams API)
|
|
478
|
+
*
|
|
479
|
+
* @example
|
|
480
|
+
* ```ts
|
|
481
|
+
* const response = await fetch('data.txt');
|
|
482
|
+
* const escaped = response.body
|
|
483
|
+
* .pipeThrough(new TextDecoderStream())
|
|
484
|
+
* .pipeThrough(createWebEscapeStream())
|
|
485
|
+
* .pipeThrough(new TextEncoderStream());
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
declare function createWebEscapeStream(options?: EscapeOptions): TransformStream<string, string>;
|
|
489
|
+
/**
|
|
490
|
+
* Creates a TransformStream for unescaping (Web Streams API)
|
|
491
|
+
*/
|
|
492
|
+
declare function createWebUnescapeStream(options?: UnescapeOptions): TransformStream<string, string>;
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Format escape functions - convert a code point to its escaped representation
|
|
496
|
+
*/
|
|
497
|
+
declare const formatters: Record<EscapeFormat, (codePoint: number, uppercase: boolean) => string>;
|
|
498
|
+
/**
|
|
499
|
+
* Regular expressions to match each escape format
|
|
500
|
+
*/
|
|
501
|
+
declare const unescapePatterns: Record<EscapeFormat, RegExp>;
|
|
502
|
+
/**
|
|
503
|
+
* Validates if a code point is valid Unicode
|
|
504
|
+
*/
|
|
505
|
+
declare function isValidCodePoint(codePoint: number): boolean;
|
|
506
|
+
/**
|
|
507
|
+
* Validates if a code point is a valid surrogate
|
|
508
|
+
*/
|
|
509
|
+
declare function isSurrogateCodePoint(codePoint: number): boolean;
|
|
510
|
+
/**
|
|
511
|
+
* Converts surrogate pair to code point
|
|
512
|
+
*/
|
|
513
|
+
declare function surrogateToCodePoint(high: number, low: number): number;
|
|
514
|
+
|
|
515
|
+
export { type CharacterInfo, type EscapeFormat, type EscapeOptions, type EscapeResult, EscapeStream, type FilterFunction, type StreamOptions, type StreamTransformOptions, type UnescapeOptions, UnescapeStream, all, and, codePointLength, countEscapeSequences, createEscapeStream, createUnescapeStream, createWebEscapeStream, createWebUnescapeStream, escape, escapeAll, escapeNonPrintable, escapeToCodePoint, escapeToHex, escapeToHtmlDecimal, escapeToHtmlHex, escapeToUnicode, escapeToUnicodeES6, escapeWithInfo, formatters, fromCodePoint, fromCodePoints, getCharInfo, getCodePoint, hasEscapeSequences, inRange, isAscii$1 as isAscii, isAscii as isAsciiChar, isBmp$1 as isBmp, isBmp as isBmpChar, isControl, isHighSurrogate$1 as isHighSurrogate, isHighSurrogate as isHighSurrogateCode, isLatin1$1 as isLatin1, isLatin1 as isLatin1Char, isLowSurrogate$1 as isLowSurrogate, isLowSurrogate as isLowSurrogateCode, isNotAscii, isNotBmp, isNotLatin1, isNotPrintableAscii, isPrintableAscii, isSurrogate$1 as isSurrogate, isSurrogate as isSurrogateCode, isSurrogateCodePoint, isValidCodePoint, isValidUnicode, isWhitespace, iterateCodePoints, none, noneOf, normalizeNFC, normalizeNFD, not, notInRange, oneOf, or, parseHex, surrogateToCodePoint, toCodePoints, toHex, unescape, unescapeCodePoint, unescapeHex, unescapeHtml, unescapeHtmlDecimal, unescapeHtmlHex, unescapeJs, unescapePatterns, unescapeUnicode, unescapeUnicodeES6, unicodeEquals };
|