Takes a string and returns with the first character capitalized
Basic usage example:
import {words} from 'stringman'; // or const words = require('stringman').words;
const cap = words.capitalize('test');
const failure = words.capitalize(true);
console.log(test); // 'Test'
console.log(failure); // null
Takes word count, image count, boolean for valueOnly which will return only the minutes if set to 'true', and optionally a words per minute value (defaults to 270) and returns estimated reading time
import {words} from 'stringman'; // or const words = require('stringman').words;
const wordCount = 1200;
const imageCount = 5;
const readTime = words.readingTime(wordCount, imageCount);
const readTimeValueOnly = words.readingTime(wordCount, imageCount, true);
const readTimeSpeedReader = words.readingTime(wordCount, imageCount, false, 400);
console.log(readTime); // '5 min read'
console.log(readTimeValueOnly); // 5
console.log(readTimeSpeedReader); // 4
Takes a string, the string to replace, the string to replace the other string with, and the optional boolean argument for case sensitivity and returns the original string with the 2nd argument replaced with the 3rd. Can return null if a failure happens along the way.
Basic usage example:
import {words} from 'stringman'; // or const words = require('stringman').words;
const test = 'We hope this works because we put some serious work into this and we are invested.';
const sens = words.replaceWord(test, 'we', 'they', true);
const ins = words.replaceWord(test, 'we', 'they');
const failure = words.replaceWord(test, 5, 'they');
console.log(sens); // 'They hope this works because they put some serious work into this and they are invested.'
console.log(ins); // 'they hope this works because they put some serious work into this and they are invested.'
console.log(failure); // null
Takes 2 strings and returns a number for the number of times the second string exists in the first string; optionally takes third boolean argument to make case sensitive
Basic usage example:
import {words} from 'stringman'; // or const words = require('stringman').words;
const insensitive = words.specificWordCount('Maybe-this will, trip it up! Will it? We WILL see.', 'will');
const sensitive = words.specificWordCount('Maybe-this will, trip it up! Will it? We WILL see.', 'will', true);
console.log(insensitive); // 3
console.log(sensitive); // 1
Takes a string and returns the number of words in the string as a number
Basic usage example:
import {words} from 'stringman'; // or const words = require('stringman').words;
const count = words.wordCount('This sentence has 4 words.');
const countAgain = words.wordCount('This sentence has five words.');
console.log(count); // 4
console.log(countAgain); // 5
Generated using TypeDoc
Takes a string, counts all instances of words in the string, and returns an object with each word and the number of occurences
Basic usage example: