@wider/utils_proto
Version:
A set of extensions to basic objects giving uniform behaviour in various technical environments
2,195 lines (638 loc) • 93.4 kB
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Module: @wider/utils_proto/proto_string | YDR</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="styles/prettify-jsdoc.css">
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/tui-doc.css">
</head>
<body>
<nav class="lnb" id="lnb">
<div class="logo" style="width: 50px">
<a href="http://y-d-r.co.uk" rel="noopener noreferrer" target="_blank">
<img src="http://y-d-r.co.uk/favicon.ico" width="100%" height="100%">
</a>
</div>
<div class="title">
<h1><a href="index.html" class="link">YDR</a></h1>
<span class="version">v1.0.23</span>
</div>
<div class="search-container" id="search-container">
<input type="text" placeholder="Search">
<ul></ul>
</div>
<ol class="lnb-tab">
<li id="api-tab">
<a href="#"><h4>API</h4></a>
</li>
<li id="examples-tab">
<a href="#"><h4>Examples</h4></a>
</li>
</ol>
<div class="lnb-examples hidden"><h3>Examples</h3><ul><li><a href="tutorial-Using Markdown with ydr_HTMLencode.html">Using Markdown with ydr_HTMLencode</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="Using Markdown with ydr_HTMLencode_sub"></div></li><li><a href="tutorial-Using Object Prototype extensions.html">Using Object Prototype extensions</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="Using Object Prototype extensions_sub"></div></li></ul></div><div class="lnb-api hidden"><h3>Modules</h3><ul><li><a href="module-@wider_utils_proto.html">@wider/utils_proto</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto_sub"><div class="member-type">Methods</div><ul class="inner"><li><a href="module-@wider_utils_proto.html#~init">init</a></li></ul></div></li><li><a href="module-@wider_utils_proto_proto_array.html">@wider/utils_proto/proto_array</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto/proto_array_sub"><div class="member-type">Methods</div><ul class="inner"><li><a href="module-@wider_utils_proto_proto_array.html#~keySort()">keySort()</a></li><li><a href="module-@wider_utils_proto_proto_array.html#~numericSortAsc()">numericSortAsc()</a></li><li><a href="module-@wider_utils_proto_proto_array.html#~permute()">permute()</a></li><li><a href="module-@wider_utils_proto_proto_array.html#~plainSortAsc()">plainSortAsc()</a></li><li><a href="module-@wider_utils_proto_proto_array.html#~plainSortDesc()">plainSortDesc()</a></li><li><a href="module-@wider_utils_proto_proto_array.html#~pushUnique()">pushUnique()</a></li></ul></div></li><li><a href="module-@wider_utils_proto_proto_array_test.html">@wider/utils_proto/proto_array/test</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto/proto_array/test_sub"></div></li><li><a href="module-@wider_utils_proto_proto_date.html">@wider/utils_proto/proto_date</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto/proto_date_sub"><div class="member-type">Methods</div><ul class="inner"><li><a href="module-@wider_utils_proto_proto_date.html#~toISOString">toISOString</a></li></ul></div></li><li><a href="module-@wider_utils_proto_proto_date_test.html">@wider/utils_proto/proto_date/test</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto/proto_date/test_sub"></div></li><li><a href="module-@wider_utils_proto_proto_function.html">@wider/utils_proto/proto_function</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto/proto_function_sub"><div class="member-type">Methods</div><ul class="inner"><li><a href="module-@wider_utils_proto_proto_function.html#~describe()">describe()</a></li></ul></div></li><li><a href="module-@wider_utils_proto_proto_function_test.html">@wider/utils_proto/proto_function/test</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto/proto_function/test_sub"></div></li><li><a href="module-@wider_utils_proto_proto_number.html">@wider/utils_proto/proto_number</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto/proto_number_sub"><div class="member-type">Methods</div><ul class="inner"><li><a href="module-@wider_utils_proto_proto_number.html#~bitsUpTo()">bitsUpTo()</a></li><li><a href="module-@wider_utils_proto_proto_number.html#~two()">two()</a></li></ul></div></li><li><a href="module-@wider_utils_proto_proto_number_test.html">@wider/utils_proto/proto_number/test</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto/proto_number/test_sub"></div></li><li><a href="module-@wider_utils_proto_proto_object.html">@wider/utils_proto/proto_object</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto/proto_object_sub"><div class="member-type">Methods</div><ul class="inner"><li><a href="module-@wider_utils_proto_proto_object.html#~assign()">assign()</a></li><li><a href="module-@wider_utils_proto_proto_object.html#~deepMerge()">deepMerge()</a></li></ul></div></li><li><a href="module-@wider_utils_proto_proto_object_test.html">@wider/utils_proto/proto_object/test</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto/proto_object/test_sub"></div></li><li><a href="module-@wider_utils_proto_proto_string.html">@wider/utils_proto/proto_string</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto/proto_string_sub"><div class="member-type">Methods</div><ul class="inner"><li><a href="module-@wider_utils_proto_proto_string.html#~asHTML()">asHTML()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~attrEncode()">attrEncode()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~camelIse()">camelIse()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~checkSum()">checkSum()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~checkSumValidate()">checkSumValidate()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~contextParse()">contextParse()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~deCamelIse()">deCamelIse()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~ellipses()">ellipses()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~escape()">escape()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~extendedCharCodeFixer()">extendedCharCodeFixer()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~formStrToXMLattr()">formStrToXMLattr()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~fuzzyValue()">fuzzyValue()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~HTMLencode()">HTMLencode()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~HTMLencodeInit">HTMLencodeInit</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~isHTML()">isHTML()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~isHTMLerror()">isHTMLerror()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~proper()">proper()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~regExpEncode()">regExpEncode()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~replaceSafe()">replaceSafe()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~searchEncode()">searchEncode()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~selectorEncode()">selectorEncode()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~simpleHTMLtoPlain()">simpleHTMLtoPlain()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~standardMarkups()">standardMarkups()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~stringEncode()">stringEncode()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~textSignature()">textSignature ()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~trim()">trim()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~unescape()">unescape()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~unHTMLencode()">unHTMLencode()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~wrapAsError()">wrapAsError()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~wrapAsOK()">wrapAsOK()</a></li><li><a href="module-@wider_utils_proto_proto_string.html#~XMLverify()">XMLverify()</a></li></ul></div></li><li><a href="module-@wider_utils_proto_proto_string_contextParse.html">@wider/utils_proto/proto_string/contextParse</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto/proto_string/contextParse_sub"><div class="member-type">Typedef</div><ul class="inner"><li><a href="module-@wider_utils_proto_proto_string_contextParse.html#~rowId">rowId</a></li><li><a href="module-@wider_utils_proto_proto_string_contextParse.html#~wider_context">wider_context</a></li></ul></div></li><li><a href="module-@wider_utils_proto_proto_string_test.html">@wider/utils_proto/proto_string/test</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto/proto_string/test_sub"></div></li></ul></div><div class="lnb-api hidden"><h3>Classes</h3><ul><li><a href="module-@wider_utils_proto_proto_string_contextParse-ContextParse.html">ContextParse</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:@wider/utils_proto/proto_string/contextParse~ContextParse_sub"><div class="member-type">Methods</div><ul class="inner"><li><a href="module-@wider_utils_proto_proto_string_contextParse-ContextParse.html#toString">toString</a></li></ul></div></li></ul></div>
</nav>
<div id="resizer"></div>
<div class="main" id="main">
<section>
<header>
<h2>@wider/utils_proto/proto_string</h2>
</header>
<article>
<div class="container-overview">
<div class="description"><p>A series of methods for the javaScript String Object, all methods have names starting <code>wider_</code></p>
<ul>
<li>This provides a collection of methods that extend the javascript String object to allow simpler and easier to read code. Elsewhere many javascript string processing function are declared as stand alone procedures and not as properties if the String object and may have different code implementations in different environments/version or not available in all environments.</li>
</ul>
<p>For example in older implementations of javascript <code>escape()</code> would give different results in different environments / versions and is not even available in later versions</p>
<p>When used in multiple combinations as prefix function calls, the standard javascript code is needlessly inelegant and harder to maintain - either requiring numerous separate statements or nested method calls which are hard to read amd have a risk of misplaced parentheses or even parameters.</p>
<p>With these methods in this module you can blend native postfix method calls as well as these custom methods with code that is easy to read.</p>
<p>The exported object of this module is an object to be assigned to your <code>String</code> class or your extension thereof. The methods assigned to the class are the methods of this module which have parentheses appended to their method name. To avoid current or future risk of name conflict, all names are prefixed with <code>.wider_</code> when used - for example</p>
<pre class="prettyprint source lang-javascript"><code>"myString".wider_camelIse()
</code></pre></div>
<dt>
</dt>
<dd>
<dl class="details">
<dt class="tag-author">Author:</dt>
<dd class="tag-author">
<ul>
<li>Martin W Baker</li>
</ul>
</dd>
<dt class="tag-copyright">Copyright:</dt>
<dd class="tag-copyright"><ul class="dummy"><li>Copyright (C) 1985..2021 Martin Baker. http://y-d-r.co.uk</li></ul></dd>
<dt class="tag-license">License:</dt>
<dd class="tag-license"><ul class="dummy"><li>ISC Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</li></ul></dd>
</dl>
</dd>
</div>
<h3 class="subsection-title">Methods</h3>
<dl>
<dt>
<h4 class="name" id="~asHTML()">
<span class="type-signature"><span class="icon green">inner</span> </span>asHTML()<span class="signature">(outerElement<span class="signature-attributes">opt</span>, mode<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {string}</span>
<div class="container-source members">
<code><a href="proto_string_index.js.html">proto_string/index.js</a></code>,
<code><a href="proto_string_index.js.html#line786">line 786</a></code>
</div>
</h4>
</dt>
<dd>
<div class="description">
<p>Ensure that the given text is in HTML format, changing it is necessary</p>
</div>
<div class="container-params">
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>outerElement</code></td>
<td class="type">
<span class="param-type">objectname</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
'div'
</td>
<td class="description last"><p>optional tag name of the outer element - ignored if the text contains newline characters. Defaults to <code>div</code> or <code>span</code> according to the presence of newlines. Also ignored if the text also appears to be HTML.</p></td>
</tr>
<tr>
<td class="name"><code>mode</code></td>
<td class="type">
<span class="param-type">enum</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
</td>
<td class="description last"><p>values |strict|markdown| <code>strict</code> the content must be strict xml and will be coerced to be so if it isn't. <code>markdown</code> if the text is not HTML then it is treated as a markdown document (if it starts with a single <em><strong>#</strong></em> heading or markdown fragment otherwise)</p></td>
</tr>
</tbody>
</table>
</div>
<div class="container-returns">
<h5>Returns:</h5>
<span class="param-type">string</span>
- <p>If already appears to be HTML then returns the original text
If it contains one one more lines then return one of more elements (for \n\n) and <br /> for (\n). If a line starts with a markup cann generate <code>h1</code> etc or <code<li` markups.
if there are no newlines then HTML as an inline block
</">Useful for including thrown error messages into an HTML response
Please refer to the documentation in ydr/data/resources to see the markups this generates</p>
</div>
<dl class="details">
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>"*head=1: my title\nhere is a line\n\n* here is a \"bullet\"\n*and <another?".wider_asHTML()
// ...
"<div><h1> my title </h1>
here is a line
<p class="bullet"> here is a "bullet"
<p class="bullet">and &lt;another?
</div>"
"line1\nline2\nline3".wider_asHTML("span")
// "<span>line1<br/>line2<br/>line3</span>"</code></pre>
</dd>
<dt>
<h4 class="name" id="~attrEncode()">
<span class="type-signature"><span class="icon green">inner</span> </span>attrEncode()<span class="signature">()</span><span class="type-signature"> → {string}</span>
<div class="container-source members">
<code><a href="proto_string_index.js.html">proto_string/index.js</a></code>,
<code><a href="proto_string_index.js.html#line1371">line 1371</a></code>
</div>
</h4>
</dt>
<dd>
<div class="description">
<p>Encode a string so it may appear in the text of an HTML or XML attribute for an element you are preparing in plain text
We assume you will placing the result in a string delimited by quotation marks and not apostrophes</p>
</div>
<div class="container-returns">
<h5>Returns:</h5>
<span class="param-type">string</span>
- <p>string with any characters that would conflict with XML syntax encoded to be safe</p>
</div>
<dl class="details">
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>> "sfgsdf< \n sdfgsdg \"".wider_attrEncode()
// "sfgsdf&lt; &#xa sdfgsdg &quot;"</code></pre>
</dd>
<dt>
<h4 class="name" id="~camelIse()">
<span class="type-signature"><span class="icon green">inner</span> </span>camelIse()<span class="signature">()</span><span class="type-signature"> → {string}</span>
<div class="container-source members">
<code><a href="proto_string_index.js.html">proto_string/index.js</a></code>,
<code><a href="proto_string_index.js.html#line370">line 370</a></code>
</div>
</h4>
</dt>
<dd>
<div class="description">
<p>Turns any string into a camelised identifier - action is mostly reversed by <code>.deCamelIse()</code>.</p>
<p>In order to be reversible the camelisation process is slightly different to the norm when dealing with the transition between an acronym and a following name. So <em><strong>an XML string</strong></em> becomes <em><strong>anXMLstring</strong></em> and hence</p>
<pre class="prettyprint source lang-javascript"><code>const demo = "an XML string";
demo.wider_camelIse().deCamelIse() == demo; // true
</code></pre>
<p>BUT if the string starts with a hard space the first hard space is removed and the string left otherwise unchanged.</p>
<p>Note the camelisation of this function's name</p>
<p><code>.wider_camelIse()</code> and <code>.wider_deCamelIse()</code> are often used with enumerated lists enabling a data value to have the form of an objectname convenient for data use and to generate a neat alternative for the user to read and write</p>
</div>
<div class="container-returns">
<h5>Returns:</h5>
<span class="param-type">string</span>
</div>
<dl class="details">
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>"hold my hands up".camelIse() // holdMyHandsUp
"HTML encode".camelIse() // HTMLencode</code></pre>
</dd>
<dt>
<h4 class="name" id="~checkSum()">
<span class="type-signature"><span class="icon green">inner</span> </span>checkSum()<span class="signature">(mode<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {string}</span>
<div class="container-source members">
<code><a href="proto_string_index.js.html">proto_string/index.js</a></code>,
<code><a href="proto_string_index.js.html#line471">line 471</a></code>
</div>
</h4>
</dt>
<dd>
<div class="description">
<p>Generates a mod 97 checksum and appends it to the string. The string may contain formatting; any non digit character is excluded from the computation
Further checksum formats will be added according to pressures to include them</p>
</div>
<div class="container-params">
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>mode</code></td>
<td class="type">
<span class="param-type">enum</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
numeric97
</td>
<td class="description last"><p>the type of checksum required</p>
<ul><li>numeric97 = mod 97 all non digits are ignored - multiply the numeric value of each digit by its character position in [3,5,7,11,13,17,19,23,29,31] rotating so
9876
becomes
<pre>` (9*3 + 8*5 + 7*7 + 6*11 ) mod 97 = 85`</pre></td>
</tr>
</tbody>
</table>
</div>
<div class="container-returns">
<h5>Returns:</h5>
<span class="param-type">string</span>
- <p>the original value augmented by its checksum</p>
</div>
<dl class="details">
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>"aasdf".wider_checksum() // "aasdf00"
"123456789123456789123456789123456789".wider_checkSum() // "12345678912345678912345678912345678904"
"GB 1245/6789-".wider_checkSum() // "GB 1245/6789-78"</code></pre>
</dd>
<dt>
<h4 class="name" id="~checkSumValidate()">
<span class="type-signature"><span class="icon green">inner</span> </span>checkSumValidate()<span class="signature">(mode)</span><span class="type-signature"> → {boolean}</span>
<div class="container-source members">
<code><a href="proto_string_index.js.html">proto_string/index.js</a></code>,
<code><a href="proto_string_index.js.html#line521">line 521</a></code>
</div>
</h4>
</dt>
<dd>
<div class="description">
<p>Generates a mod 97 checksum and appends it to the string. The string may contain formatting; any non digit character is excluded from the computation</p>
</div>
<div class="container-params">
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>mode</code></td>
<td class="type">
<span class="param-type">enum</span>
</td>
<td class="description last"><p>the mode that the checksum would have been created in by <code>.checkSum()</code></p></td>
</tr>
</tbody>
</table>
</div>
<div class="container-returns">
<h5>Returns:</h5>
<span class="param-type">boolean</span>
- <p>true if the checksum is valid as the last two characters of the string</p>
</div>
<dl class="details">
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>"aAsdf00".checkSumValidate()
// true
"123456789123456789123456789123456789".checkSum()
// "12345678912345678912345678912345678904"
"GB 1245/6789-".checkSum()
// "GB 1245/6789-78"</code></pre>
</dd>
<dt>
<h4 class="name" id="~contextParse()">
<span class="type-signature"><span class="icon green">inner</span> </span>contextParse()<span class="signature">()</span><span class="type-signature"></span>
<div class="container-source members">
<code><a href="proto_string_index.js.html">proto_string/index.js</a></code>,
<code><a href="proto_string_index.js.html#line541">line 541</a></code>
</div>
</h4>
</dt>
<dd>
<div class="description">
<p>Takes a context string and converts it into an object.This object may later be extended by the <code>$wider.data</code>
to facilitate data updates or deletes or to create new rows</p>
</div>
<dl class="details">
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>"FINANCE:transactrowsRowId_4012:name:webfile".contextParse()
// ...
ContextParse {
urn: "FINANCE",
id: "transactrowsRowId_4012",
target: "transactrowsRowId_4012",
attribute: "name",
xpath: "webfile",
buttons: undefined,
selector: undefined,
action: undefined,
context: "FINANCE:transactrowsRowId_4012:name:webfile"
}</code></pre>
</dd>
<dt>
<h4 class="name" id="~deCamelIse()">
<span class="type-signature"><span class="icon green">inner</span> </span>deCamelIse()<span class="signature">()</span><span class="type-signature"> → {string}</span>
<div class="container-source members">
<code><a href="proto_string_index.js.html">proto_string/index.js</a></code>,
<code><a href="proto_string_index.js.html#line414">line 414</a></code>
</div>
</h4>
</dt>
<dd>
<div class="description">
<p>Turns any camelised string into a space separated string - action is mostly reversed by .camelIse</p>
<p>BUT if the string starts with a hard space the first hard space is removed and the string left otherwise unchanged.</p>
<p>Note the camelisation of the function name
<code>.camelIse()></code> and <code>.deCamelIse)</code> are often used with enumerated lists enabling a data value to have the form of an objectname and to generate a neat alternative for the user and to work back from what the user enters to the objectname</p>
</div>
<div class="container-returns">
<h5>Returns:</h5>
<span class="param-type">string</span>
</div>
<dl class="details">
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>"aasdf".deCamelIse() // aasdj
"holdMyHandsUp".deCamelIse() // "hold my hands up"
"HTMLencode".deCamelIse().camelIse() // "HTMLencode"
"wasThatIBMsoftware".deCamelIse() // "was that IBM software"
"HTMLEncode".deCamelIse() // "HTMLEncode" --- note shown to avoid inelegant forms
"HTMLEncode".deCamelIse().camelIse() // "HTMLencode"</code></pre>
</dd>
<dt>
<h4 class="name" id="~ellipses()">
<span class="type-signature"><span class="icon green">inner</span> </span>ellipses()<span class="signature">(widthMax<span class="signature-attributes">nullable</span>, heightMax<span class="signature-attributes">opt</span>, mode<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {string}</span>
<div class="container-source members">
<code><a href="proto_string_index.js.html">proto_string/index.js</a></code>,
<code><a href="proto_string_index.js.html#line1405">line 1405</a></code>
</div>
</h4>
</dt>
<dd>
<div class="description">
<p>Limit the length of a string as sent fo HTML display.
Sometimes you want only so much of a string - if it is short then fine, but if the string is too long you only want so much
<p?String may be plain text or HTML</p>
</div>
<div class="container-params">
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>widthMax</code></td>
<td class="type">
<span class="param-type">positiveInteger</span>
</td>
<td class="attributes">
<nullable><br>
</td>
<td class="description last"><p>count of the ems width you want to allocate</p></td>
</tr>
<tr>
<td class="name"><code>heightMax</code></td>
<td class="type">
<span class="param-type">positiveInteger</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>count of the ems height you wish to allocate</p></td>
</tr>
<tr>
<td class="name"><code>mode</code></td>
<td class="type">
<span class="param-type">enumList</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>if present then a space delimited list</p></td>
</tr>
</tbody>
</table>
</div>
<div class="container-returns">
<h5>Returns:</h5>
<span class="param-type">string</span>
- <p>HTML encoded string ellipsed if it is longer than space specified</p>
</div>
<dl class="details">
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>> "fdsgsdfgsdfg sdfg s sdfg sdfg sdfg sdfg sdf gb".ellipses(20)
//"<span class="ellipses" style="white-space:nowrap; width:20em"><span>fdsgsdfgsdfg sdfg s sdfg sdfg sdfg sdfg sdf gb</span></span>"</code></pre>
</dd>
<dt>
<h4 class="name" id="~escape()">
<span class="type-signature"><span class="icon green">inner</span> </span>escape()<span class="signature">()</span><span class="type-signature"> → {string}</span>
<div class="container-source members">
<code><a href="proto_string_index.js.html">proto_string/index.js</a></code>,
<code><a href="proto_string_index.js.html#line1281">line 1281</a></code>
</div>
</h4>
</dt>
<dd>
<div class="description">
<p>Generates an old school equivalent of the escape () function found in many older browsers. Use this to avoid different behaviours according to the age of the javascript engine you are using</p>
<p>This roughly follows the ecma-262/5.1 <a href="https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3">https://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3</a> within the limited context of the original early versions so it does not mess with any character above \x1F per the original form of the function
Do not use this as a substitute for URI Handling Function Properties - this is for when you want to encode something that is not a URI so it doesn't conflict with other controlling characters you may use
The result may be used directly in an HTML attribute without compromising attribute or tag delimiters and may be used in a formData string.</p>
<ul><li>; \ / ? : @ & = + $ ecma-262/5.1/#sec-15.1.3 uriReserved
</li><li>% ecma-262/5.1/#sec-15.1.3 uriEscaped
</li><li>- _ . ! ~ * " () ecma-262/5.1/#sec-15.1.3 uriMark
</li><li>space # < > { } [ ] additions for backwards compatibility
</ul>
</div>
<div class="container-returns">
<h5>Returns:</h5>
<span class="param-type">string</span>
</div>
<dl class="details">
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>"sdf : ; - + / \\ { } ".wider_escape()
// "sdf%20%20%20%3a%20%20%20%3b%20%20%20%2d%20%20%2b%20%20%2f%20%20%20%20\\%20%20%20%7b%20%20%20%7d%20%20%20"</code></pre>
</dd>
<dt>
<h4 class="name" id="~extendedCharCodeFixer()">
<span class="type-signature"><span class="icon green">inner</span> </span>extendedCharCodeFixer()<span class="signature">()</span><span class="type-signature"> → {string}</span>
<div class="container-source members">
<code><a href="proto_string_index.js.html">proto_string/index.js</a></code>,
<code><a href="proto_string_index.js.html#line564">line 564</a></code>
</div>
</h4>
</dt>
<dd>
<div class="description">
<p>When one creates an xml object and its output contains extended character codes these can get mapped onto character code with values in excess of 127. In older systems with code pages you can get character corruptions when using database, javascript and client side HTML rendering. This is particularly prevalent when people paste in content from older applications such as older versions of MS Word.
This converts all unicode and extended character set copes above \x80 so that in effect you get UTF-7 rendering - which is carried safely in UTF-8 standard for javascript and various browser code pages</p>
</div>
<h5>Throws:</h5>
<dl>
<dt>
<div class="param-desc">
<p>if not part of a @wider/utils_bundle solution - so just dont use it</p>
</div>
</dt>
<dd></dd>
<dt>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Error</span>
</dd>
</dl>
</dt>
<dd></dd>
</dl>
<div class="container-returns">
<h5>Returns:</h5>
<span class="param-type">string</span>
- <p>HTML string compatible with the original but with extended characters</p>
</div>
<dl class="details">
</dl>
</dd>
<dt>
<h4 class="name" id="~formStrToXMLattr()">
<span class="type-signature"><span class="icon green">inner</span> </span>formStrToXMLattr()<span class="signature">(mode<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {string}</span>
<div class="container-source members">
<code><a href="proto_string_index.js.html">proto_string/index.js</a></code>,
<code><a href="proto_string_index.js.html#line632">line 632</a></code>
</div>
</h4>
</dt>
<dd>
<div class="description">
<p>Take a standard http request queryString (eg as in Request.queryString) or in formData and returns it as a string in the form of xml property name value pairs ready for insert in an xml element
eg <code>field1="lkjj;l" field2="lklkklh"</code> etc<.p>
unless mode is withNulls, empty or missing attributes are not included in the xml</p>
<pre><code> if the string has real unencoded newlines WITHIN an attribute value then these are JS escaped as is
this is a formatting error</code></pre>
</div>
<div class="container-params">
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>mode</code></td>
<td class="type">
<span class="param-type">enum</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>values |withNulls| if present then attributes given in the source that have no value are supplied as empty strings otherwise they are suppressed</p></td>
</tr>
</tbody>
</table>
</div>
<div class="container-returns">
<h5>Returns:</h5>
<span class="param-type">string</span>
- <p>XML attribute list</p>
</div>
<dl class="details">
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>> "field0&field1=here%20is%20my%20contentm%5bin%20here%5d&field2=here%20is%20my%20content%20%3cin%20here%3e".formStrToXMLattr()
// "field1="here is my contentm[in here]" field2="here is my content &amp;lt;in here&amp;gt;" "
> "field0&field1=here%20is%20my%20contentm%5bin%20here%5d&field2=here%20is%20my%20content%20%3cin%20here%3e".formStrToXMLattr("withNulls")
// "field0="" field1="here is my contentm[in here]" field2="here is my content &amp;lt;in here&amp;gt;" "</code></pre>
</dd>
<dt>
<h4 class="name" id="~fuzzyValue()">
<span class="type-signature"><span class="icon green">inner</span> </span>fuzzyValue()<span class="signature">(mode<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {string}</span>
<div class="container-source members">
<code><a href="proto_string_index.js.html">proto_string/index.js</a></code>,
<code><a href="proto_string_index.js.html#line676">line 676</a></code>
</div>
</h4>
</dt>
<dd>
<div class="description">
<p>Generates an encoding of a word or phrase that can be used to search a list - useful for use entry on long pick lists allowing typos and spelling errors to handled</p>
<p>At the client, we suggest you use this method repeatedly with increasing rules until you get a short enough option list from your dataset</p>
</div>
<div class="container-params">
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>mode</code></td>
<td class="type">
<span class="param-type">enumList</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="default">
basic
</td>
<td class="description last"><p>zero or more of the values |basic|harsh|noVowels|alpha|</p>
<ul>
<li><em><strong>basic</strong></em> - in which all spaces are removed, chars converted to lowercase, and utf-8 extended characters either removed or converted to lowercase a-z equivalents
other characters are generally preserved</li>
<li><em><strong>harsh</strong></em> - removes all duplicate adjacent letters</li>
<li><em><strong>noVowels</strong></em> - aeiouy like letters removed (but accented ones kept)</li>
<li><em><strong>alpha</strong></em> - // only a-z A-Z \xff</li>
</ul></td>
</tr>
</tbody>
</table>
</div>
<div class="container-returns">
<h5>Returns:</h5>
<span class="param-type">string</span>
- <p>} sting reduced for fuzzy comparison</p>
</div>
<dl class="details">
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>> "I have a sore Œsophagus".fuzzyValue()
"ihaveasoreœsopegus"
> "I have a sore Œsophagus".fuzzyValue("basic")
"ihaveasoreœsopegus"
> "I have a sore Œsophagus".fuzzyValue("harsh")
"I have a sore sophegus"
> "I have a sore Œsophagus".fuzzyValue("harsh noVowels")
"I hv sr sphgs"
> "I have a sore Œsophagus".fuzzyValue("basic harsh noVowels")
"hvsrœspgs"
> "I have 1 sore Œsophagus".fuzzyValue("alpha")
"havesoresophegus"</code></pre>
</dd>
<dt>
<h4 class="name" id="~HTMLencode()">
<span class="type-signature"><span class="icon green">inner</span> </span>HTMLencode()<span class="signature">(condition<span class="signature-attributes">opt</span>, settings<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {string}</span>
<div class="container-source members">
<code><a href="proto_string_index.js.html">proto_string/index.js</a></code>,
<code><a href="proto_string_index.js.html#line53">line 53</a></code>
</div>
</h4>
</dt>
<dd>
<div class="description">
<p>Convert a string so that it is safe for use as text content in HTML. If the string is already HTML it will still be encoded - rendering the HTML markups visible to a user viewing the result.</p>
<p>See also <code>myString.wider_attrEncode()</code> for strings that are safe to place inside an xml or HTML attribute
See also <code>myString.wider_asHTML()</code> which only converts if the string is not already HTML.</p>
</div>
<div class="container-params">
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>condition</code></td>
<td class="type">
<span class="param-type">enumList</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>values <code>'newlines'HTML'markdown</code></p>
<ul>
<li>If this contains <code>HTML</code> then if the string already appears to be HTML syntax then it is not amended</li>
<li>if this contains <code>newlines</code> then new line markers are replace with their HTML character code equivalent</li>
<li>if this contains 'markdown' then <em><strong>markdown-it</strong></em> will be used if the string appears to be markdown. Your must call `"".wider_HTMLencode("markdownInit") ONCE in lifetime before calling with this option</li>
<li>if this is ONLY 'markdownInit' then the markdown tool is loaded dynamically on its first use to prevent bloat if it is not used. So if you intend to use this feature then call <code>"".wider_HTMLencode("markdown", [settings])</code> to initialise. The result will be a <em><strong>Promise</strong></em> that triggers when ready. In general, unless you are initialising just in time, you cam ignore the Promise if you execute this call immediately you have imported this module. See