@ddunigma/node 2.0.0 → 2.0.2

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.
@@ -1,27 +1,116 @@
1
1
  import { BaseDdu } from "../base/BaseDdu";
2
2
  import { DduConstructorOptions, DduOptions } from "../types";
3
+ /**
4
+ * 커스텀 charset을 사용하는 Base64 스타일 인코더
5
+ *
6
+ * @description
7
+ * 바이너리 데이터를 지정된 charset으로 인코딩/디코딩합니다.
8
+ * 2의 제곱수 charset과 가변 길이 charset 모두 지원하며,
9
+ * 압축 옵션을 통해 데이터 크기를 줄일 수 있습니다.
10
+ *
11
+ * @example
12
+ * // 기본 사용
13
+ * const encoder = new Ddu64("우따야", "뭐");
14
+ * const encoded = encoder.encode("Hello");
15
+ * const decoded = encoder.decode(encoded);
16
+ *
17
+ * @example
18
+ * // 압축 사용
19
+ * const encoder = new Ddu64(undefined, undefined, { compress: true });
20
+ * const encoded = encoder.encode(longText);
21
+ */
3
22
  export declare class Ddu64 extends BaseDdu {
23
+ /** 인코딩에 사용할 문자 배열 */
4
24
  protected readonly dduChar: string[];
25
+ /** 패딩 문자 */
5
26
  protected readonly paddingChar: string;
27
+ /** 각 charset 문자의 길이 */
6
28
  protected readonly charLength: number;
29
+ /** 비트 길이 (log2) */
7
30
  protected readonly bitLength: number;
31
+ /** 2의 제곱수 charset 여부 */
8
32
  protected readonly usePowerOfTwo: boolean;
33
+ /** 문자열 인코딩 방식 */
9
34
  protected readonly encoding: BufferEncoding;
35
+ /** 기본 압축 사용 여부 */
36
+ protected readonly defaultCompress: boolean;
37
+ /** 기본 최대 디코딩 바이트 수 */
38
+ private readonly defaultMaxDecodedBytes;
39
+ /** 기본 최대 압축해제 바이트 수 */
40
+ private readonly defaultMaxDecompressedBytes;
41
+ /** 문자 → 인덱스 역방향 룩업 맵 */
10
42
  protected readonly dduBinaryLookup: Map<string, number>;
43
+ /** 미리 정의된 charset 사용 여부 */
11
44
  private readonly isPredefinedCharSet;
45
+ /** 실제 사용되는 비트 길이 */
12
46
  private readonly effectiveBitLength;
47
+ /** 최대 바이너리 값 */
13
48
  private readonly maxBinaryValue;
49
+ /** ASCII 문자 빠른 룩업 테이블 */
50
+ private readonly fastAsciiLookup;
51
+ /** ASCII 룩업 사용 여부 */
52
+ private readonly useAsciiLookup;
53
+ /**
54
+ * Ddu64 인코더 인스턴스를 생성합니다.
55
+ *
56
+ * @param dduChar - charset 문자열 또는 배열 (미지정 시 옵션의 dduSetSymbol 사용)
57
+ * @param paddingChar - 패딩 문자 (dduChar 지정 시 필수)
58
+ * @param dduOptions - 생성자 옵션
59
+ *
60
+ * @throws dduChar 지정 시 paddingChar가 없으면 에러
61
+ * @throws charset 문자 수가 부족하면 에러
62
+ *
63
+ * @example
64
+ * // 커스텀 charset
65
+ * new Ddu64("우따야", "뭐");
66
+ *
67
+ * @example
68
+ * // 미리 정의된 charset
69
+ * new Ddu64(undefined, undefined, { dduSetSymbol: DduSetSymbol.ONECHARSET });
70
+ */
14
71
  constructor(dduChar?: string[] | string, paddingChar?: string, dduOptions?: DduConstructorOptions);
15
72
  /**
16
- * 데이터를 DDU 포맷으로 인코딩합니다.
17
- * 성능을 위해 24비트 이하는 Fast Path(number 연산)를 사용합니다.
73
+ * 입력 데이터를 인코딩합니다.
74
+ *
75
+ * @param input - 인코딩할 문자열 또는 Buffer
76
+ * @param options - 인코딩 옵션
77
+ * @param options.compress - 압축 사용 여부 (기본값: 생성자 설정)
78
+ * @returns 인코딩된 문자열
79
+ *
80
+ * @example
81
+ * encoder.encode("Hello World!");
82
+ * encoder.encode(buffer, { compress: true });
18
83
  */
19
- encode(input: Buffer | string, _options?: DduOptions): string;
84
+ encode(input: Buffer | string, options?: DduOptions): string;
20
85
  /**
21
- * DDU 포맷 문자열을 버퍼로 디코딩합니다.
86
+ * 인코딩된 문자열을 Buffer로 디코딩합니다.
87
+ *
88
+ * @param input - 디코딩할 인코딩된 문자열
89
+ * @param options - 디코딩 옵션
90
+ * @param options.maxDecodedBytes - 최대 디코딩 바이트 수
91
+ * @param options.maxDecompressedBytes - 최대 압축해제 바이트 수
92
+ * @returns 디코딩된 Buffer
93
+ *
94
+ * @throws 잘못된 문자가 포함된 경우
95
+ * @throws 패딩 형식이 잘못된 경우
96
+ * @throws 크기 제한 초과 시
97
+ */
98
+ decodeToBuffer(input: string, options?: DduOptions): Buffer;
99
+ /**
100
+ * 인코딩된 문자열을 원본 문자열로 디코딩합니다.
101
+ *
102
+ * @param input - 디코딩할 인코딩된 문자열
103
+ * @param options - 디코딩 옵션
104
+ * @returns 디코딩된 문자열
105
+ *
106
+ * @throws 잘못된 문자나 패딩 형식일 경우 에러
107
+ */
108
+ decode(input: string, options?: DduOptions): string;
109
+ /**
110
+ * 현재 인코더의 charset 정보를 반환합니다.
111
+ *
112
+ * @returns charset 설정 정보 객체
22
113
  */
23
- decodeToBuffer(input: string, _options?: DduOptions): Buffer;
24
- decode(input: string, _options?: DduOptions): string;
25
114
  getCharSetInfo(): {
26
115
  charSet: string[];
27
116
  paddingChar: string;
@@ -29,20 +118,68 @@ export declare class Ddu64 extends BaseDdu {
29
118
  bitLength: number;
30
119
  usePowerOfTwo: boolean;
31
120
  encoding: BufferEncoding;
121
+ defaultCompress: boolean;
122
+ defaultMaxDecodedBytes: number;
123
+ defaultMaxDecompressedBytes: number;
32
124
  };
125
+ /**
126
+ * 옵션 값을 정규화합니다.
127
+ */
128
+ private normalizeLimit;
129
+ /**
130
+ * 디코딩 결과 바이트 수를 추정합니다.
131
+ */
132
+ private estimateDecodedBytes;
133
+ /**
134
+ * 인코딩된 입력의 정렬을 검증합니다.
135
+ */
136
+ private assertEncodedInputAligned;
137
+ /**
138
+ * 크기 제한을 적용하여 압축을 해제합니다.
139
+ */
140
+ private inflateWithLimit;
141
+ /**
142
+ * 인코딩된 문자열의 푸터(패딩 정보)를 파싱합니다.
143
+ */
144
+ private parseFooter;
145
+ /**
146
+ * 일반 정수 연산을 사용한 빠른 인코딩
147
+ */
33
148
  private encodeFast;
149
+ /**
150
+ * 일반 정수 연산을 사용한 빠른 디코딩
151
+ */
34
152
  private decodeFast;
153
+ /**
154
+ * BigInt를 사용한 대형 비트 인코딩
155
+ */
35
156
  private encodeBigInt;
157
+ /**
158
+ * BigInt를 사용한 대형 비트 디코딩
159
+ */
36
160
  private decodeBigInt;
37
- private parsePaddingAndGetInput;
38
161
  /**
39
- * 입력된 CharSet검증하고 정리(Normalization)합니다.
40
- * 문제가 발생하면 옵션에 따라 Error를 던지거나 Fallback CharSet을 반환합니다.
162
+ * Charset정규화합니다.
41
163
  */
42
164
  private normalizeCharSet;
165
+ /**
166
+ * 초기 charset을 결정합니다.
167
+ */
43
168
  private resolveInitialCharSet;
169
+ /**
170
+ * Fallback charset을 반환합니다.
171
+ */
44
172
  private getFallbackCharSet;
173
+ /**
174
+ * 2의 제곱수 사용 여부를 결정합니다.
175
+ */
45
176
  private shouldUsePowerOfTwo;
177
+ /**
178
+ * charset을 가져오거나 에러를 발생시킵니다.
179
+ */
46
180
  private getCharSetOrThrow;
181
+ /**
182
+ * 커스텀 charset의 조합 중복을 검증합니다.
183
+ */
47
184
  private validateCombinationDuplicates;
48
185
  }