1.2.0 • Published 4 years ago
tf_la_helpers v1.2.0
tf-LA- helpers
This package contains a few helper classes and functions created while attending the Launch Academy Boston 35 bootcamp.
So ... beware ... zero promises.
random(lower: {number}, upper: {number})
Returns a random integer number between of min lower and max upper
capitalize(string: {string})`
For a given string e.g. "hello world" returns "Hello world".
Str
A class that contains various methods that help working with strings.
Methods:
stringSortPredicate(isAsc: {Boolean} = true)- Returns a predicate for use in anArray.sortmethod.sortStrings(arr: {arr[]}, isAsc:{Boolean} = true, inPlace: {Boolean} = true)- Sorts string arrays either ascending or descending either in place or returning a shallow copy.pluralizeNoun(noun: {string})- has a bit of a go at converting a noun into its plural form using some (but by no means all) of the rules from Grammerly.
Question
A class for asking questions via window.prompt().
Initialized with:
question: {string}- The text to display in the prompt.'answerType: '{string}- The type of answer required - "string", "number", or "boolean". Default is "string".pattern: {RegExp}- The regular expression literal that a "string" answer must match to be valid. Default is/./matching all characters.min: {number}- Either the minium value for "number", orlengthfor a string. Default is zero.max: {number}- Either the maximum value for "number", orlengthfor a string. Default is Infinity.
Methods:
ask()- Ask a question viapromptand return the validated answer based on theQuestion's validation critera.
deduplicate()
deduplicate({any[]})- Returns a shallow copy of only the unique items in an provided array.