@turndown/library 0.1.16 → 0.1.22

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.
Files changed (60) hide show
  1. package/dist/helpers/date/index.d.ts +113 -0
  2. package/dist/helpers/date/index.js +171 -0
  3. package/dist/helpers/index.d.ts +3 -1
  4. package/dist/helpers/index.js +2 -1
  5. package/dist/helpers/object/index.d.ts +160 -75
  6. package/dist/helpers/object/index.js +355 -168
  7. package/dist/helpers/string/index.d.ts +227 -74
  8. package/dist/helpers/string/index.js +448 -114
  9. package/dist/types/api/index.d.ts +22 -11
  10. package/dist/types/api/index.js +9 -2
  11. package/dist/types/auth/index.d.ts +56 -18
  12. package/dist/types/auth/index.js +7 -0
  13. package/dist/types/auth/routes.d.ts +76 -47
  14. package/dist/types/auth/routes.js +0 -1
  15. package/dist/types/base/index.d.ts +200 -69
  16. package/dist/types/base/index.js +116 -0
  17. package/dist/types/base/paging.types.d.ts +11 -11
  18. package/dist/types/checklist-template/index.d.ts +8 -8
  19. package/dist/types/checklist-template/routes.d.ts +57 -28
  20. package/dist/types/checklist-template/routes.js +0 -1
  21. package/dist/types/company/index.d.ts +5 -5
  22. package/dist/types/company/routes.d.ts +81 -33
  23. package/dist/types/company/routes.js +0 -1
  24. package/dist/types/damage-report/index.d.ts +9 -9
  25. package/dist/types/damage-report/routes.d.ts +128 -51
  26. package/dist/types/damage-report/routes.js +0 -1
  27. package/dist/types/errors/index.d.ts +15 -16
  28. package/dist/types/errors/index.js +17 -7
  29. package/dist/types/health/index.d.ts +20 -0
  30. package/dist/types/health/index.js +1 -0
  31. package/dist/types/health/routes.d.ts +10 -0
  32. package/dist/types/health/routes.js +1 -0
  33. package/dist/types/image/index.d.ts +34 -0
  34. package/dist/types/image/index.js +11 -0
  35. package/dist/types/image/routes.d.ts +32 -0
  36. package/dist/types/image/routes.js +1 -0
  37. package/dist/types/index.d.ts +3 -0
  38. package/dist/types/index.js +3 -0
  39. package/dist/types/inventory/index.d.ts +13 -87
  40. package/dist/types/inventory/routes.d.ts +73 -36
  41. package/dist/types/inventory/routes.js +0 -1
  42. package/dist/types/job/index.d.ts +7 -0
  43. package/dist/types/job/index.js +1 -0
  44. package/dist/types/property/index.d.ts +88 -29
  45. package/dist/types/property/index.js +23 -23
  46. package/dist/types/property/routes.d.ts +40 -14
  47. package/dist/types/property/routes.js +0 -1
  48. package/dist/types/room/index.d.ts +4 -4
  49. package/dist/types/room/routes.d.ts +27 -8
  50. package/dist/types/room/routes.js +0 -1
  51. package/dist/types/room-checklist/index.d.ts +9 -9
  52. package/dist/types/room-checklist/routes.d.ts +50 -28
  53. package/dist/types/room-checklist/routes.js +0 -1
  54. package/dist/types/user/index.d.ts +12 -12
  55. package/dist/types/user/routes.d.ts +26 -16
  56. package/dist/types/user/routes.js +0 -1
  57. package/dist/types/work-session/index.d.ts +12 -12
  58. package/dist/types/work-session/routes.d.ts +55 -34
  59. package/dist/types/work-session/routes.js +0 -1
  60. package/package.json +14 -5
@@ -1,104 +1,257 @@
1
- import { TurndownObject } from "../../index";
2
1
  /**
3
- * Convert a string to "Normal Case":
4
- * - Inserts spaces between camel/pascal case boundaries
5
- * - Capitalizes the first letter of each word, lowercases the rest
2
+ * String utilities for common text manipulation tasks.
3
+ */
4
+ /**
5
+ * Adds commas to a number for thousands separators.
6
+ *
7
+ * @example formatNumber(1000) => '1,000'
8
+ * @example formatNumber('1234567') => '1,234,567'
9
+ * @example formatNumber(1234567.89) => '1,234,567.89'
10
+ */
11
+ export declare const formatNumber: (value: string | number) => string;
12
+ export declare const normalCase: (str?: string) => string;
13
+ export declare const sentenceCase: (str?: string) => string;
14
+ export declare const upperCase: (str?: string) => string;
15
+ export declare const lowerCase: (str?: string) => string;
16
+ /**
17
+ * Converts a string to camelCase.
18
+ *
19
+ * @example toCamelCase('hello-world') => 'helloWorld'
20
+ * @example toCamelCase('hello_world') => 'helloWorld'
21
+ */
22
+ export declare const toCamelCase: (str: string) => string;
23
+ export declare const camelCase: (str: string) => string;
24
+ /**
25
+ * Converts a string to kebab-case.
26
+ *
27
+ * @example toKebabCase('helloWorld') => 'hello-world'
28
+ * @example toKebabCase('Hello_World') => 'hello-world'
29
+ */
30
+ export declare const toKebabCase: (str: string) => string;
31
+ export declare const kebabCase: (str: string) => string;
32
+ /**
33
+ * Converts a string to snake_case.
34
+ *
35
+ * @example toSnakeCase('helloWorld') => 'hello_world'
36
+ * @example toSnakeCase('hello-world') => 'hello_world'
37
+ */
38
+ export declare const toSnakeCase: (str: string) => string;
39
+ export declare const snakeCase: (str: string) => string;
40
+ /**
41
+ * Converts a string to PascalCase.
42
+ *
43
+ * @example toPascalCase('hello-world') => 'HelloWorld'
44
+ * @example toPascalCase('hello_world') => 'HelloWorld'
45
+ */
46
+ export declare const toPascalCase: (str: string) => string;
47
+ export declare const pascalCase: (str: string) => string;
48
+ export declare const snakeCaseToSpaces: (str: string) => string;
49
+ export declare const kebabToSpaces: (str: string) => string;
50
+ /**
51
+ * Capitalizes the first character of a string.
52
+ *
53
+ * @example capitalize('hello world') => 'Hello world'
54
+ */
55
+ export declare const capitalize: (str: string) => string;
56
+ /**
57
+ * Capitalizes the first letter of each word.
58
+ *
59
+ * @example titleCase('hello world') => 'Hello World'
60
+ */
61
+ export declare const titleCase: (str: string) => string;
62
+ /**
63
+ * Truncates a string to a specified length and adds ellipsis.
64
+ *
65
+ * @example truncate('hello world', 5) => 'he...'
66
+ */
67
+ export declare const truncate: (str: string, length: number, suffix?: string) => string;
68
+ /**
69
+ * Removes all whitespace from a string.
70
+ *
71
+ * @example removeWhitespace('hello world') => 'helloworld'
72
+ */
73
+ export declare const removeWhitespace: (str: string) => string;
74
+ /**
75
+ * Removes all non-alphanumeric characters.
76
+ *
77
+ * @example removeSpecialChars('hello@world#123') => 'helloworld123'
78
+ */
79
+ export declare const removeSpecialChars: (str: string) => string;
80
+ /**
81
+ * Generates a URL-friendly slug from a string.
82
+ *
83
+ * @example slug('Hello World 2024!') => 'hello-world-2024'
84
+ */
85
+ export declare const slug: (str: string) => string;
86
+ /**
87
+ * Validates if a string is a valid email.
88
+ *
89
+ * @example isEmail('user@example.com') => true
90
+ */
91
+ export declare const isEmail: (str: string) => boolean;
92
+ /**
93
+ * Validates if a string is a valid URL.
94
+ *
95
+ * @example isUrl('https://example.com') => true
96
+ */
97
+ export declare const isUrl: (str: string) => boolean;
98
+ /**
99
+ * Validates if a string contains only numbers.
100
+ *
101
+ * @example isNumeric('12345') => true
102
+ * @example isNumeric('123abc') => false
103
+ */
104
+ export declare const isNumeric: (str: string) => boolean;
105
+ /**
106
+ * Checks if a string is empty or contains only whitespace.
107
+ *
108
+ * @example isEmpty(' ') => true
109
+ * @example isEmpty('hello') => false
110
+ */
111
+ export declare const isEmpty: (str: string) => boolean;
112
+ /**
113
+ * Reverses a string.
114
+ *
115
+ * @example reverse('hello') => 'olleh'
116
+ */
117
+ export declare const reverse: (str: string) => string;
118
+ /**
119
+ * Repeats a string a specified number of times.
120
+ *
121
+ * @example repeat('ab', 3) => 'ababab'
122
+ */
123
+ export declare const repeat: (str: string, times: number) => string;
124
+ /**
125
+ * Pads a string to a specified length.
126
+ *
127
+ * @example padStart('5', 3, '0') => '005'
128
+ * @example padEnd('5', 3, '0') => '500'
129
+ */
130
+ export declare const padStart: (str: string, length: number, padChar?: string) => string;
131
+ export declare const padEnd: (str: string, length: number, padChar?: string) => string;
132
+ /**
133
+ * Encodes a string to Base64.
134
+ *
135
+ * @example toBase64('hello') => 'aGVsbG8='
136
+ */
137
+ export declare const toBase64: (str: string) => string;
138
+ /**
139
+ * Decodes a Base64 string.
140
+ *
141
+ * @example fromBase64('aGVsbG8=') => 'hello'
142
+ */
143
+ export declare const fromBase64: (str: string) => string;
144
+ /**
145
+ * Counts the number of words in a string.
146
+ *
147
+ * @example wordCount('hello world test') => 3
148
+ */
149
+ export declare const wordCount: (str: string) => number;
150
+ /**
151
+ * Counts the number of characters, excluding whitespace.
152
+ *
153
+ * @example charCount('hello world') => 10
154
+ */
155
+ export declare const charCount: (str: string) => number;
156
+ /**
157
+ * Repeats a character a specified number of times.
158
+ *
159
+ * @example repeatChar('*', 5) => '*****'
160
+ */
161
+ export declare const repeatChar: (char: string, times: number) => string;
162
+ /**
163
+ * Extracts numbers from a string.
164
+ *
165
+ * @example extractNumbers('abc123def456') => '123456'
166
+ */
167
+ export declare const extractNumbers: (str: string) => string;
168
+ /**
169
+ * Removes duplicate consecutive characters.
170
+ *
171
+ * @example removeDuplicates('aabbccdd') => 'abcd'
172
+ */
173
+ export declare const removeDuplicates: (str: string) => string;
174
+ /**
175
+ * Checks if a string is a palindrome.
176
+ *
177
+ * @example isPalindrome('racecar') => true
178
+ * @example isPalindrome('hello') => false
179
+ */
180
+ export declare const isPalindrome: (str: string) => boolean;
181
+ /**
182
+ * Finds the longest word in a string.
183
+ *
184
+ * @example longestWord('the quick brown fox') => 'quick'
185
+ */
186
+ export declare const longestWord: (str: string) => string;
187
+ /**
188
+ * Pluralizes common English words using a simple ruleset.
6
189
  *
7
- * @param {TurndownObject} [str] Input value (falsy returns an empty string)
8
- * @returns {string}
9
- * @example
10
- * normalCase("helloWorld") // "Hello World"
11
- * normalCase("XMLHttpRequest") // "Xml Http Request"
190
+ * @example pluralize('cat') => 'cats'
191
+ * @example pluralize('box') => 'boxes'
12
192
  */
13
- export declare const normalCase: (str?: TurndownObject) => string;
193
+ export declare const pluralize: (word: string) => string;
14
194
  /**
15
- * Capitalize only the first character; lowercases the rest.
16
- * Trims leading/trailing spaces before processing.
195
+ * Highlights a substring within a string by wrapping it with markers.
17
196
  *
18
- * @param {TurndownObject} [str] Input value (falsy returns an empty string)
19
- * @returns {string}
20
- * @example
21
- * sentenceCase("hELLO WORLD") // "Hello world"
197
+ * @example highlight('hello world', 'world', '**') => 'hello **world**'
22
198
  */
23
- export declare const sentenceCase: (str?: TurndownObject) => string;
199
+ export declare const highlight: (str: string, substring: string, marker?: string) => string;
24
200
  /**
25
- * Uppercase the entire string.
201
+ * Converts a string to a regex-safe string.
26
202
  *
27
- * @param {TurndownObject} [str] Input value (falsy returns an empty string)
28
- * @returns {string}
29
- * @example
30
- * upperCase("Hello world") // "HELLO WORLD"
203
+ * @example escapeRegex('a.b*c') => 'a\\.b\\*c'
31
204
  */
32
- export declare const upperCase: (str?: TurndownObject) => string;
205
+ export declare const escapeRegex: (str: string) => string;
33
206
  /**
34
- * Lowercase the entire string.
207
+ * Finds similarity between two strings using Levenshtein distance.
208
+ * Returns a value between 0 and 1, where 1 means identical.
35
209
  *
36
- * @param {TurndownObject} [str] Input value (falsy returns an empty string)
37
- * @returns {string}
38
- * @example
39
- * lowerCase("Hello WORLD") // "hello world"
210
+ * @example stringSimilarity('hello', 'hallo') => 0.8
40
211
  */
41
- export declare const lowerCase: (str?: TurndownObject) => string;
212
+ export declare const stringSimilarity: (str1: string, str2: string) => number;
42
213
  /**
43
- * Convert to camelCase.
44
- * Splits on spaces, underscores, and hyphens; lowercases the first word,
45
- * TitleCases the rest, then joins with no separators.
214
+ * Strips HTML tags from a string.
46
215
  *
47
- * @param {TurndownObject} [str] Input value (falsy returns an empty string)
48
- * @returns {string}
49
- * @example
50
- * camelCase("Hello world") // "helloWorld"
51
- * camelCase("hello_world-again") // "helloWorldAgain"
216
+ * @example stripHtml('<p>Hello <b>world</b></p>') => 'Hello world'
52
217
  */
53
- export declare const camelCase: (str?: TurndownObject) => string;
218
+ export declare const stripHtml: (str: string) => string;
54
219
  /**
55
- * Convert to PascalCase.
56
- * Splits on spaces, underscores, and hyphens; TitleCases all words and joins them.
220
+ * Replaces multiple spaces with a single space.
57
221
  *
58
- * @param {TurndownObject} [str] Input value (falsy returns an empty string)
59
- * @returns {string}
60
- * @example
61
- * pascalCase("hello world") // "HelloWorld"
62
- * pascalCase("hello_world-again") // "HelloWorldAgain"
222
+ * @example normalizeSpaces('hello world') => 'hello world'
63
223
  */
64
- export declare const pascalCase: (str?: TurndownObject) => string;
224
+ export declare const normalizeSpaces: (str: string) => string;
65
225
  /**
66
- * Convert to kebab-case.
67
- * Inserts hyphens between camelCase boundaries, then replaces spaces/underscores with hyphens.
226
+ * Converts a string to a number, returning null if not valid.
68
227
  *
69
- * @param {TurndownObject} [str] Input value (falsy returns an empty string)
70
- * @returns {string}
71
- * @example
72
- * kebabCase("HelloWorld Again") // "hello-world-again"
73
- * kebabCase("hello_world") // "hello-world"
228
+ * @example toNumber('123') => 123
229
+ * @example toNumber('abc') => null
74
230
  */
75
- export declare const kebabCase: (str?: TurndownObject) => string;
231
+ export declare const toNumber: (str: string) => number | null;
76
232
  /**
77
- * Convert to snake_case.
78
- * Inserts underscores between camelCase boundaries, then replaces spaces/hyphens with underscores.
233
+ * Splits a string by multiple delimiters.
79
234
  *
80
- * @param {TurndownObject} [str] Input value (falsy returns an empty string)
81
- * @returns {string}
82
- * @example
83
- * snakeCase("HelloWorld Again") // "hello_world_again"
84
- * snakeCase("hello-world") // "hello_world"
235
+ * @example splitMultiple('a,b;c:d', ',', ';', ':') => ['a', 'b', 'c', 'd']
85
236
  */
86
- export declare const snakeCase: (str?: TurndownObject) => string;
237
+ export declare const splitMultiple: (str: string, ...delimiters: string[]) => string[];
87
238
  /**
88
- * Convert snake_case to space-delimited words.
239
+ * Checks if a string contains any of the provided substrings.
89
240
  *
90
- * @param {TurndownObject} [str] Input value (falsy returns an empty string)
91
- * @returns {string}
92
- * @example
93
- * snakeCaseToSpaces("hello_world_again") // "hello world again"
241
+ * @example containsAny('hello world', 'foo', 'world') => true
94
242
  */
95
- export declare const snakeCaseToSpaces: (str?: TurndownObject) => string;
243
+ export declare const containsAny: (str: string, ...substrings: string[]) => boolean;
96
244
  /**
97
- * Convert kebab-case to space-delimited words.
245
+ * Checks if a string contains all of the provided substrings.
98
246
  *
99
- * @param {TurndownObject} [str] Input value (falsy returns an empty string)
100
- * @returns {string}
101
- * @example
102
- * kebabToSpaces("hello-world-again") // "hello world again"
247
+ * @example containsAll('hello world', 'hello', 'world') => true
103
248
  */
104
- export declare const kebabToSpaces: (str?: TurndownObject) => string;
249
+ export declare const containsAll: (str: string, ...substrings: string[]) => boolean;
250
+ export interface IAddress {
251
+ addressLine1?: string;
252
+ addressLine2?: string;
253
+ city?: string;
254
+ stateCode?: string;
255
+ postalCode?: string;
256
+ }
257
+ export declare const formatAddress: (address: IAddress) => string;