bitaboom 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.
@@ -0,0 +1,434 @@
1
+ /**
2
+ * Removes extreme Arabic underscores (ـ) that appear at the beginning or end of a line or in text.
3
+ * Does not affect Hijri dates (e.g., 1424هـ) or specific Arabic terms.
4
+ * Example: "ـThis is a textـ" will be changed to "This is a text".
5
+ * @param {string} text - The input text to apply the rule to.
6
+ * @returns {string} - The modified text with extreme underscores removed.
7
+ */
8
+ export const cleanExtremeArabicUnderscores: (text: string) => string;
9
+ /**
10
+ * Converts Urdu symbols to their Arabic equivalents.
11
+ * Example: 'ھذا' will be changed to 'هذا', 'ی' to 'ي'.
12
+ * @param {string} text - The input text containing Urdu symbols.
13
+ * @returns {string} - The modified text with Urdu symbols converted to Arabic symbols.
14
+ */
15
+ export const convertUrduSymbolsToArabic: (text: string) => string;
16
+ /**
17
+ * Fixes the trailing "و" (wow) in phrases such as "عليكم و رحمة" to "عليكم ورحمة".
18
+ * This function attempts to correct phrases where "و" appears unnecessarily, particularly in greetings.
19
+ * Example: 'السلام عليكم و رحمة' will be changed to 'السلام عليكم ورحمة'.
20
+ * @param {string} text - The input text containing the "و" character.
21
+ * @returns {string} - The modified text with unnecessary trailing "و" characters corrected.
22
+ */
23
+ export const fixTrailingWow: (text: string) => string;
24
+ /**
25
+ * Inserts a space between Arabic text and numbers.
26
+ * Example: 'الآية37' will be changed to 'الآية 37'.
27
+ * @param {string} text - The input text containing Arabic text followed by numbers.
28
+ * @returns {string} - The modified text with spaces inserted between Arabic text and numbers.
29
+ */
30
+ export const addSpaceBetweenArabicTextAndNumbers: (text: string) => string;
31
+ /**
32
+ * Removes English letters and symbols from the text, including ampersands, slashes, and other symbols.
33
+ * Example: 'أحب & لنفسي' will be changed to 'أحب لنفسي'.
34
+ * @param {string} text - The input text containing English letters and symbols.
35
+ * @returns {string} - The modified text with English letters and symbols removed.
36
+ */
37
+ export const stripEnglishCharactersAndSymbols: (text: string) => string;
38
+ /**
39
+ * Removes single-digit numbers surrounded by Arabic text. Also removes dashes (-) not followed by a number.
40
+ * For example, removes '3' from 'وهب 3 وقال' but does not remove '121' from 'لوحه 121 الجرح'.
41
+ * @param {string} text - The input text to apply the rule to.
42
+ * @returns {string} - The modified text with non-index numbers and dashes removed.
43
+ */
44
+ export const removeNonIndexSignatures: (text: string) => string;
45
+ /**
46
+ * Removes characters enclosed in square brackets [] or parentheses () if they are Arabic letters or Arabic-Indic numerals.
47
+ * Example: '[س]' or '(س)' will be removed.
48
+ * @param {string} text - The input text to apply the rule to.
49
+ * @returns {string} - The modified text with singular codes removed.
50
+ */
51
+ export const removeSingularCodes: (text: string) => string;
52
+ /**
53
+ * Removes solitary Arabic letters unless they are the 'ha' letter, which is used in Hijri years.
54
+ * Example: "ب ا الكلمات ت" will be changed to "ا الكلمات".
55
+ * @param {string} text - The input text to apply the rule to.
56
+ * @returns {string} - The modified text with solitary Arabic letters removed.
57
+ */
58
+ export const removeSolitaryArabicLetters: (text: string) => string;
59
+ /**
60
+ * Replaces the 'tah marbutah' (ة) character with 'ha' (ه).
61
+ * Example: 'مدرسة' will be changed to 'مدرسه'.
62
+ * @param {string} text - The input text to apply the rule to.
63
+ * @returns {string} - The modified text with 'ta marbutah' replaced by 'ha'.
64
+ */
65
+ export const replaceTaMarbutahWithHa: (text: string) => string;
66
+ /**
67
+ * Removes Arabic diacritics (tashkeel) and the tatweel (elongation) character.
68
+ * Example: 'مُحَمَّدٌ' will be changed to 'محمد'.
69
+ * @param {string} text - The input text to apply the rule to.
70
+ * @returns {string} - The modified text with diacritics and tatweel removed.
71
+ */
72
+ export const stripDiacritics: (text: string) => string;
73
+ /**
74
+ * Removes zero-width joiners (ZWJ) and other zero-width characters from the input text.
75
+ * Zero-width characters include U+200B to U+200F, U+202A to U+202E, U+2060 to U+2064, and U+FEFF.
76
+ * @param {string} text - The input text to apply the rule to.
77
+ * @returns {string} - The modified text with zero-width characters removed.
78
+ */
79
+ export const stripZeroWidthCharacters: (text: string) => string;
80
+ /**
81
+ * Replaces the 'alif maqsurah' (ى) character with the regular 'ya' (ي).
82
+ * Example: 'رؤيى' will be changed to 'رؤيي'.
83
+ * @param {string} text - The input text to apply the rule to.
84
+ * @returns {string} - The modified text with 'alif maqsurah' replaced by 'ya'.
85
+ */
86
+ export const replaceAlifMaqsurah: (text: string) => string;
87
+ /**
88
+ * Replaces English punctuation (question mark and semicolon) with their Arabic equivalents.
89
+ * Example: '?' will be replaced with '؟', and ';' with '؛'.
90
+ * @param {string} text - The input text to apply the rule to.
91
+ * @returns {string} - The modified text with English punctuation replaced by Arabic punctuation.
92
+ */
93
+ export const replaceEnglishPunctuationWithArabic: (text: string) => string;
94
+ /**
95
+ * Simplifies all forms of 'alif' (أ, إ, and آ) to the basic 'ا'.
96
+ * Example: 'أنا إلى الآفاق' will be changed to 'انا الى الافاق'.
97
+ * @param {string} text - The input text to apply the rule to.
98
+ * @returns {string} - The modified text with simplified 'alif' characters.
99
+ */
100
+ export const normalizeAlifVariants: (text: string) => string;
101
+ /**
102
+ * Adds line breaks after punctuation marks such as periods, exclamation points, and question marks.
103
+ * Example: 'Text.' becomes 'Text.\n'.
104
+ * @param {string} text - The input text containing punctuation.
105
+ * @returns {string} - The modified text with line breaks added after punctuation.
106
+ */
107
+ export const insertLineBreaksAfterPunctuation: (text: string) => string;
108
+ /**
109
+ * Adds spaces before and after punctuation, except for certain cases like quoted text or ayah references.
110
+ * Example: 'Text,word' becomes 'Text, word'.
111
+ * @param {string} text - The input text containing punctuation.
112
+ * @returns {string} - The modified text with spaces added before and after punctuation.
113
+ */
114
+ export const addSpaceBeforeAndAfterPunctuation: (text: string) => string;
115
+ /**
116
+ * Turns regular double quotes surrounding a body of text into smart quotes.
117
+ * Also fixes incorrect starting quotes by ensuring the string starts with an opening quote if needed.
118
+ * Example: 'The "quick brown" fox' becomes 'The “quick brown” fox'.
119
+ * @param {string} text - The input text to apply the rule to.
120
+ * @returns {string} - The modified text with smart quotes applied.
121
+ */
122
+ export const applySmartQuotes: (text: string) => string;
123
+ /**
124
+ * Replaces literal new line characters (\n) and carriage returns (\r) with actual line breaks.
125
+ * Example: 'A\\nB' becomes 'A\nB'.
126
+ * @param {string} text - The input text containing literal new lines.
127
+ * @returns {string} - The modified text with actual line breaks.
128
+ */
129
+ export const cleanLiteralNewLines: (text: string) => string;
130
+ /**
131
+ * Removes trailing spaces from each line in a multiline string.
132
+ * Example: " This is a line \nAnother line " becomes "This is a line\nAnother line".
133
+ * @param {string} text - The input text to apply the rule to.
134
+ * @returns {string} - The modified text with trailing spaces removed.
135
+ */
136
+ export const cleanMultilines: (text: string) => string;
137
+ /**
138
+ * Checks if the input string consists of only punctuation characters.
139
+ * @param {string} text - The input text to check.
140
+ * @returns {boolean} - Returns true if the string contains only punctuation, false otherwise.
141
+ */
142
+ export const isOnlyPunctuation: (text: string) => boolean;
143
+ export const cleanJunkFromText: (text: string) => string;
144
+ /**
145
+ * Cleans unnecessary spaces before punctuation marks such as periods, commas, and question marks.
146
+ * Example: 'This is a sentence , with extra space .' becomes 'This is a sentence, with extra space.'.
147
+ * @param {string} text - The input text to apply the rule to.
148
+ * @returns {string} - The modified text with cleaned spaces before punctuation.
149
+ */
150
+ export const cleanSpacesBeforePeriod: (text: string) => string;
151
+ /**
152
+ * Condenses multiple asterisks (*) into a single one.
153
+ * Example: '***' becomes '*'.
154
+ * @param {string} text - The input text to apply the rule to.
155
+ * @returns {string} - The modified text with condensed asterisks.
156
+ */
157
+ export const condenseAsterisks: (text: string) => string;
158
+ /**
159
+ * Replaces occurrences of colons surrounded by periods (e.g., '.:.' or ':') with a single colon.
160
+ * Example: 'This.:. is a test' becomes 'This: is a test'.
161
+ * @param {string} text - The input text to apply the rule to.
162
+ * @returns {string} - The modified text with condensed colons.
163
+ */
164
+ export const condenseColons: (text: string) => string;
165
+ /**
166
+ * Condenses two or more dashes (--) into a single dash (-).
167
+ * Example: 'This is some ---- text' becomes 'This is some - text'.
168
+ * @param {string} text - The input text to apply the rule to.
169
+ * @returns {string} - The modified text with condensed dashes.
170
+ */
171
+ export const condenseDashes: (text: string) => string;
172
+ /**
173
+ * Replaces sequences of two or more periods (e.g., '...') with an ellipsis character (…).
174
+ * Example: 'This is a test...' becomes 'This is a test…'.
175
+ * @param {string} text - The input text to apply the rule to.
176
+ * @returns {string} - The modified text with ellipses condensed.
177
+ */
178
+ export const condenseEllipsis: (text: string) => string;
179
+ /**
180
+ * Reduces multiple consecutive line breaks (3 or more) to exactly 2 line breaks.
181
+ * Example: 'This is line 1\n\n\n\nThis is line 2' becomes 'This is line 1\n\nThis is line 2'.
182
+ * @param {string} text - The input text to apply the rule to.
183
+ * @returns {string} - The modified text with condensed line breaks.
184
+ */
185
+ export const reduceMultilineBreaksToDouble: (text: string) => string;
186
+ /**
187
+ * Reduces multiple consecutive line breaks (2 or more) to exactly 1 line break.
188
+ * Example: 'This is line 1\n\nThis is line 2' becomes 'This is line 1\nThis is line 2'.
189
+ * @param {string} text - The input text to apply the rule to.
190
+ * @returns {string} - The modified text with condensed line breaks.
191
+ */
192
+ export const reduceMultilineBreaksToSingle: (text: string) => string;
193
+ /**
194
+ * Condenses multiple periods separated by spaces (e.g., '. . .') into a single period.
195
+ * Example: 'This . . . is a test' becomes 'This. is a test'.
196
+ * @param {string} text - The input text to apply the rule to.
197
+ * @returns {string} - The modified text with condensed periods.
198
+ */
199
+ export const condensePeriods: (text: string) => string;
200
+ /**
201
+ * Condenses multiple underscores (__) or Arabic Tatweel characters (ـــــ) into a single underscore or Tatweel.
202
+ * Example: 'This is ـــ some text __' becomes 'This is ـ some text _'.
203
+ * @param {string} text - The input text to apply the rule to.
204
+ * @returns {string} - The modified text with condensed underscores.
205
+ */
206
+ export const condenseUnderscores: (text: string) => string;
207
+ /**
208
+ * Replaces double parentheses or brackets with single ones.
209
+ * Example: '((text))' becomes '(text)'.
210
+ * @param {string} text - The input text to apply the rule to.
211
+ * @returns {string} - The modified text with condensed brackets.
212
+ */
213
+ export const doubleToSingleBrackets: (text: string) => string;
214
+ /**
215
+ * Formats a multiline string by joining sentences and maintaining footnotes on their own lines.
216
+ * Footnotes are identified by Arabic and English numerals.
217
+ * Example: 'Sentence one.\n(1) A footnote.\nSentence two.' remains the same, while regular sentences are joined.
218
+ * @param {string} input - The input text containing sentences and footnotes.
219
+ * @returns {string} - The formatted text.
220
+ */
221
+ export const formatStringBySentence: (input: string) => string;
222
+ /**
223
+ * Removes unnecessary spaces around slashes in references.
224
+ * Example: '127 / 11' becomes '127/11'.
225
+ * @param {string} text - The input text containing references.
226
+ * @returns {string} - The modified text with spaces removed around slashes.
227
+ */
228
+ export const normalizeSlashInReferences: (text: string) => string;
229
+ /**
230
+ * Reduces multiple spaces or tabs to a single space.
231
+ * Example: 'This is a text' becomes 'This is a text'.
232
+ * @param {string} text - The input text containing extra spaces.
233
+ * @returns {string} - The modified text with reduced spaces.
234
+ */
235
+ export const normalizeSpaces: (text: string) => string;
236
+ /**
237
+ * Removes spaces inside brackets, parentheses, or square brackets.
238
+ * Example: '( a b )' becomes '(a b)'.
239
+ * @param {string} text - The input text with spaces inside brackets.
240
+ * @returns {string} - The modified text with spaces removed inside brackets.
241
+ */
242
+ export const removeSpaceInsideBrackets: (text: string) => string;
243
+ /**
244
+ * Removes bold styling from text by normalizing the string and removing stylistic characters.
245
+ * @param {string} text - The input text containing bold characters.
246
+ * @returns {string} - The modified text with bold styling removed.
247
+ */
248
+ export const stripBoldStyling: (text: string) => string;
249
+ /**
250
+ * Removes italicized characters by replacing italic Unicode characters with their normal counterparts.
251
+ * Example: '𝘼𝘽𝘾' becomes 'ABC'.
252
+ * @param {string} text - The input text containing italicized characters.
253
+ * @returns {string} - The modified text with italics removed.
254
+ */
255
+ export const stripItalicsStyling: (text: string) => string;
256
+ /**
257
+ * Removes all bold and italic styling from the input text.
258
+ * @param {string} text - The input text to remove styling from.
259
+ * @returns {string} - The modified text with all styling removed.
260
+ */
261
+ export const stripStyling: (text: string) => string;
262
+ /**
263
+ * Removes unnecessary spaces inside quotes.
264
+ * Example: '“ Text ”' becomes '“Text”'.
265
+ * @param {string} text - The input text with spaces inside quotes.
266
+ * @returns {string} - The modified text with spaces removed inside quotes.
267
+ */
268
+ export const trimSpaceInsideQuotes: (text: string) => string;
269
+ /**
270
+ * Converts a string that resembles JSON but with numeric keys and single-quoted values
271
+ * into valid JSON format. This function replaces numeric keys with quoted numeric keys
272
+ * and ensures all values are double-quoted as required by JSON.
273
+ *
274
+ * @param {string} str - The input string that needs to be fixed into valid JSON.
275
+ * @returns {string} - A valid JSON string.
276
+ *
277
+ * @example
278
+ * const result = normalizeJsonSyntax("{10: 'abc', 20: 'def'}");
279
+ * console.log(result); // '{"10": "abc", "20": "def"}'
280
+ */
281
+ export const normalizeJsonSyntax: (str: string) => string;
282
+ /**
283
+ * Checks if a given string resembles a JSON object with numeric or quoted keys and values
284
+ * that are single or double quoted. This is useful for detecting malformed JSON-like
285
+ * structures that can be fixed by the `normalizeJsonSyntax` function.
286
+ *
287
+ * @param {string} str - The input string to check.
288
+ * @returns {boolean} - Returns true if the string is JSON-like, false otherwise.
289
+ *
290
+ * @example
291
+ * const result = isJsonStructureValid("{10: 'abc', 'key': 'value'}");
292
+ * console.log(result); // true
293
+ */
294
+ export const isJsonStructureValid: (str: string) => boolean;
295
+ /**
296
+ * Splits a string by spaces and quoted substrings.
297
+ *
298
+ * This function takes an input string and splits it into parts where substrings
299
+ * enclosed in double quotes are treated as a single part. Other substrings
300
+ * separated by spaces are split normally.
301
+ *
302
+ * @param {string} query - The input string to be split.
303
+ * @returns {string[]} An array of strings, with quoted substrings kept intact.
304
+ *
305
+ * @example
306
+ * const result = splitByQuotes('"This is" "a part of the" "string and"');
307
+ * console.log(result); // ["This is", "a part of the", "string and"]
308
+ */
309
+ export const splitByQuotes: (query: string) => string[];
310
+ /**
311
+ * Removes various symbols, part references, and numerical markers from the text.
312
+ * Example: '(1) (2/3)' becomes ''.
313
+ * @param {string} text - The input text to apply the rule to.
314
+ * @returns {string} - The modified text with symbols and part references removed.
315
+ */
316
+ export const cleanSymbolsAndPartReferences: (text: string) => string;
317
+ /**
318
+ * Removes trailing page numbers formatted as '-[46]-' from the text.
319
+ * Example: 'This is some -[46]- text' becomes 'This is some text'.
320
+ * @param {string} text - The input text with trailing page numbers.
321
+ * @returns {string} - The modified text with page numbers removed.
322
+ */
323
+ export const cleanTrailingPageNumbers: (text: string) => string;
324
+ /**
325
+ * Replaces consecutive line breaks and whitespace characters with a single space.
326
+ * Example: 'a\nb' becomes 'a b'.
327
+ * @param {string} text - The input text containing line breaks or multiple spaces.
328
+ * @returns {string} - The modified text with spaces.
329
+ */
330
+ export const replaceLineBreaksWithSpaces: (text: string) => string;
331
+ /**
332
+ * Removes all numeric digits from the text.
333
+ * Example: 'abc123' becomes 'abc'.
334
+ * @param {string} text - The input text containing digits.
335
+ * @returns {string} - The modified text with digits removed.
336
+ */
337
+ export const stripAllDigits: (text: string) => string;
338
+ /**
339
+ * Removes death year references like "(d. 390H)" and "[d. 100h]" from the text.
340
+ * Example: 'Sufyān ibn ‘Uyaynah (d. 198h)' becomes 'Sufyān ibn ‘Uyaynah'.
341
+ * @param {string} text - The input text containing death year references.
342
+ * @returns {string} - The modified text with death years removed.
343
+ */
344
+ export const removeDeathYear: (text: string) => string;
345
+ /**
346
+ * Removes numeric digits and dashes from the text.
347
+ * Example: 'ABC 123-Xyz' becomes 'ABC Xyz'.
348
+ * @param {string} text - The input text containing digits and dashes.
349
+ * @returns {string} - The modified text with numbers and dashes removed.
350
+ */
351
+ export const removeNumbersAndDashes: (text: string) => string;
352
+ /**
353
+ * Removes single digit references like (1), «2», [3] from the text.
354
+ * Example: 'Ref (1), Ref «2», Ref [3]' becomes 'Ref , Ref , Ref '.
355
+ * @param {string} text - The input text containing single digit references.
356
+ * @returns {string} - The modified text with single digit references removed.
357
+ */
358
+ export const removeSingleDigitReferences: (text: string) => string;
359
+ /**
360
+ * Removes URLs from the text.
361
+ * Example: 'Visit https://example.com' becomes 'Visit '.
362
+ * @param {string} text - The input text containing URLs.
363
+ * @returns {string} - The modified text with URLs removed.
364
+ */
365
+ export const removeUrls: (text: string) => string;
366
+ /**
367
+ * Replaces common Arabic prefixes (like 'Al-', 'Ar-', 'Ash-', etc.) with 'al-' in the text.
368
+ * Handles different variations of prefixes such as Ash- and Al- but not when the second word
369
+ * does not start with 'S'.
370
+ * Example: 'Ash-Shafiee' becomes 'al-Shafiee'.
371
+ *
372
+ * @param {string} text - The input text containing Arabic prefixes.
373
+ * @returns {string} - The modified text with standardized 'al-' prefixes.
374
+ */
375
+ export const normalizeArabicPrefixesToAl: (text: string) => string;
376
+ /**
377
+ * Removes double occurrences of Arabic apostrophes such as ʿʿ or ʾʾ in the text.
378
+ * Example: 'ʿulamāʾʾ' becomes 'ʿulamāʾ'.
379
+ *
380
+ * @param {string} text - The input text containing double apostrophes.
381
+ * @returns {string} - The modified text with condensed apostrophes.
382
+ */
383
+ export const normalizeDoubleApostrophes: (text: string) => string;
384
+ /**
385
+ * Replaces common salutations such as "sallahu alayhi wasallam" with "ﷺ" in the text.
386
+ * It also handles variations of the salutation phrase, including 'peace and blessings be upon him'.
387
+ * Example: 'Then Muḥammad (sallahu alayhi wasallam)' becomes 'Then Muḥammad ﷺ'.
388
+ *
389
+ * @param {string} text - The input text containing salutations.
390
+ * @returns {string} - The modified text with salutations replaced.
391
+ */
392
+ export const replaceSalutationsWithSymbol: (text: string) => string;
393
+ /**
394
+ * Normalizes the text by removing diacritics, apostrophes, and dashes.
395
+ * Example: 'Al-Jadwal' becomes 'AlJadwal'.
396
+ *
397
+ * @param {string} input - The input text to normalize.
398
+ * @returns {string} - The normalized text.
399
+ */
400
+ export const normalize: (input: string) => string;
401
+ /**
402
+ * Replaces various apostrophe characters (‛, ’, ‘) with the standard apostrophe (').
403
+ * Example: '‛ulama’ al-su‘' becomes ''ulama' al-su''.
404
+ *
405
+ * @param {string} text - The input text containing different apostrophe characters.
406
+ * @returns {string} - The modified text with normalized apostrophes.
407
+ */
408
+ export const normalizeApostrophes: (text: string) => string;
409
+ /**
410
+ * Strips common Arabic prefixes like 'al-', 'bi-', 'fī', 'wa-', etc. from the beginning of words.
411
+ * Example: 'al-Bukhari' becomes 'Bukhari'.
412
+ *
413
+ * @param {string} text - The input text containing Arabic prefixes.
414
+ * @returns {string} - The modified text with prefixes stripped.
415
+ */
416
+ export const removeArabicPrefixes: (text: string) => string;
417
+ /**
418
+ * Simplifies English transliterations by removing diacritics, apostrophes, and common prefixes.
419
+ * Example: 'Al-Jadwal' becomes 'Jadwal', and 'āḍġḥīṣṭū' becomes 'adghistu'.
420
+ *
421
+ * @param {string} text - The input text to simplify.
422
+ * @returns {string} - The simplified text.
423
+ */
424
+ export const normalizeTransliteratedEnglish: (text: string) => string;
425
+ /**
426
+ * Extracts the initials from the input string, typically used for names or titles.
427
+ * Example: 'Nayl al-Awtar' becomes 'NA'.
428
+ *
429
+ * @param {string} text - The input text to extract initials from.
430
+ * @returns {string} - The extracted initials.
431
+ */
432
+ export const extractInitials: (fullName: string) => string;
433
+
434
+ //# sourceMappingURL=index.d.ts.map