A very powerful words counter that supports plain text and html.
npm install word-counting



[![NPM Version][npm-image]][npm-url]
[![License Stats][npm-license]][npm-url]
[![Downloads Stats][npm-downloads]][npm-url]
[![Github stars][github-stars]][github-url]
[![Github issues][github-issues]][github-issues-url]




> A very powerful words counter that supports plain text and html.
[![nodei.co][npm-io]][npm-url]
- Word counting
- Why this project
- Installation
- Basic Usage
- Contributing
- Contributors
- Support node and browser environment.
- Support html formated text. (Won't count tags)
- Well typed
``shellUsing npm
npm install --save word-counting
Basic Usage
Inject the library in your file:
`javascript
// javascript
var wordsCounter = require('word-counting')
``typescript
// typescript
import wordsCounter from 'word-counting'
`Count the words for plain text:
`typescript
const mockedText = 'These are some mocked words.'
console.log(wordsCounter(mockedText).wordsCount) // 5
`Count the words for html:
`typescript
const mockedText = 'These are some mocked words with html format
'
console.log(wordsCounter(mockedText, { isHtml: true }).wordsCount) // 8
`Contributing
1. Fork it ()
2. Create your feature branch (
git checkout -b feature/fooBar)
3. Commit your changes (git commit -am 'Add some fooBar')
4. Push to the branch (git push origin feature/fooBar`)[npm-image]: https://img.shields.io/npm/v/word-counting.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/word-counting
[npm-license]: https://img.shields.io/npm/l/word-counting.svg
[npm-downloads]: https://img.shields.io/npm/dm/word-counting.svg?style=flat-square
[github-url]: https://github.com/nerdmax/word-counting
[github-issues]: https://img.shields.io/github/issues/nerdmax/word-counting.svg
[github-issues-url]: https://github.com/nerdmax/word-counting/issues
[github-stars]: https://img.shields.io/github/stars/nerdmax/word-counting.svg
[travis-image]: https://img.shields.io/travis/dbader/node-word-counting/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/dbader/node-word-counting
[npm-io]: https://nodei.co/npm/word-counting.png?downloads=true&downloadRank=true&stars=true
[wiki]: https://github.com/nerdmax/word-counting/wiki
|
Max Liu
💻 📖 🚇") ⚠️ |
| :---: |
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!