letter-count

This is a calculator which counts the number of letters/ characters/ lines/ words/ numbers or wordsigns in a text, useful for your tweets on Twitter, as well as a multitude of other applications.

Usage no npm install needed!

<script type="module">
  import letterCount from 'https://cdn.skypack.dev/letter-count';
</script>

README

letter-count

npm version Dependency Status Dev Dependency Status Build Status Coverage Status Code Climate Known Vulnerabilities GitHub issues GitHub license

NPM Badge

This is a calculator which counts the number of letters/ characters/ lines/ words/ numbers or wordsigns in a text, useful for your tweets on Twitter, as well as a multitude of other applications.

Whether it is Snapchat, Twitter, Facebook, Yelp or just a note to co-workers or business officials, the number of actual characters matters. What you say may not be as important as how you say it. And how many characters you use.

The idea of this project arose during the development of a game | OpenAPI, while my brother accompanied me for one day in the agency to register the incurrence of free improvised software. So, this is a project that also has been started because of my interests in modelling digital logic and data.

Installation

Via npm:

$ npm install letter-count

In Node.js:

const lc = require('letter-count');

API

lc.count([option], value)

const Log = console.log;

Log(lc.count("Hamburg - \nGermany 137!")); 
//=> { 
//      origin: 'Hamburg - \nGermany 137!', 
//      chars: 23, 
//      lines: 2, 
//      words: 2, 
//      numbers: 3, 
//      option: '-a',
//      letters: 14, 
//      wordsigns: 2, 
//      hash: 'd559d4e0ad0770ec6940e6892a9c921b' 
//  }

➔ The optional option argument accepts a string with the following options:

Counts only the characters:

-c or --chars
lc.count('-c', "Hamburg - \nGermany 137!"); 
//=> { origin: 'Hamburg - \nGermany 137!', chars: 23 }

Counts only the lines:

-ln or --lines
lc.count('-ln', "Hamburg - \nGermany 137!"); 
//=> { origin: 'Hamburg - \nGermany 137!', lines: 2 }

Counts only the characters:

-w or --words
lc.count('-w', "Hamburg - \nGermany 137!"); 
//=> { origin: 'Hamburg - \nGermany 137!', words: 2 }

Counts only the numbers:

-n or --numbers
lc.count('-n', "Hamburg - \nGermany 137!"); 
//=> { origin: 'Hamburg - \nGermany 137!', numbers: 3 }

Counts only the letters:

-l or --letters
lc.count('-l', "Hamburg - \nGermany 137!"); 
//=> { origin: 'Hamburg - \nGermany 137!', letters: 14 }

MD5 hash:

-hs or --hash
lc.count('-hs', "Hamburg - \nGermany 137!"); 
//=> { origin: 'Hamburg - \nGermany 137!', hash: '6bee63bbc6c56f61fbfd19f1429ad4a3' }

Counts only the words sings:

-ws or --wordsigns
lc.count('-ws', "Hamburg - \nGermany 137!"); 
//=> { origin: 'Hamburg - \nGermany 137!', wordsigns: 2 }

lc.countFromFile([option], file)

const Log = console.log;

Log(lc.countFromFile('/path/to/file.txt')); 
//=> { 
//      origin: 'Hamburg - \nGermany 137!', 
//      chars: 23, 
//      lines: 2, 
//      words: 2, 
//      numbers: 3, 
//      option: '-a',
//      letters: 14,
//      wordsigns: 2, 
//      hash: 'd559d4e0ad0770ec6940e6892a9c921b' 
// }

➔ The optional option argument accepts a string with the following options:

Counts only the characters:

-c or --chars
lc.countFromFile('--chars', '/path/to/file.txt'); 
//=> { origin: 'Hamburg - \nGermany 137!', chars: 23 }

Counts only the lines:

-ln or --lines
lc.countFromFile('--lines', '/path/to/file.txt'); 
//=> { origin: 'Hamburg - \nGermany 137!', lines: 2 }

Counts only the words:

-w or --words
lc.countFromFile('--words', '/path/to/file.txt'); 
//=> { origin: 'Hamburg - \nGermany 137!', words: 2 }

Counts only the numbers:

-n or --numbers
lc.countFromFile('--numbers', '/path/to/file.txt'); 
//=> { origin: 'Hamburg - \nGermany 137!', numbers: 3 }

Counts only the letters:

-l or --letters
lc.countFromFile('--letters', '/path/to/file.txt'); 
//=> { origin: 'Hamburg - \nGermany 137!', letters: 14 }

Counts only the word signs:

-ws or --wordsigns
lc.countFromFile('--wordsigns', '/path/to/file.txt'); 
//=> { origin: 'Hamburg - \nGermany 137!', wordsigns: 2 }

MD5 hash:

-hs or --hash
lc.countFromFile('--hash', '/path/to/file.txt'); 
//=> { origin: 'Hamburg - \nGermany 137!', hash: '6bee63bbc6c56f61fbfd19f1429ad4a3' }

lc.info([option])

const Log = console.log;

Log(lc.info()); 
//=>  { 
//      name: 'letter-count',
//      version: '3.2.0',
//      description: 'This is a calculator which counts the number of letters/ characters/ lines/ words/ numbers or wordsigns in a text, useful for your tweets on Twitter, as well as a multitude of other applications.',
//      author: { 
//          name: 'Tom S.', 
//          email: 'thoschulte@gmail.com' 
//      },
//      license: 'MIT' 
//  }

➔ The optional option argument accepts a string with the following options:

Returns only the project name:

-n or --name
lc.info('--name'); 
//=> letter-count

Returns only the project version:

-v or --version
lc.info('--version'); 
//=> 3.2.0

Returns only the project description:

-d or --description
lc.info('--description'); 
//=> e.g. This is a calculator which counts the number of letters/ characters/ lines/ words/ numbers or wordsigns in a text, useful for your tweets on Twitter, as well as a multitude of other applications.

Returns only the project author:

-a or --author
lc.info('--author'); 
//=> { 
// name: 'Tom S.', email: 'thoschulte@gmail.com' }

Returns only the project license:

-l or --license
lc.info('--license'); 
//=> MIT

Using the letter-count binary

To use the letter-count binary in your shell, simply install letter-count globally using npm:

$ npm install -g letter-count 

After that you’re able to count from the command line:

$ letter-count hamburg 
#=> 1 Jan 23:59:59 - hamburg : {"chars": "7", "hash": "f23bb5e2f7d35c767b40eddd42ac0e08", "letters": "7", "lines": "1", "numbers": "0", "options": "-a", "origin": "hamburg", "words": "1", "wordsigns": "0"}
To count only the character, use the the -c/--char option:
$ letter-count -c hamburg 
#=> 1 Jan 23:59:59 - hamburg : {"chars": 7, "origin": "hamburg"}
To count only the lines, use the the -ln/--lines option:
$ letter-count -ln tom s. 
#=> 1 Jan 12:00:00 - tom s. : {"lines": 1, "origin": "tom s."}
To count only the words, use the the -w/--words option:
$ letter-count -w tom hamburg 
#=> 1 Jan 12:00:00 - tom hamburg : {"words": 2, "origin": "tom hamburg"}
To count only the words, use the the -w/--words option:
$ letter-count -hs tom
#=> 1 Jan 12:00:00 - tom hamburg : {"words": 2, "origin": "tom hamburg"}
To count only the numbers, use the the -n/--numbers option:
$ letter-count -n hamburg 20457
#=> 1 Jan 12:00:00 - hamburg 20457 : {"numbers": 5, "origin": "hamburg 20457"}
To count only the letters, use the the -l/--letters option:
$ letter-count -l tom 13 hh
#=> 1 Jan 12:00:00 - tom 13 hh : {"letters": 5, "origin": "tom 13 hh"}
To count only the wordsigns, use the the -ws/--wordsigns option:
$ letter-count -ws germany!
#=> 1 Jan 12:00:00 - germany! : {"wordsigns": 1, "origin": "germany!"}
To get a hash, use the the -hs/--hash option:
$ letter-count -hs hamburg
#=> 1 Jan 12:00:00 - hamburg : {"hash": "f23bb5e2f7d35c767b40eddd42ac0e08", "origin": "hamburg"}
To count in interactive mode, use the the -i/--interactive option:
$ letter-count -i
$ Input please: hamburg
$ Option please: -a       
#=> 1 Jan 12:00:00 - hamburg : {"chars": "7", "hash": "f23bb5e2f7d35c767b40eddd42ac0e08", "letters": "7", "lines": "1", "numbers": "0", "option": "-a", "origin": "hamburg", "words": "1", "wordsigns": "0"}
To count in a file, use the the -f/--file option and the path to the file:
$ letter-count -f path/to/file/input.txt
#=> 1 Jan 12:00:00 - test/input.txt : {"chars": 23, "hash": "fdf25c637725818100fae9d635edf787", "letters": 14, "lines": 2, "numbers": 3, "origin": "Hamburg -\r\nGermany 137!", "words": 2, "wordsigns": 2}

NPM

https://npmjs.com/package/letter-count


Doc

jsdoc logo


RinKit

https://npm.runkit.com/letter-count


Links

Author

RTL - Games

ShieldsIO


License

This library is available under the MIT license.