jaaJSU - v2.0.0 / $string
This NAMESPACE provides features for strings.
Version
2.0.0
- clearHTML
- clearSpaces
- concatLeft
- concatRight
- containsRepeatingChars
- containsSequential
- countChars
- escapeHTML
- generateUnique
- getSubstring
- isEmail
- isFilled
- letterInc
- template
- toCamelCase
▸ clearHTML(str
): string
Clear tags from str
Name | Type |
---|---|
str |
string |
string
Text without HTML tags
▸ clearSpaces(str
): string
Clear spaces (\s+
) in str
Deprecated
Use String.prototype.replace
OR String.prototype.replaceAll
Name | Type |
---|---|
str |
string |
string
▸ concatLeft(text_right
): (text_left
: string
) => string
Curried function for joining text: text_right=> text_left=> text_left+text_right
Name | Type |
---|---|
text_right |
string |
fn
▸ (text_left
): string
Name | Type |
---|---|
text_left |
string |
string
▸ concatRight(text_left
): (text_right
: string
) => string
Curried function for joining text: text_left=> text_right=> text_left+text_right
Name | Type |
---|---|
text_left |
string |
fn
▸ (text_right
): string
Name | Type |
---|---|
text_right |
string |
string
▸ containsRepeatingChars(str
, quantity?
): boolean
console.log($string.containsRepeatingChars("AAbcd"));//=false
console.log($string.containsRepeatingChars("AAAbcd"));//=true
console.log($string.containsRepeatingChars("AAAbcd", 3));//=false
Name | Type | Description |
---|---|---|
str |
string |
- |
quantity? |
number |
(By default 2 ) |
boolean
▸ containsSequential(str
, quantity?
): boolean
console.log($string.containsSequential("ABccc"));//=false
console.log($string.containsSequential("ABCdd"));//=true
console.log($string.containsSequential("ABCdd", 3));//=false
Name | Type | Description |
---|---|---|
str |
string |
- |
quantity? |
number |
(By default 2 ) |
boolean
▸ countChars(str
): number
Number of chars in str
Name | Type |
---|---|
str |
string |
number
▸ escapeHTML(str
): string
Escapes "<", ">", "&", '"', "'"
Name | Type |
---|---|
str |
string |
string
▸ generateUnique(): string
An unique string
string
▸ getSubstring(str
, len
, start?
): string
Wrapper around *.substring(*,*)
Deprecated
Use String.prototype.split
Name | Type | Description |
---|---|---|
str |
string |
- |
len |
number |
How many chars |
start? |
number |
(By default 0 ) |
string
Substring of str
▸ isFilled(str
): boolean
Wrapper around *.trim()
Name | Type |
---|---|
str |
string |
boolean
▸ letterInc(str
, inc?
, pos?
): string
New string with "highter" letter on position pos
console.log($string.letterInc("125"));//="126"
console.log($string.letterInc("125a"));//="125b"
console.log($string.letterInc("HH"));//="HI"
console.log($string.letterInc("Hg", 2, 1));//="Hi"
Name | Type | Description |
---|---|---|
str |
string |
[a-zA-z] at least on position pos |
inc? |
number |
(By default 1 ) inc=0 is convert to inc=1 |
pos? |
number |
(By default str.length-1 ) |
string
▸ template(str
, keysFun?
): TemplateString
Alternative to ```text with ${variable}```
(something like sprintf()
)
const test1= $string.template("${0}, ${1}, ${2}");
console.log(test1.partial(["A"]));//="A, ${1}, ${2}"
console.log(test1.execute(["B", "C", "D"]));//="A, C, D"
console.log(test1.isSubstituted());//=false
console.log(test1.partial(["_", "B", "C"]));//="A, B, C"
console.log(test1.isSubstituted());//=true
const test2= $string.template("${test0}, ${test1}, ${test2}");
console.log(test2.partial({test0: "A"}));//="A, ${test1}, ${test2}"
console.log(test2.execute({test0: "B", test1: "C", test2: "D"}));//="A, C, D"
console.log(test2.isSubstituted());//=false
console.log(test2.partial({test0: "_", test1: "B", test2: "C"}));//="A, B, C"
console.log(test2.isSubstituted());//=true
Name | Type | Description |
---|---|---|
str |
string |
String in the form text…${key}… . |
keysFun? |
(o : Object ) => PropertyKey [] |
If defined, used to filter keys in *.execute method. |
▸ toCamelCase(str
): string
Converts string to camel case format "peter"=>"Peter"
Name | Type |
---|---|
str |
string |
string
▸ isEmail(email_candidate
): boolean
Name | Type |
---|---|
email_candidate |
string |
boolean