sheetra 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 +32 -0
- package/dist/index.esm.js +2392 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2419 -0
- package/dist/index.js.map +1 -0
- package/dist/types/builders/export-builder.d.ts +20 -0
- package/dist/types/builders/section-builder.d.ts +142 -0
- package/dist/types/builders/sheet-builder.d.ts +297 -0
- package/dist/types/core/cell.d.ts +16 -0
- package/dist/types/core/column.d.ts +13 -0
- package/dist/types/core/row.d.ts +20 -0
- package/dist/types/core/styles.d.ts +23 -0
- package/dist/types/core/workbook.d.ts +19 -0
- package/dist/types/core/worksheet.d.ts +32 -0
- package/dist/types/formatters/date-formatter.d.ts +7 -0
- package/dist/types/formatters/index.d.ts +3 -0
- package/dist/types/formatters/number-formatter.d.ts +6 -0
- package/dist/types/formatters/string-formatter.d.ts +310 -0
- package/dist/types/index.d.ts +1730 -0
- package/dist/types/types/cell.types.d.ts +288 -0
- package/dist/types/types/export.types.d.ts +303 -0
- package/dist/types/types/index.d.ts +13 -0
- package/dist/types/types/workbook.types.d.ts +500 -0
- package/dist/types/utils/constants.d.ts +10 -0
- package/dist/types/utils/helpers.d.ts +36 -0
- package/dist/types/utils/validators.d.ts +3 -0
- package/dist/types/writers/csv-writer.d.ts +6 -0
- package/dist/types/writers/excel-writer.d.ts +16 -0
- package/dist/types/writers/index.d.ts +4 -0
- package/dist/types/writers/json-writer.d.ts +6 -0
- package/package.json +88 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* String formatting options
|
|
3
|
+
*/
|
|
4
|
+
export interface StringFormatOptions {
|
|
5
|
+
/** Maximum length */
|
|
6
|
+
maxLength?: number;
|
|
7
|
+
/** Truncation indicator */
|
|
8
|
+
truncationIndicator?: string;
|
|
9
|
+
/** Case transformation */
|
|
10
|
+
case?: 'upper' | 'lower' | 'title' | 'sentence' | 'camel' | 'pascal' | 'snake' | 'kebab';
|
|
11
|
+
/** Padding configuration */
|
|
12
|
+
padding?: {
|
|
13
|
+
/** Total width */
|
|
14
|
+
width: number;
|
|
15
|
+
/** Pad character */
|
|
16
|
+
char?: string;
|
|
17
|
+
/** Pad side */
|
|
18
|
+
side?: 'left' | 'right' | 'both';
|
|
19
|
+
};
|
|
20
|
+
/** Trim whitespace */
|
|
21
|
+
trim?: boolean;
|
|
22
|
+
/** Replace patterns */
|
|
23
|
+
replace?: Array<{
|
|
24
|
+
pattern: RegExp | string;
|
|
25
|
+
replacement: string;
|
|
26
|
+
}>;
|
|
27
|
+
/** Prefix to add */
|
|
28
|
+
prefix?: string;
|
|
29
|
+
/** Suffix to add */
|
|
30
|
+
suffix?: string;
|
|
31
|
+
/** Escape special characters */
|
|
32
|
+
escape?: boolean;
|
|
33
|
+
/** Remove accents/diacritics */
|
|
34
|
+
normalize?: boolean;
|
|
35
|
+
/** Format as currency */
|
|
36
|
+
currency?: {
|
|
37
|
+
symbol?: string;
|
|
38
|
+
position?: 'before' | 'after';
|
|
39
|
+
thousandsSeparator?: boolean;
|
|
40
|
+
decimalPlaces?: number;
|
|
41
|
+
};
|
|
42
|
+
/** Format as phone number */
|
|
43
|
+
phone?: {
|
|
44
|
+
format: 'international' | 'national' | 'e164';
|
|
45
|
+
countryCode?: string;
|
|
46
|
+
separator?: string;
|
|
47
|
+
};
|
|
48
|
+
/** Format as credit card */
|
|
49
|
+
creditCard?: {
|
|
50
|
+
mask?: boolean;
|
|
51
|
+
separator?: 'space' | 'dash' | 'none';
|
|
52
|
+
maskChar?: string;
|
|
53
|
+
};
|
|
54
|
+
/** Format as email */
|
|
55
|
+
email?: {
|
|
56
|
+
lowercase?: boolean;
|
|
57
|
+
trim?: boolean;
|
|
58
|
+
};
|
|
59
|
+
/** Format as URL */
|
|
60
|
+
url?: {
|
|
61
|
+
protocol?: boolean;
|
|
62
|
+
www?: boolean;
|
|
63
|
+
lowercase?: boolean;
|
|
64
|
+
};
|
|
65
|
+
/** Format as file path */
|
|
66
|
+
filePath?: {
|
|
67
|
+
separator?: 'forward' | 'backward';
|
|
68
|
+
normalize?: boolean;
|
|
69
|
+
extension?: string;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* String manipulation utilities
|
|
74
|
+
*/
|
|
75
|
+
export declare class StringFormatter {
|
|
76
|
+
/**
|
|
77
|
+
* Format a string with options
|
|
78
|
+
*/
|
|
79
|
+
static format(value: unknown, options?: StringFormatOptions): string;
|
|
80
|
+
/**
|
|
81
|
+
* Transform string case
|
|
82
|
+
*/
|
|
83
|
+
static transformCase(str: string, type: StringFormatOptions['case']): string;
|
|
84
|
+
/**
|
|
85
|
+
* Pad a string to a specific width
|
|
86
|
+
*/
|
|
87
|
+
static pad(str: string, options: NonNullable<StringFormatOptions['padding']>): string;
|
|
88
|
+
/**
|
|
89
|
+
* Truncate string to maximum length
|
|
90
|
+
*/
|
|
91
|
+
static truncate(str: string, maxLength: number, indicator?: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* Escape HTML special characters
|
|
94
|
+
*/
|
|
95
|
+
static escapeHtml(str: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Unescape HTML special characters
|
|
98
|
+
*/
|
|
99
|
+
static unescapeHtml(str: string): string;
|
|
100
|
+
/**
|
|
101
|
+
* Escape regex special characters
|
|
102
|
+
*/
|
|
103
|
+
static escapeRegex(str: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* Escape CSV special characters
|
|
106
|
+
*/
|
|
107
|
+
static escapeCsv(str: string, delimiter?: string): string;
|
|
108
|
+
/**
|
|
109
|
+
* Remove accents/diacritics
|
|
110
|
+
*/
|
|
111
|
+
static normalize(str: string): string;
|
|
112
|
+
/**
|
|
113
|
+
* Reverse a string
|
|
114
|
+
*/
|
|
115
|
+
static reverse(str: string): string;
|
|
116
|
+
/**
|
|
117
|
+
* Check if string contains only ASCII characters
|
|
118
|
+
*/
|
|
119
|
+
static isAscii(str: string): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Convert to ASCII (remove non-ASCII)
|
|
122
|
+
*/
|
|
123
|
+
static toAscii(str: string): string;
|
|
124
|
+
/**
|
|
125
|
+
* Extract numbers from string
|
|
126
|
+
*/
|
|
127
|
+
static extractNumbers(str: string): string;
|
|
128
|
+
/**
|
|
129
|
+
* Extract letters from string
|
|
130
|
+
*/
|
|
131
|
+
static extractLetters(str: string): string;
|
|
132
|
+
/**
|
|
133
|
+
* Extract alphanumeric characters
|
|
134
|
+
*/
|
|
135
|
+
static extractAlphanumeric(str: string): string;
|
|
136
|
+
/**
|
|
137
|
+
* Format as currency
|
|
138
|
+
*/
|
|
139
|
+
static formatAsCurrency(str: string, options: NonNullable<StringFormatOptions['currency']>): string;
|
|
140
|
+
/**
|
|
141
|
+
* Format as phone number
|
|
142
|
+
*/
|
|
143
|
+
static formatAsPhone(str: string, options: NonNullable<StringFormatOptions['phone']>): string;
|
|
144
|
+
/**
|
|
145
|
+
* Format as credit card
|
|
146
|
+
*/
|
|
147
|
+
static formatAsCreditCard(str: string, options: NonNullable<StringFormatOptions['creditCard']>): string;
|
|
148
|
+
/**
|
|
149
|
+
* Format as email
|
|
150
|
+
*/
|
|
151
|
+
static formatAsEmail(str: string, options: NonNullable<StringFormatOptions['email']>): string;
|
|
152
|
+
/**
|
|
153
|
+
* Format as URL
|
|
154
|
+
*/
|
|
155
|
+
static formatAsUrl(str: string, options: NonNullable<StringFormatOptions['url']>): string;
|
|
156
|
+
/**
|
|
157
|
+
* Format as file path
|
|
158
|
+
*/
|
|
159
|
+
static formatAsFilePath(str: string, options: NonNullable<StringFormatOptions['filePath']>): string;
|
|
160
|
+
/**
|
|
161
|
+
* Pluralize a word
|
|
162
|
+
*/
|
|
163
|
+
static pluralize(word: string, count: number, plural?: string): string;
|
|
164
|
+
/**
|
|
165
|
+
* Convert to slug (URL-friendly)
|
|
166
|
+
*/
|
|
167
|
+
static slugify(str: string, separator?: string): string;
|
|
168
|
+
/**
|
|
169
|
+
* Convert to camelCase
|
|
170
|
+
*/
|
|
171
|
+
static camelCase(str: string): string;
|
|
172
|
+
/**
|
|
173
|
+
* Convert to PascalCase
|
|
174
|
+
*/
|
|
175
|
+
static pascalCase(str: string): string;
|
|
176
|
+
/**
|
|
177
|
+
* Convert to snake_case
|
|
178
|
+
*/
|
|
179
|
+
static snakeCase(str: string): string;
|
|
180
|
+
/**
|
|
181
|
+
* Convert to kebab-case
|
|
182
|
+
*/
|
|
183
|
+
static kebabCase(str: string): string;
|
|
184
|
+
/**
|
|
185
|
+
* Capitalize first letter
|
|
186
|
+
*/
|
|
187
|
+
static capitalize(str: string): string;
|
|
188
|
+
/**
|
|
189
|
+
* Capitalize each word
|
|
190
|
+
*/
|
|
191
|
+
static capitalizeWords(str: string): string;
|
|
192
|
+
/**
|
|
193
|
+
* Check if string starts with any of the provided prefixes
|
|
194
|
+
*/
|
|
195
|
+
static startsWithAny(str: string, prefixes: string[]): boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Check if string ends with any of the provided suffixes
|
|
198
|
+
*/
|
|
199
|
+
static endsWithAny(str: string, suffixes: string[]): boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Remove all whitespace
|
|
202
|
+
*/
|
|
203
|
+
static removeWhitespace(str: string): string;
|
|
204
|
+
/**
|
|
205
|
+
* Normalize whitespace (replace multiple spaces with single)
|
|
206
|
+
*/
|
|
207
|
+
static normalizeWhitespace(str: string): string;
|
|
208
|
+
/**
|
|
209
|
+
* Get word count
|
|
210
|
+
*/
|
|
211
|
+
static wordCount(str: string): number;
|
|
212
|
+
/**
|
|
213
|
+
* Get character count (excluding optional spaces)
|
|
214
|
+
*/
|
|
215
|
+
static charCount(str: string, excludeSpaces?: boolean): number;
|
|
216
|
+
/**
|
|
217
|
+
* Mask a string (show only first and last characters)
|
|
218
|
+
*/
|
|
219
|
+
static mask(str: string, visibleStart?: number, visibleEnd?: number, maskChar?: string): string;
|
|
220
|
+
/**
|
|
221
|
+
* Generate random string
|
|
222
|
+
*/
|
|
223
|
+
static random(length: number, charset?: string): string;
|
|
224
|
+
/**
|
|
225
|
+
* Check if string is palindrome
|
|
226
|
+
*/
|
|
227
|
+
static isPalindrome(str: string): boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Levenshtein distance between two strings
|
|
230
|
+
*/
|
|
231
|
+
static levenshteinDistance(a: string, b: string): number;
|
|
232
|
+
/**
|
|
233
|
+
* Calculate similarity percentage between two strings
|
|
234
|
+
*/
|
|
235
|
+
static similarity(a: string, b: string): number;
|
|
236
|
+
/**
|
|
237
|
+
* Highlight matching text
|
|
238
|
+
*/
|
|
239
|
+
static highlight(text: string, search: string, tag?: string): string;
|
|
240
|
+
/**
|
|
241
|
+
* Indent text
|
|
242
|
+
*/
|
|
243
|
+
static indent(str: string, level?: number, char?: string): string;
|
|
244
|
+
/**
|
|
245
|
+
* Wrap text to specified width
|
|
246
|
+
*/
|
|
247
|
+
static wrap(str: string, width: number, indent?: string): string[];
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Template string utilities
|
|
251
|
+
*/
|
|
252
|
+
export declare class TemplateFormatter {
|
|
253
|
+
/**
|
|
254
|
+
* Simple template interpolation
|
|
255
|
+
*/
|
|
256
|
+
static interpolate(template: string, data: Record<string, any>, pattern?: RegExp): string;
|
|
257
|
+
/**
|
|
258
|
+
* Template with conditions
|
|
259
|
+
*/
|
|
260
|
+
static conditional(template: string, data: Record<string, any>): string;
|
|
261
|
+
/**
|
|
262
|
+
* Template with loops
|
|
263
|
+
*/
|
|
264
|
+
static loop(template: string, data: Record<string, any>): string;
|
|
265
|
+
/**
|
|
266
|
+
* Evaluate expression safely
|
|
267
|
+
*/
|
|
268
|
+
private static evaluateExpression;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Byte size formatter
|
|
272
|
+
*/
|
|
273
|
+
export declare class ByteFormatter {
|
|
274
|
+
static readonly UNITS: string[];
|
|
275
|
+
/**
|
|
276
|
+
* Format bytes to human readable string
|
|
277
|
+
*/
|
|
278
|
+
static format(bytes: number, decimals?: number): string;
|
|
279
|
+
/**
|
|
280
|
+
* Parse human readable size to bytes
|
|
281
|
+
*/
|
|
282
|
+
static parse(size: string): number;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Duration formatter
|
|
286
|
+
*/
|
|
287
|
+
export declare class DurationFormatter {
|
|
288
|
+
/**
|
|
289
|
+
* Format milliseconds to human readable duration
|
|
290
|
+
*/
|
|
291
|
+
static format(ms: number, options?: {
|
|
292
|
+
includeMs?: boolean;
|
|
293
|
+
maxUnits?: number;
|
|
294
|
+
separator?: string;
|
|
295
|
+
}): string;
|
|
296
|
+
/**
|
|
297
|
+
* Parse duration string to milliseconds
|
|
298
|
+
*/
|
|
299
|
+
static parse(duration: string): number;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Export all formatters
|
|
303
|
+
*/
|
|
304
|
+
declare const _default: {
|
|
305
|
+
StringFormatter: typeof StringFormatter;
|
|
306
|
+
TemplateFormatter: typeof TemplateFormatter;
|
|
307
|
+
ByteFormatter: typeof ByteFormatter;
|
|
308
|
+
DurationFormatter: typeof DurationFormatter;
|
|
309
|
+
};
|
|
310
|
+
export default _default;
|