Package Exports
- whatsapp-chat-parser
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (whatsapp-chat-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
WhatsApp Chat Parser
A package to parse WhatsApp chat logs 💬
Install
$ npm install whatsapp-chat-parserUsage
const whatsapp = require('whatsapp-chat-parser');
whatsapp
.parseFile('path/to/file.txt')
.then(messages => {
// Do whatever you want with messages
})
.catch(err => {
// Something went wrong
});The messages variable is an array of objects like this:
[
{
date: '2018-06-02T22:45:00.000Z', // Date object
author: 'Luke',
message: 'Hey how are you?',
},
{
date: '2018-06-02T23:48:00.000Z', // Date object
author: 'Joe',
message: 'All good, thanks',
},
];In the case of a system message, the author will be System
[
{
date: '2018-06-02T22:45:00.000Z', // Date object
author: 'System',
message: 'You created group "Party 🎉"',
},
];API
parseFile(filepath, [options]) → Promise
filepath
Type: string
Path to the file to parse.
options
Type: object
parseString(string, [options]) → Promise
string
Type: string
Raw string of the WhatsApp conversation
options
Type: object
Options
| Name | Type | Default | Description |
|---|---|---|---|
| daysFirst | Boolean |
undefined |
Specify if your log file's date starts with a day (true) or a month (false). Manually specifying this may improve performance. By default the program will try to infer this information using 3 different methods (look at date.js for the implementation), if all fails it defaults to interpret the first digit as the day. |
Technologies used
- Testing: Jest
- Code formatting: Prettier
- Linting: ESLint (with Airbnb rules)
Requirements
Node.js >= 8.0.0