Namespace atropa.string
A few utilities for manipulating strings.
Defined in: <node_modules/atropa-string/src/atropa-string.js>.
Constructor Attributes | Constructor Name and Description |
---|---|
A few utilities for manipulating strings.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
atropa.string.camelize(string)
Converts the given string to camel case.
|
<static> |
atropa.string.convertEol(text, newEOL)
Converts end of line markers into whatever you want.
|
<static> |
atropa.string.countWords(someText)
Counts words.
|
<static> |
atropa.string.escapeCdata(text)
Escapes
CDATA sections in text
so that the text may be embedded into a
CDATA section. |
<static> |
atropa.string.getOffset(text)
Counts the number of leading space or tab characters but not both.
|
<static> |
atropa.string.getWords(text)
Breaks a string into an array of words.
|
<static> |
atropa.string.lineBreaksToBreakTags(string)
Creates break tags at every line break.
|
<static> |
atropa.string.lineBreaksToParagraphTags(string)
Creates paragraph breaks at every occurrence of two consecutive line breaks.
|
<static> |
atropa.string.normalizeEol(string)
Normalizes line breaks to `\n`.
|
<static> |
atropa.string.normalizeWhiteSpace(text)
Converts all tabs into four spaces.
|
<static> |
atropa.string.normalizeWhiteSpacePrefix(text)
Converts all tabs in leading whitespace into four spaces.
|
<static> |
atropa.string.offsetWhiteSpace(text, offset)
Removes a quantity of leading spaces specified by offset.
|
<static> |
atropa.string.removeRepeatedWord(string)
Replaces repeated words and phrases with a single word or phrase.
|
<static> |
atropa.string.ucFirst(string)
Converts the first character of a given string to
uppercase.
|
Namespace Detail
atropa.string
A few utilities for manipulating strings.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
- Requires:
- atropa.regex.patterns
Method Detail
<static>
{String}
atropa.string.camelize(string)
Converts the given string to camel case.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
atropa.string.camelize('get it together'); // returns "getItTogether"
- Parameters:
- {String} string
- The string to camelize.
- Returns:
- {String} The camelized string.
<static>
{String}
atropa.string.convertEol(text, newEOL)
Converts end of line markers into whatever you want.
Automatically detects any of \r\n, \n, or \r and
replaces it with the user specified EOL marker.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
- Parameters:
- {String} text
- The text you want processed.
- {String} newEOL
- The replacement for the current EOL marks.
- Returns:
- {String} Returns the processed text.
<static>
{Number}
atropa.string.countWords(someText)
- Parameters:
- {String} someText
- Plain text.
- Returns:
- {Number} Returns the count of words in someText.
<static>
{Array}
atropa.string.escapeCdata(text)
Escapes
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
CDATA
sections in text
so that the text may be embedded into a
CDATA
section. This should be run
on any text which may contain the string
]]>
since said string will effectively
end the CDATA
section prematurely.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
- Parameters:
- {String} text
- The text containing
CDATA
sections to escape.
- Returns:
- {Array} Returns a string with escaped
CDATA
sections.
<static>
{Number}
atropa.string.getOffset(text)
Counts the number of leading space or tab characters but not both.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
- Parameters:
- {String} text
- The text to analyze.
- Returns:
- {Number} Returns the quantity of leading spaces or tabs.
<static>
{Array}
atropa.string.getWords(text)
Breaks a string into an array of words.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
- Parameters:
- {String} text
- The text to analyze.
- Returns:
- {Array} Returns an array of the words in the given text.
- Requires:
- atropa.arrays.removeEmptyElements
<static>
{String}
atropa.string.lineBreaksToBreakTags(string)
Creates break tags at every line break.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
- Parameters:
- {String} string
- The string to insert break tags into.
- Returns:
- {String} Returns the given string with break tags inserted.
<static>
{String}
atropa.string.lineBreaksToParagraphTags(string)
Creates paragraph breaks at every occurrence of two consecutive line breaks.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
- Parameters:
- {String} string
- The string to insert paragraph tags into.
- Returns:
- {String} Returns the given string with paragraph breaks inserted.
<static>
{String}
atropa.string.normalizeEol(string)
- Parameters:
- {String} string
- The string to normalize.
- Returns:
- {String} Returns the given string with normalized line breaks.
<static>
{String}
atropa.string.normalizeWhiteSpace(text)
- Parameters:
- {String} text
- The text to process
- Returns:
- {String} Returns the processed text.
<static>
{String}
atropa.string.normalizeWhiteSpacePrefix(text)
Converts all tabs in leading whitespace into four spaces.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
- Parameters:
- {String} text
- The text to process
- Returns:
- {String} Returns the processed text.
<static>
atropa.string.offsetWhiteSpace(text, offset)
Removes a quantity of leading spaces specified by offset.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
- Parameters:
- {String} text
- The text to process.
- {Number} offset
- The amount of spaces you want removed from the beginning of the text.
- Returns:
- Returns the processed text.
<static>
{String}
atropa.string.removeRepeatedWord(string)
Replaces repeated words and phrases with a single word or phrase.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
- Parameters:
- {String} string
- The string to remove repeated words from.
- Returns:
- {String} Returns the given string with repeated words and phrases removed.
<static>
{String}
atropa.string.ucFirst(string)
Converts the first character of a given string to
uppercase.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
Author: Matthew Christopher Kastor-Inare III
☭ Hial Atropa!! ☭.
- Parameters:
- {String} string
- The string for which you want the first letter to be in upper case.
- Returns:
- {String} The given string with it's first letter capitalized.