whatsapp-chat-parser
Version:
A package to parse WhatsApp chats with Node.js or in the browser 💬
51 lines (50 loc) • 2.16 kB
TypeScript
/**
* Takes an array of numeric dates and tries to understand if the days come
* before the month or the other way around by checking if numbers go above
* `12`.
*
* Output is `true` if days are first, `false` if they are second, or `null` if
* it failed to understand the order.
*/
declare function checkAbove12(numericDates: number[][]): boolean | null;
/**
* Takes an array of numeric dates and tries to understand if the days come
* before the month or the other way around by checking if a set of numbers
* during the same year decrease at some point.
*
* If it does it's probably the days since months can only increase in a given
* year.
*
* Output is `true` if days are first, `false` if they are second, or `null` if
* it failed to understand the order.
*/
declare function checkDecreasing(numericDates: number[][]): boolean | null;
/**
* Takes an array of numeric dates and tries to understand if the days come
* before the month or the other way around by looking at which number changes
* more frequently.
*
* Output is `true` if days are first, `false` if they are second, or `null` if
* it failed to understand the order.
*/
declare function changeFrequencyAnalysis(numericDates: number[][]): boolean | null;
/**
* Takes an array of numeric dates and tries to understand if the days come
* before the month or the other way around by running the dates through various
* checks.
*
* Output is `true` if days are first, `false` if they are second, or `null` if
* it failed to understand the order.
*/
declare function daysBeforeMonths(numericDates: number[][]): boolean | null;
/**
* Takes `year`, `month` and `day` as strings and pads them to `4`, `2`, `2`
* digits respectively.
*/
declare function normalizeDate(year: string, month: string, day: string): [string, string, string];
/**
* Pushes the longest number in a date to the end, if there is one. Necessary to
* ensure the year is the last number.
*/
declare function orderDateComponents(date: string): [string, string, string];
export { checkAbove12, checkDecreasing, changeFrequencyAnalysis, daysBeforeMonths, normalizeDate, orderDateComponents, };