Skip to content

jo0ger/word-counter

Repository files navigation

@jooger/word-counter

styled with prettier Travis Coveralls Dev Dependencies

NPM NPM

A lib for counting your words and reading time

Install

// npm
$ npm install @jooger/word-counter

// yarn
$ yarn add @jooger/word-counter

Usage

import { wordCount, timeCalc } from '@jooger/word-counter'

const content = 'this 中文 is a 单词'

const count = wordCount(content, count => {
  return count * 2
}) // the origin count is 7, the transformed data is 14

const time = timeCalc(content, {
  cn: 300, // the number of cn words per minute read
  en: 160 // the number of en words per minute read
}) // time is 1

License

MIT