urdu-text-utils 0.1.6 → 0.1.7
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/CHANGELOG.md +7 -0
- package/README.md +25 -0
- package/dist/index.cjs +202 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +97 -1
- package/dist/index.d.ts +97 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +196 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -302,4 +302,100 @@ interface SlugOptions {
|
|
|
302
302
|
*/
|
|
303
303
|
declare function urduSlug(input: string, options?: SlugOptions): string;
|
|
304
304
|
|
|
305
|
-
|
|
305
|
+
/**
|
|
306
|
+
* Gregorian month names in Urdu (standard literary transliterations).
|
|
307
|
+
* Index 0 corresponds to January (جنوری).
|
|
308
|
+
*/
|
|
309
|
+
declare const URDU_MONTHS_GREGORIAN: readonly ["جنوری", "فروری", "مارچ", "اپریل", "مئی", "جون", "جولائی", "اگست", "ستمبر", "اکتوبر", "نومبر", "دسمبر"];
|
|
310
|
+
/**
|
|
311
|
+
* Islamic (Hijri) month names in Urdu.
|
|
312
|
+
* Index 0 corresponds to Muharram (محرم).
|
|
313
|
+
*/
|
|
314
|
+
declare const URDU_MONTHS_HIJRI: readonly ["محرم", "صفر", "ربیع الاول", "ربیع الثانی", "جمادی الاول", "جمادی الثانی", "رجب", "شعبان", "رمضان المبارک", "شوال", "ذی القعدہ", "ذی الحجہ"];
|
|
315
|
+
/**
|
|
316
|
+
* Days of the week in Urdu.
|
|
317
|
+
* Index 0 corresponds to Sunday (اتوار).
|
|
318
|
+
*/
|
|
319
|
+
declare const URDU_WEEKDAYS: readonly ["اتوار", "پیر", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"];
|
|
320
|
+
interface FormatUrduDateOptions {
|
|
321
|
+
/**
|
|
322
|
+
* Digit style to use for numeric tokens (e.g. YYYY, MM, DD, HH, mm, ss).
|
|
323
|
+
* @default "urdu"
|
|
324
|
+
*/
|
|
325
|
+
digits?: "urdu" | "english";
|
|
326
|
+
/**
|
|
327
|
+
* Calendar month naming scheme to use for `MMMM` and `MMM`.
|
|
328
|
+
* @default "gregorian"
|
|
329
|
+
*/
|
|
330
|
+
calendar?: "gregorian" | "hijri";
|
|
331
|
+
}
|
|
332
|
+
interface TimeAgoOptions {
|
|
333
|
+
/**
|
|
334
|
+
* Digit style to use for counts (e.g. "۵ منٹ پہلے" vs "5 منٹ پہلے").
|
|
335
|
+
* @default "urdu"
|
|
336
|
+
*/
|
|
337
|
+
digits?: "urdu" | "english";
|
|
338
|
+
/**
|
|
339
|
+
* Whether to include the relative suffix/prefix ("پہلے" or "بعد").
|
|
340
|
+
* When `false`, returns only the duration string (e.g. "۵ منٹ", "ایک گھنٹہ").
|
|
341
|
+
* @default true
|
|
342
|
+
*/
|
|
343
|
+
addSuffix?: boolean;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Returns the Urdu name for a given month index (0 to 11).
|
|
347
|
+
*
|
|
348
|
+
* @param monthIndex - 0 for January / Muharram, 11 for December / Dhul Hijjah.
|
|
349
|
+
* @param calendar - "gregorian" or "hijri". Default is "gregorian".
|
|
350
|
+
*/
|
|
351
|
+
declare function getUrduMonthName(monthIndex: number, calendar?: "gregorian" | "hijri"): string;
|
|
352
|
+
/**
|
|
353
|
+
* Returns the Urdu name for a day of the week (0 = Sunday, 6 = Saturday).
|
|
354
|
+
*/
|
|
355
|
+
declare function getUrduWeekdayName(dayIndex: number): string;
|
|
356
|
+
/**
|
|
357
|
+
* Formats a Date object or timestamp into an Urdu formatted date string.
|
|
358
|
+
*
|
|
359
|
+
* Supported formatting tokens:
|
|
360
|
+
* - `YYYY`: Full year (e.g. "۲۰۲۶")
|
|
361
|
+
* - `YY`: Two-digit year (e.g. "۲۶")
|
|
362
|
+
* - `MMMM`: Full Urdu month name (e.g. "اگست")
|
|
363
|
+
* - `MMM`: Full Urdu month name (e.g. "اگست")
|
|
364
|
+
* - `MM`: 2-digit month with leading zero (e.g. "۰۸")
|
|
365
|
+
* - `M`: 1-digit month (e.g. "۸")
|
|
366
|
+
* - `DD`: 2-digit day of month with leading zero (e.g. "۰۵")
|
|
367
|
+
* - `D`: 1-digit day of month (e.g. "۵")
|
|
368
|
+
* - `dddd`: Full day of the week (e.g. "ہفتہ", "جمعہ")
|
|
369
|
+
* - `ddd`: Short day of the week (same in Urdu)
|
|
370
|
+
* - `HH`: 24-hour hour with leading zero (00-23)
|
|
371
|
+
* - `H`: 24-hour hour (0-23)
|
|
372
|
+
* - `hh`: 12-hour hour with leading zero (01-12)
|
|
373
|
+
* - `h`: 12-hour hour (1-12)
|
|
374
|
+
* - `mm`: Minute with leading zero (00-59)
|
|
375
|
+
* - `m`: Minute (0-59)
|
|
376
|
+
* - `ss`: Second with leading zero (00-59)
|
|
377
|
+
* - `s`: Second (0-59)
|
|
378
|
+
* - `A`: Day period indicator in Urdu ("صبح", "دوپہر", "شام", "رات")
|
|
379
|
+
* - `a`: Concise period indicator ("صبح", "شام")
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* formatUrduDate(new Date(2026, 7, 22), "DD MMMM YYYY")
|
|
383
|
+
* // "۲۲ اگست ۲۰۲۶"
|
|
384
|
+
*
|
|
385
|
+
* formatUrduDate(new Date(2026, 7, 22, 14, 30), "dddd، D MMMM YYYY، hh:mm A")
|
|
386
|
+
* // "ہفتہ، ۲۲ اگست ۲۰۲۶، ۰۲:۳۰ دوپہر"
|
|
387
|
+
*/
|
|
388
|
+
declare function formatUrduDate(date: Date | string | number, pattern?: string, options?: FormatUrduDateOptions): string;
|
|
389
|
+
/**
|
|
390
|
+
* Returns a human-friendly relative time string in Urdu.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* timeAgoUrdu(Date.now() - 30 * 1000) // "ابھی"
|
|
394
|
+
* timeAgoUrdu(Date.now() - 5 * 60 * 1000) // "۵ منٹ پہلے"
|
|
395
|
+
* timeAgoUrdu(Date.now() - 3 * 3600 * 1000) // "۳ گھنٹے پہلے"
|
|
396
|
+
* timeAgoUrdu(Date.now() - 86400 * 1000) // "کل"
|
|
397
|
+
* timeAgoUrdu(Date.now() + 5 * 60 * 1000) // "۵ منٹ بعد"
|
|
398
|
+
*/
|
|
399
|
+
declare function timeAgoUrdu(date: Date | string | number, relativeTo?: Date | string | number, options?: TimeAgoOptions): string;
|
|
400
|
+
|
|
401
|
+
export { type DigitStyle, type FormatUrduDateOptions, type IsUrduOptions, type NormalizeOptions, type SearchOptions, type SearchResult, type SlugOptions, type SortOptions, type SplitSentenceOptions, type TimeAgoOptions, URDU_MONTHS_GREGORIAN, URDU_MONTHS_HIJRI, URDU_STOP_WORDS, URDU_WEEKDAYS, type UrduStats, analyzeUrdu, compareUrdu, convertNumbers, countSentences, countWords, editDistance, filterStopWords, foldUrdu, formatUrduDate, getUrduMonthName, getUrduWeekdayName, hasUrduSpecificLetters, highlightUrdu, isStopWord, isUrdu, normalizeUrdu, numberToUrduWords, parseUrduNumber, removeDiacritics, removeStopWords, romanToUrdu, romanize, searchUrdu, searchUrduRanked, sortUrdu, splitSentences, splitWords, timeAgoUrdu, toArabicIndicDigits, toEnglishDigits, toUrduDigits, urduRatio, urduSlug };
|
package/dist/index.d.ts
CHANGED
|
@@ -302,4 +302,100 @@ interface SlugOptions {
|
|
|
302
302
|
*/
|
|
303
303
|
declare function urduSlug(input: string, options?: SlugOptions): string;
|
|
304
304
|
|
|
305
|
-
|
|
305
|
+
/**
|
|
306
|
+
* Gregorian month names in Urdu (standard literary transliterations).
|
|
307
|
+
* Index 0 corresponds to January (جنوری).
|
|
308
|
+
*/
|
|
309
|
+
declare const URDU_MONTHS_GREGORIAN: readonly ["جنوری", "فروری", "مارچ", "اپریل", "مئی", "جون", "جولائی", "اگست", "ستمبر", "اکتوبر", "نومبر", "دسمبر"];
|
|
310
|
+
/**
|
|
311
|
+
* Islamic (Hijri) month names in Urdu.
|
|
312
|
+
* Index 0 corresponds to Muharram (محرم).
|
|
313
|
+
*/
|
|
314
|
+
declare const URDU_MONTHS_HIJRI: readonly ["محرم", "صفر", "ربیع الاول", "ربیع الثانی", "جمادی الاول", "جمادی الثانی", "رجب", "شعبان", "رمضان المبارک", "شوال", "ذی القعدہ", "ذی الحجہ"];
|
|
315
|
+
/**
|
|
316
|
+
* Days of the week in Urdu.
|
|
317
|
+
* Index 0 corresponds to Sunday (اتوار).
|
|
318
|
+
*/
|
|
319
|
+
declare const URDU_WEEKDAYS: readonly ["اتوار", "پیر", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"];
|
|
320
|
+
interface FormatUrduDateOptions {
|
|
321
|
+
/**
|
|
322
|
+
* Digit style to use for numeric tokens (e.g. YYYY, MM, DD, HH, mm, ss).
|
|
323
|
+
* @default "urdu"
|
|
324
|
+
*/
|
|
325
|
+
digits?: "urdu" | "english";
|
|
326
|
+
/**
|
|
327
|
+
* Calendar month naming scheme to use for `MMMM` and `MMM`.
|
|
328
|
+
* @default "gregorian"
|
|
329
|
+
*/
|
|
330
|
+
calendar?: "gregorian" | "hijri";
|
|
331
|
+
}
|
|
332
|
+
interface TimeAgoOptions {
|
|
333
|
+
/**
|
|
334
|
+
* Digit style to use for counts (e.g. "۵ منٹ پہلے" vs "5 منٹ پہلے").
|
|
335
|
+
* @default "urdu"
|
|
336
|
+
*/
|
|
337
|
+
digits?: "urdu" | "english";
|
|
338
|
+
/**
|
|
339
|
+
* Whether to include the relative suffix/prefix ("پہلے" or "بعد").
|
|
340
|
+
* When `false`, returns only the duration string (e.g. "۵ منٹ", "ایک گھنٹہ").
|
|
341
|
+
* @default true
|
|
342
|
+
*/
|
|
343
|
+
addSuffix?: boolean;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Returns the Urdu name for a given month index (0 to 11).
|
|
347
|
+
*
|
|
348
|
+
* @param monthIndex - 0 for January / Muharram, 11 for December / Dhul Hijjah.
|
|
349
|
+
* @param calendar - "gregorian" or "hijri". Default is "gregorian".
|
|
350
|
+
*/
|
|
351
|
+
declare function getUrduMonthName(monthIndex: number, calendar?: "gregorian" | "hijri"): string;
|
|
352
|
+
/**
|
|
353
|
+
* Returns the Urdu name for a day of the week (0 = Sunday, 6 = Saturday).
|
|
354
|
+
*/
|
|
355
|
+
declare function getUrduWeekdayName(dayIndex: number): string;
|
|
356
|
+
/**
|
|
357
|
+
* Formats a Date object or timestamp into an Urdu formatted date string.
|
|
358
|
+
*
|
|
359
|
+
* Supported formatting tokens:
|
|
360
|
+
* - `YYYY`: Full year (e.g. "۲۰۲۶")
|
|
361
|
+
* - `YY`: Two-digit year (e.g. "۲۶")
|
|
362
|
+
* - `MMMM`: Full Urdu month name (e.g. "اگست")
|
|
363
|
+
* - `MMM`: Full Urdu month name (e.g. "اگست")
|
|
364
|
+
* - `MM`: 2-digit month with leading zero (e.g. "۰۸")
|
|
365
|
+
* - `M`: 1-digit month (e.g. "۸")
|
|
366
|
+
* - `DD`: 2-digit day of month with leading zero (e.g. "۰۵")
|
|
367
|
+
* - `D`: 1-digit day of month (e.g. "۵")
|
|
368
|
+
* - `dddd`: Full day of the week (e.g. "ہفتہ", "جمعہ")
|
|
369
|
+
* - `ddd`: Short day of the week (same in Urdu)
|
|
370
|
+
* - `HH`: 24-hour hour with leading zero (00-23)
|
|
371
|
+
* - `H`: 24-hour hour (0-23)
|
|
372
|
+
* - `hh`: 12-hour hour with leading zero (01-12)
|
|
373
|
+
* - `h`: 12-hour hour (1-12)
|
|
374
|
+
* - `mm`: Minute with leading zero (00-59)
|
|
375
|
+
* - `m`: Minute (0-59)
|
|
376
|
+
* - `ss`: Second with leading zero (00-59)
|
|
377
|
+
* - `s`: Second (0-59)
|
|
378
|
+
* - `A`: Day period indicator in Urdu ("صبح", "دوپہر", "شام", "رات")
|
|
379
|
+
* - `a`: Concise period indicator ("صبح", "شام")
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* formatUrduDate(new Date(2026, 7, 22), "DD MMMM YYYY")
|
|
383
|
+
* // "۲۲ اگست ۲۰۲۶"
|
|
384
|
+
*
|
|
385
|
+
* formatUrduDate(new Date(2026, 7, 22, 14, 30), "dddd، D MMMM YYYY، hh:mm A")
|
|
386
|
+
* // "ہفتہ، ۲۲ اگست ۲۰۲۶، ۰۲:۳۰ دوپہر"
|
|
387
|
+
*/
|
|
388
|
+
declare function formatUrduDate(date: Date | string | number, pattern?: string, options?: FormatUrduDateOptions): string;
|
|
389
|
+
/**
|
|
390
|
+
* Returns a human-friendly relative time string in Urdu.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* timeAgoUrdu(Date.now() - 30 * 1000) // "ابھی"
|
|
394
|
+
* timeAgoUrdu(Date.now() - 5 * 60 * 1000) // "۵ منٹ پہلے"
|
|
395
|
+
* timeAgoUrdu(Date.now() - 3 * 3600 * 1000) // "۳ گھنٹے پہلے"
|
|
396
|
+
* timeAgoUrdu(Date.now() - 86400 * 1000) // "کل"
|
|
397
|
+
* timeAgoUrdu(Date.now() + 5 * 60 * 1000) // "۵ منٹ بعد"
|
|
398
|
+
*/
|
|
399
|
+
declare function timeAgoUrdu(date: Date | string | number, relativeTo?: Date | string | number, options?: TimeAgoOptions): string;
|
|
400
|
+
|
|
401
|
+
export { type DigitStyle, type FormatUrduDateOptions, type IsUrduOptions, type NormalizeOptions, type SearchOptions, type SearchResult, type SlugOptions, type SortOptions, type SplitSentenceOptions, type TimeAgoOptions, URDU_MONTHS_GREGORIAN, URDU_MONTHS_HIJRI, URDU_STOP_WORDS, URDU_WEEKDAYS, type UrduStats, analyzeUrdu, compareUrdu, convertNumbers, countSentences, countWords, editDistance, filterStopWords, foldUrdu, formatUrduDate, getUrduMonthName, getUrduWeekdayName, hasUrduSpecificLetters, highlightUrdu, isStopWord, isUrdu, normalizeUrdu, numberToUrduWords, parseUrduNumber, removeDiacritics, removeStopWords, romanToUrdu, romanize, searchUrdu, searchUrduRanked, sortUrdu, splitSentences, splitWords, timeAgoUrdu, toArabicIndicDigits, toEnglishDigits, toUrduDigits, urduRatio, urduSlug };
|