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.
Via npx:
$ npx letter-count "Hamburg - \nGermany 325!"
$ npx letter-count -int "Hamburg - \nGermany 325!"
Via yarn:
$ yarn add letter-count
Via npm:
$ npm install letter-count
import { count, countFromFile, info } from 'letter-count';
const lc = require('letter-count');
import { count } from 'letter-count';
const Log = console.log;
Log(count('Hamburg - \nGermany 137!'));
//=> {
// origin: 'Hamburg - \nGermany 137!',
// chars: 23,
// lines: 2,
// words: 2,
// numbers: 3,
// option: '-a',
// letters: 14,
// wordsigns: 2,
// hash: 'd559d4e0ad0770ec6940e6892a9c921b'
// }
const lc = require('letter-count');
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'
// }
// ECMAScript
count('Hamburg - \nGermany 137!', '-c');
// CommonJS
lc.count('Hamburg - \nGermany 137!', '--chars');
//=> { origin: 'Hamburg - \nGermany 137!', chars: 23 }
// ECMAScript
count('Hamburg - \nGermany 137!', '-ln');
// CommonJS
lc.count('Hamburg - \nGermany 137!', '--lines');
//=> { origin: 'Hamburg - \nGermany 137!', lines: 2 }
// ECMAScript
count('Hamburg - \nGermany 137!', '-w');
// CommonJS
lc.count('Hamburg - \nGermany 137!', '--words');
//=> { origin: 'Hamburg - \nGermany 137!', words: 2 }
// ECMAScript
count('Hamburg - \nGermany 137!', '-n');
// CommonJS
lc.count('Hamburg - \nGermany 137!', '--numbers');
//=> { origin: 'Hamburg - \nGermany 137!', numbers: 3 }
// ECMAScript
count('Hamburg - \nGermany 137!', '-int');
// CommonJS
lc.count('Hamburg - \nGermany 137!', '--integers');
//=> { origin: 'Hamburg - \nGermany 137!', integers: 1 }
// ECMAScript
count('Hamburg - \nGermany 13.7!', '-fl');
// CommonJS
lc.count('Hamburg - \nGermany 13.7!', '--floats');
//=> { origin: 'Hamburg - \nGermany 137!', floats: 1 }
// ECMAScript
count('Hamburg - \nGermany 13 7!', '-s');
// CommonJS
lc.count('Hamburg - \nGermany 13 7!', '--spaces');
//=> { origin: 'Hamburg - \nGermany 13 7!', spaces: 4 }
// ECMAScript
count('Hamburg - \nGermany 137!', '-l');
// CommonJS
lc.count('Hamburg - \nGermany 137!', '--letters');
//=> { origin: 'Hamburg - \nGermany 137!', letters: 14 }
// ECMAScript
count('Hamburg - \nGermany 137!', '-hs');
// CommonJS
lc.count('Hamburg - \nGermany 137!', '--hash');
//=> { origin: 'Hamburg - \nGermany 137!', hash: '6bee63bbc6c56f61fbfd19f1429ad4a3' }
// ECMAScript
count('Hamburg - \nGermany 137!', '-ws');
// CommonJS
lc.count('Hamburg - \nGermany 137!', '--wordsigns');
//=> { origin: 'Hamburg - \nGermany 137!', wordsigns: 2 }
โ no Browser support โ
import { countFromFile } from 'letter-count';
const Log = console.log;
Log(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'
// }
โ no Browser support โ
const lc = require('letter-count');
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'
// }
// ECMAScript
countFromFile('/path/to/file.txt', '-c');
// CommonJS
lc.countFromFile('/path/to/file.txt', '--chars');
//=> { origin: 'Hamburg - \nGermany 137!', chars: 23 }
// ECMAScript
countFromFile('/path/to/file.txt', '-ln');
// CommonJS
lc.countFromFile('/path/to/file.txt', '--lines');
//=> { origin: 'Hamburg - \nGermany 137!', lines: 2 }
// ECMAScript
countFromFile('/path/to/file.txt', '-w');
// CommonJS
lc.countFromFile('/path/to/file.txt', '--words');
//=> { origin: 'Hamburg - \nGermany 137!', words: 2 }
// ECMAScript
countFromFile('/path/to/file.txt', '-n');
// CommonJS
lc.countFromFile('/path/to/file.txt', '--numbers');
//=> { origin: 'Hamburg - \nGermany 137!', numbers: 3 }
// ECMAScript
countFromFile('/path/to/file.txt', '-int');
// CommonJS
lc.countFromFile('/path/to/file.txt', '--integers');
//=> { origin: 'Hamburg - \nGermany 137!', integers: 1 }
// ECMAScript
countFromFile('/path/to/file.txt', '-fl');
// CommonJS
lc.countFromFile('/path/to/file.txt', '--floats');
//=> { origin: 'Hamburg - \nGermany 13.7!', floats: 1 }
// ECMAScript
countFromFile('/path/to/file.txt', '-s');
// CommonJS
lc.countFromFile('/path/to/file.txt', '--spaces');
//=> { origin: 'Hamburg - \nGermany 13 7!', spaces: 4 }
// ECMAScript
countFromFile('/path/to/file.txt', '-l');
// CommonJS
lc.countFromFile('/path/to/file.txt', '--letters');
//=> { origin: 'Hamburg - \nGermany 137!', letters: 14 }
// ECMAScript
countFromFile('/path/to/file.txt', '-ws');
// CommonJS
lc.countFromFile('/path/to/file.txt', '--wordsigns');
//=> { origin: 'Hamburg - \nGermany 137!', wordsigns: 2 }
// ECMAScript
countFromFile('/path/to/file.txt', '-hs');
// CommonJS
lc.countFromFile('/path/to/file.txt', '--hash');
//=> { origin: 'Hamburg - \nGermany 137!', hash: '6bee63bbc6c56f61fbfd19f1429ad4a3' }
โ no Browser support โ
import { info } from 'letter-count';
const Log = console.log;
Log(info('author'));
//=> {
// author: {
// name: 'Tom S.',
// email: '[email protected]'
// }
// }
โ no Browser support โ
const lc = require('letter-count');
const Log = console.log;
Log(lc.info());
//=> {
// name: 'letter-count',
// version: '5.0.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: '[email protected]'
// },
// license: 'MIT'
// }
$ npx letter-count [option] "Hamburg - \nGermany 325!"
$ npm install -g letter-count
$ letter-count hamburg
#=> July 13, 2023 at 12:00:00 - hamburg : {"chars": "7", "hash": "f23bb5e2f7d35c767b40eddd42ac0e08", "letters": "7", "lines": "1", "numbers": "0", "option": "-a", "origin": "hamburg", "words": "1", "wordsigns": "0"}
$ letter-count -c hamburg
#=> July 13, 2023 at 12:00:00 - hamburg : {"chars": "7", "origin": "hamburg"}
$ letter-count -ln tom s.
#=> July 13, 2023 at 12:00:00 - tom s. : {"lines": "1", "origin": "tom s."}
$ letter-count -w tom hamburg
#=> July 13, 2023 at 12:00:00 - tom hamburg : {"origin": "tom hamburg", "words": "2"}
$ letter-count -n hamburg 20097
#=> July 13, 2023 at 12:00:00 - hamburg 20097 : {"numbers": "5", "origin": "hamburg 20097"}
$ letter-count -int hamburg 20097
#=> July 13, 2023 at 12:00:00 - hamburg 20097 : {"integers": "1", "origin": "hamburg 20097"}
$ letter-count -fl hamburg 13.7
#=> July 13, 2023 at 12:00:00 - hamburg 13.7 : {"floats": "1", "origin": "hamburg 13.7"}
$ letter-count -s hamburg tom npm
#=> July 13, 2023 at 12:00:00 - hamburg tom npm : {"spaces": "2", "origin": "hamburg tom npm"}
$ letter-count -l tom 13 hh
#=> July 13, 2023 at 12:00:00 - tom 13 hh : {"letters": "5", "origin": "tom 13 hh"}
$ letter-count -ws germany!
#=> July 13, 2023 at 12:00:00 - germany! : {"origin": "germany!", "wordsigns": "1"}
$ letter-count -hs hamburg
#=> July 13, 2023 at 12:00:00 - hamburg : {"hash": "f23bb5e2f7d35c767b40eddd42ac0e08", "origin": "hamburg"}
$ letter-count -f path/to/file/input.txt
#=> July 13, 2023 at 12:00:00 - path/to/file/input.txt : {"chars": "11", "hash": "374b094aaccf1fa849642a2de03d6dbe", "letters": "9", "lines": "2", "numbers": "0", "option": "-a", "origin": "foo\nbar baz", "words": "3", "wordsigns": "0"}
https://npmjs.com/package/letter-count
https://npm.runkit.com/letter-count
This library is available under the MIT license.