Wordify
A set of utilities for authors to get meta data from content and generally to play with words.
Usage
var wordify = ;
list
Get a unique list of words from content.
var list = wordify;
Result:
"array" "did" "i" "list" "lots" "make" "of" "returns" "say" "to" "unique" "with" "words"
stats
Returns an object with words and occurrances
var words = wordify;
Returns:
the: count: 7 man: count: 3 sat: count: 1 on: count: 1 cat: count: 4
chunk
Break copy up based on the number of words you want in each chunk. Pass in the copy to be chunked, and the number of words in each chunk. Returns an array of strings.
wordify
Returns:
"this should be in first element," "this should be in second element"
wave
Break copy up in varying lengths forming a "wave". Lengths are characters to break into chunks at lengths specified. The length is used to find the closest space. Sizes go up, and then down, and repeated.
wordify
Returns:
"the" "cat sat" "on the mat"
count
Count the number of words in a string, removing any HTML and punctuation
var count = wordify;
Returns:
3
charCount
Returns the length of characters in a string. It strips out html and punctuation marks.
charCountWithCharacters
Returns the length of characters in a string including punctuation marks.