Skip to content

Commit

Permalink
🔀 Merge branch 'release/2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Pustur committed May 29, 2019
2 parents 1074829 + be0946c commit 60fbd4e
Show file tree
Hide file tree
Showing 13 changed files with 1,507 additions and 618 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": [["@babel/env", { "modules": false }]]
}
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
docker:
# specify the version you desire here
- image: circleci/node:8.0.0
- image: circleci/node:8.3.0

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
dist/
12 changes: 0 additions & 12 deletions .npmignore

This file was deleted.

12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# Change Log
# Changelog

## [2.0.0] - 2019-05-29

### Added

- Browser support (Thanks [@Mintonne](https://github.com/Mintonne))

### Removed

- `parseFile` method (Node users can still read the file in their code and pass the file contents to the `parseString` function)

## [1.2.4] - 2019-04-25

Expand Down
61 changes: 47 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ $ npm install whatsapp-chat-parser

## Usage

### Node

```javascript
const fs = require('fs');
const whatsapp = require('whatsapp-chat-parser');

const fileContents = fs.readFileSync('path/to/file.txt', 'utf8');

whatsapp
.parseFile('path/to/file.txt')
.parseString(fileContents)
.then(messages => {
// Do whatever you want with messages
})
Expand All @@ -25,6 +30,33 @@ whatsapp
});
```

### Browser

Add the script to your HTML file (usually just before the closing `</body>` tag).
Then use it in your JavaScript code, the `whatsappChatParser` variable will be globally available.

```html
<script src="path/to/whatsapp-chat-parser.min.js"></script>
<script>
whatsappChatParser
.parseString('06/03/2017, 00:45 - Sample User: This is a test message')
.then(messages => {
// Do whatever you want with messages
})
.catch(err => {
// Something went wrong
});
</script>
```

You can also use the [jsDelivr CDN](https://www.jsdelivr.com/package/npm/whatsapp-chat-parser).

```html
<script src="https://cdn.jsdelivr.net/npm/whatsapp-chat-parser/dist/whatsapp-chat-parser.min.js"></script>
```

&nbsp;

The `messages` variable is an array of objects like this:

```javascript
Expand Down Expand Up @@ -56,18 +88,6 @@ In the case of a system message, the author will be `System`

## API

### parseFile(filepath, [options]) → Promise

**filepath**

Type: `string`

Path to the file to parse.

**options**

Type: `object`

### parseString(string, [options]) → Promise

**string**
Expand All @@ -88,6 +108,12 @@ Type: `object`
| 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`](src/date.js) for the implementation), if all fails it defaults to interpret the first digit as the day. |
<!-- prettier-ignore-end -->

## How to export WhatsApp chats

- [Android](https://faq.whatsapp.com/en/android/23756533/)
- [iPhone](https://faq.whatsapp.com/en/iphone/20888066/#email)
- [Windows Phone](https://faq.whatsapp.com/en/wp/22548236)

## Technologies used

- Testing: [Jest](https://jestjs.io/)
Expand All @@ -96,7 +122,14 @@ Type: `object`

## Requirements

`Node.js >= 8.0.0`
### Node

`Node.js >= 8.3.0`

### Browser

This package is written in ES6 and transpiled to ES5.
It should work in all relevant browsers but at the moment I have no time to test it and provide an official compatibility table. So no guarantees, sorry.

## Changelog

Expand Down
Loading

0 comments on commit 60fbd4e

Please sign in to comment.