strings
MMO.core · 24 symboles · générée le 27 Oct 2026
strings
strings.js:3- Espace de noms
MMO.core
Index
Constantes8
SPRINTF_FORMAT
strings.js:4HTML_ESCAPES
strings.js:8HTML_ESCAPES_REGEX
strings.js:16REG_CLEAR_START_ANCHOR
strings.js:18REG_CLEAR_END_ANCHOR
strings.js:19REG_CLEAR_ANCHORS
strings.js:20REG_CLEAR_NAMED_GROUP
strings.js:21REG_CLEAR_GLOBAL_PARENTHESIS
strings.js:22bytesize
strings.js:33Format a byte count as a human readable size (binary units, decimal prefixes).
- Espace de noms
MMO.core.strings
| bytes | number | |
| decimals = 2 | number | how many decimals to keep |
| retourne | string |
safeJsonEncode
strings.js:48Alias to JSON.stringify, safe for circular references WARNING: don't use to stringify content that will be decoded. All circular references are lost during this process.
- Espace de noms
MMO.core.strings
| value | * | |
| space | ||
| retourne |
toCamelCase
strings.js:66Convert words into a camel case valid string ex: font-weight => fontWeight
- Espace de noms
MMO.core.strings
| str | string | |
| retourne | string |
escapeHTML
strings.js:77Escape the characters that would otherwise be read as markup.
- Espace de noms
MMO.core.strings
| str | * | coerced to a string |
| retourne | string |
toBoolean
strings.js:90Read a boolean the way an html attribute or a query parameter carries it: the STRINGS '0', '', 'false' and 'FALSE' are false, unlike plain javascript truthiness.
- Espace de noms
MMO.core.strings
| value | * | |
| retourne | boolean |
generatePassword
strings.js:106Draw a random password, retrying until every required character class is present.
- Espace de noms
MMO.core.strings
| length = 10 | number | |
| withSpecialChar = true | boolean | require at least one of !@#$%^&* |
| withDigit = true | boolean | require at least one digit |
| withUpperCase = true | boolean | require at least one upper case letter |
| withLowerCase = true | boolean | require at least one lower case letter |
| retourne | string |
escapeRegex
strings.js:144Escape a part of a regex <MDN|https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping>
- Espace de noms
MMO.core.strings
| str | string | |
| retourne | string |
extractRegexSource
strings.js:154Extract regex source and clear some stuff
- Espace de noms
MMO.core.strings
| regex | RegExp | string | |
| flags = -1 | number | binary flags. Clearing options |
| retourne | string |
anyRegex
strings.js:187Create a regular expression that matches any of the regex.
- Espace de noms
MMO.core.strings
| regex | Array | a list of regular expression |
| min = false | ||
| max = false | ||
| anchorStart = true | ||
| anchorEnd = true | ||
| retourne | RegExp |
objectRegex
strings.js:221Create a regular expression for a serialized object, each properties separated by sep.
- Espace de noms
MMO.core.strings
| regexMap | object | a map of regular expressions |
| sep = '' | String | a separator between regex |
| required = true | Array | Boolean | a list of key in regexMap that are required to match in the string |
| retourne | RegExp |
listRegex
strings.js:275Create a regular expression for a serialized list, each properties separated by sep, not ordered.
- Espace de noms
MMO.core.strings
| regexMap | object | key: RexExp the regular expression to capture with the name for each group |
| sep = ',' | String | a separator between regex |
| required = false | Array | a list of required regex to match in the string |
| retourne | RegExp |
matchObject
strings.js:301Match a serialized object
- Espace de noms
MMO.core.strings- Voir
MMO.core.strings.objectRegex
| text | ||
| regexMap | ||
| sep = '' | ||
| required = true | ||
| retourne | null | object | null if any required key is missing |
matchList
strings.js:323Match a serialized list, with no defined order (any regular expression can match first) If some text is not contained in any captured, but the regex matches, this text is returned at the index '-1'
- Espace de noms
MMO.core.strings
| text | [type] | [description] |
| regexMap | [type] | [description] |
| sep = ',' | string | between regex |
| required = false | Array | keys of regexMap that MUST match |
| retourne | null | object | null if any required key is missing |
serialize
strings.js:382Convert any variable into a valid string
- Espace de noms
MMO.core.strings
| value | ||
| levelMax = 3 | ||
| hash = [] | ||
| hashValues = [] | ||
| retourne | string |
printf
strings.js:459- Espace de noms
MMO.core.strings
| format | string | |
| data | Object | the data to use as replacement |
| allow_partial = false | boolean | if true, will leave the injectors that can't be found in data |
| encode = null | Function | function to use to encode the value found in data |
| retourne | string | the text injected |
extractPrintf
strings.js:481Reverse of MMO.core.strings.printf: recover the values a format was filled with.
- Espace de noms
MMO.core.strings
| format | string | the format containing {key} injectors |
| result | string | the string produced from that format |
| retourne | ?Object | the captured values, or null when result does not match format |
dump
strings.js:490alias to printf with encode = serialize
- Espace de noms
MMO.core.strings
| format | ||
| data |
stripAccent
strings.js:527Strip accent of string
- Espace de noms
MMO.core.strings
| a | string | |
| retourne | string |
split
strings.js:538Split words (utf-8) with a set of delimeters
- Espace de noms
MMO.core.strings
| a | string | [description] |
| delim = [' ', "\n", "\t"] | Array | [description] |
| retourne | Array<string> |
distanceEquality
strings.js:563Compute the strict distance between words.
- Espace de noms
MMO.core.strings
| a | [type] | [description] |
| b | [type] | [description] |
| retourne | [type] | [description] |
distanceJaroWinkler
strings.js:601Compute the the Jaro Distance between two sequences (string or array) s1 and s2, using strict equality operator ===.
- Espace de noms
MMO.core.strings
| a | ||
| b |
score
strings.js:668Score a searched text with some text content
- Espace de noms
MMO.core.strings
| search | Array | list of words to search for |
| text | Array | list of words to search in |
| distanceFn | Function | function(a,b): float |
| normalize = true | bool | if true, remove accent in text and set to lower case |
| retourne | Map<string: Array<string, float>> | false | falswe if nothing matched |
search
strings.js:704Search text inside a list of urls + texts
- Espace de noms
MMO.core.strings
| search | string | |
| texts | Array<Array<url,text>> | the url part can be of any type (use Element when searching inside the dom) |
| distanceFn | Function | function(a,b): float |
| threshold = 0.7 | ||
| normalize = true | bool | |
| retourne | Array<Array<url,score,Array<string>>> | the last elements are an array of matching words |