README
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.
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'
// }
option
argument accepts a string with the following options:
➔ The optional Counts only the characters:
or -c--chars
lc.count('-c', "Hamburg - \nGermany 137!");
//=> { origin: 'Hamburg - \nGermany 137!', chars: 23 }
Counts only the lines:
or -ln--lines
lc.count('-ln', "Hamburg - \nGermany 137!");
//=> { origin: 'Hamburg - \nGermany 137!', lines: 2 }
Counts only the characters:
or -w--words
lc.count('-w', "Hamburg - \nGermany 137!");
//=> { origin: 'Hamburg - \nGermany 137!', words: 2 }
Counts only the numbers:
or -n--numbers
lc.count('-n', "Hamburg - \nGermany 137!");
//=> { origin: 'Hamburg - \nGermany 137!', numbers: 3 }
Counts only the letters:
or -l--letters
lc.count('-l', "Hamburg - \nGermany 137!");
//=> { origin: 'Hamburg - \nGermany 137!', letters: 14 }
MD5 hash:
or -hs--hash
lc.count('-hs', "Hamburg - \nGermany 137!");
//=> { origin: 'Hamburg - \nGermany 137!', hash: '6bee63bbc6c56f61fbfd19f1429ad4a3' }
Counts only the words sings:
or -ws--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'
// }
option
argument accepts a string with the following options:
➔ The optional Counts only the characters:
or -c--chars
lc.countFromFile('--chars', '/path/to/file.txt');
//=> { origin: 'Hamburg - \nGermany 137!', chars: 23 }
Counts only the lines:
or -ln--lines
lc.countFromFile('--lines', '/path/to/file.txt');
//=> { origin: 'Hamburg - \nGermany 137!', lines: 2 }
Counts only the words:
or -w--words
lc.countFromFile('--words', '/path/to/file.txt');
//=> { origin: 'Hamburg - \nGermany 137!', words: 2 }
Counts only the numbers:
or -n--numbers
lc.countFromFile('--numbers', '/path/to/file.txt');
//=> { origin: 'Hamburg - \nGermany 137!', numbers: 3 }
Counts only the letters:
or -l--letters
lc.countFromFile('--letters', '/path/to/file.txt');
//=> { origin: 'Hamburg - \nGermany 137!', letters: 14 }
Counts only the word signs:
or -ws--wordsigns
lc.countFromFile('--wordsigns', '/path/to/file.txt');
//=> { origin: 'Hamburg - \nGermany 137!', wordsigns: 2 }
MD5 hash:
or -hs--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'
// }
option
argument accepts a string with the following options:
➔ The optional Returns only the project name:
or -n--name
lc.info('--name');
//=> letter-count
Returns only the project version:
or -v--version
lc.info('--version');
//=> 3.2.0
Returns only the project description:
or -d--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:
or -a--author
lc.info('--author');
//=> {
// name: 'Tom S.', email: 'thoschulte@gmail.com' }
Returns only the project license:
or -l--license
lc.info('--license');
//=> MIT
letter-count
binary
Using the letter-count
binary in your shell, simply install letter-count globally using npm:
To use the $ 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"}
-c
/--char
option:
To count only the character, use the the $ letter-count -c hamburg
#=> 1 Jan 23:59:59 - hamburg : {"chars": 7, "origin": "hamburg"}
-ln
/--lines
option:
To count only the lines, use the the $ letter-count -ln tom s.
#=> 1 Jan 12:00:00 - tom s. : {"lines": 1, "origin": "tom s."}
-w
/--words
option:
To count only the words, use the the $ letter-count -w tom hamburg
#=> 1 Jan 12:00:00 - tom hamburg : {"words": 2, "origin": "tom hamburg"}
-w
/--words
option:
To count only the words, use the the $ letter-count -hs tom
#=> 1 Jan 12:00:00 - tom hamburg : {"words": 2, "origin": "tom hamburg"}
-n
/--numbers
option:
To count only the numbers, use the the $ letter-count -n hamburg 20457
#=> 1 Jan 12:00:00 - hamburg 20457 : {"numbers": 5, "origin": "hamburg 20457"}
-l
/--letters
option:
To count only the letters, use the the $ letter-count -l tom 13 hh
#=> 1 Jan 12:00:00 - tom 13 hh : {"letters": 5, "origin": "tom 13 hh"}
-ws
/--wordsigns
option:
To count only the wordsigns, use the the $ letter-count -ws germany!
#=> 1 Jan 12:00:00 - germany! : {"wordsigns": 1, "origin": "germany!"}
-hs
/--hash
option:
To get a hash, use the the $ letter-count -hs hamburg
#=> 1 Jan 12:00:00 - hamburg : {"hash": "f23bb5e2f7d35c767b40eddd42ac0e08", "origin": "hamburg"}
-i
/--interactive
option:
To count in interactive mode, use the the $ 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"}
-f
/--file
option and the path to the file:
To count in a file, use the the $ 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
RinKit
https://npm.runkit.com/letter-count
Links
License
This library is available under the MIT license.