Given an epub file, do our best to count the number of words in it.
epub =epub// There are 106190 words
There's also a cli tool to quickly get the count of any epub file! Invoke it via:
word-count -h for more info
There's no programmatic representation for the table of contents in epub and it's hard to skip over the reviews, copyright, etc. We do our best to guess what's actually story text, but there's a margin of error. Probably no more than ~500 words.
Pull requests welcome.
countWords(path, [options]) => Promise<number>
Path to (what is hopefully) an epub file. Opens it, and returns a promise that resolves to the number of words in the book.
Object of options. It's optional, I don't know your life.
|boolean||print a nice message with data included for each file||false|
|sturdy||boolean||bravely ignore errors on missing or malformed epub file||false|
|quiet||boolean||stifle errors in parsing chapters||false|
... are for code that doesn't work on the first try (which this undoubtedly doesn't) so please let me know if you see something wrong.