Global

Methods

# applyOptions(text, caseSensitiveopt, spaceopt) → {string|Array}

Apply options to text or array of text
Parameters:
Name Type Attributes Default Description
text string | Array The text you want to apply options on
caseSensitive boolean <optional>
false true = case sensitive. false = case insensitive. Default is false
space boolean <optional>
false true = space is count. false = space is not count as character. Default is false

View Source utilities.ts, line 77

text with options applied
string | Array
Example

Object compares

applyOptions("Race car") // 'racecar'
applyOptions(["Car", "Race car"]) // [ 'car', 'racecar' ]
applyOptions("Race car", {caseSensitive: true}) // 'Racecar'
applyOptions("Race car", {space: true}) // 'race car'

# areAnagram(word1, word2, optionsopt) → {boolean}

Check if word given are anagram
Parameters:
Name Type Attributes Default Description
word1 string First word
word2 string Second word
options Object <optional>
Options for customization
caseSensitive boolean <optional>
false true = case sensitive. false = case insensitive. Default is false
space boolean <optional>
false true = space is count. false = space is not count as character. Default is false

View Source index.ts, line 83

is two words are anagram
boolean
Examples

Check if two words are anagram

areAnagram("mything", "My night") // true

Check if two words are anagram with options

areAnagram("Thing", "Night", {caseSensitive: true}) // false

# compare(a, b) → {boolean}

Look for same key & value from a into b. In other words, check if a is part of b
Parameters:
Name Type Description
a Object Object key and value to look for
b Object Object key and value to look into

View Source utilities.ts, line 30

true if a is part of b
boolean
Example

Object compares

compare({a: 1}, {a: 1}) // true
compare({a: 1}, {a: 2}) // false
compare({a: 1}, {a: 1, b: 1}) // true
compare({a: 1}, {a: 2, b: 1}) // false
compare({a: 1}, {b: 1}) // false

# createHash(pattern, text) → {Object}

Create only fisrt hashmap of each character in pattern, text would have hashmap length as pattern hasmap length
Parameters:
Name Type Description
pattern string Pattern string
text string Text string

View Source utilities.ts, line 48

Object {pw, tw} hashmap of character as key and character count as value
Object
Example

Object compares

createHash("car", "race car") // { pw: { c: 1, a: 1, r: 1 }, tw: { r: 1, a: 1, c: 1 } }
createHash("car", "eve") // { pw: { c: 1, a: 1, r: 1 }, tw: { e: 2, v: 1 } }

# findPattern(pattern, text, optionsopt) → {Array}

Return anagram words/sequences from the given string if any
Parameters:
Name Type Attributes Default Description
pattern string The sequence string you look for in in the text
text string The whole string you want to look for the pattern
options Object <optional>
Options for customization
caseSensitive boolean <optional>
false true = case sensitive. false = case insensitive. Default is false
space boolean <optional>
false true = space is count. false = space is not count as character. Default is false
unique boolean <optional>
false true = return only unique sequence. false = return all sequence. Default is false

View Source index.ts, line 21

anagram words/sequences
Array
Examples

Find anagram pattern in a sentence

findPattern("car", "race car care") // [ 'rac', 'car', 'arc', 'rca', 'car' ]

Find anagram pattern with options

findPattern("car", "race car care", {space: true, unique: true}) // [ 'rac', 'car' ]

# isPalindrome(word, optionsopt) → {boolean}

Check if word is palindrome
Parameters:
Name Type Attributes Default Description
word string The word to check
options Object <optional>
Options for customization
caseSensitive boolean <optional>
false true = case sensitive. false = case insensitive. Default is false
space boolean <optional>
false true = space is count. false = space is not count as character. Default is false

View Source index.ts, line 58

is the word palindrome
boolean
Examples

Check if word is palindrome

isPalindrome("Race car") // true

Check if word is palindrome with options

isPalindrome("Racecar", {caseSensitive: true}) // false

# removeSpaces(text) → {string}

Return new text without spaces
Parameters:
Name Type Description
text string The text where spaces will be removed

View Source utilities.ts, line 12

new text without spaces
string
Example

Remove all spaces

removeSpaces("race car") // 'racecar'

Type Definitions

object

# Hash

Hash
Properties:
Name Type Description
{...} number key is a character, the value is the count of the character

View Source utilities.ts, line 103

object

# Options

Options
Properties:
Name Type Attributes Description
caseSensitive boolean <optional>
if true, text is case sensitive
space boolean <optional>
if true, spaces in text are counted as a character
unique boolean <optional>
if true, returned array result will be unique

View Source utilities.ts, line 95