UNPKG

letter-count

Version:

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.

35 lines (30 loc) 745 B
/** * Module dependencies. */ const Fs = require('fs'), tasks = require('./src/tasks'); /** * letter-count.js module. * @module lib/index.js */ module.exports = { count: (input, option= '-a') => { return tasks.count(input, option); }, countFromFile: (filePath, options = '-a') => { let returnValue; try { let content = Fs.readFileSync(filePath, 'utf8'), input = content.toString(); returnValue = tasks.count(input, options); } catch (err) { returnValue = { info: `File: ${filePath} does not exist` }; } return returnValue; }, info: (key) => { return tasks.info(key); } };