UNPKG

fluentnode

Version:

Fluent apis for node (based on the concepts used in C#'s FluentSharp

351 lines (229 loc) 14.7 kB
<!DOCTYPE html> <html> <head> <title>String.litcoffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <ul id="jump_to"> <li> <a class="large" href="javascript:void(0);">Jump To &hellip;</a> <a class="small" href="javascript:void(0);">+</a> <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="Array.html"> Array.litcoffee </a> <a class="source" href="Boolean.html"> Boolean.litcoffee </a> <a class="source" href="Function.html"> Function.litcoffee </a> <a class="source" href="Number.html"> Number.litcoffee </a> <a class="source" href="Object.html"> Object.litcoffee </a> <a class="source" href="String.html"> String.litcoffee </a> <a class="source" href="_register.html"> _register.js </a> <a class="source" href="_to_map_and_write_Tests.html"> _to_map_and_write_Tests.litcoffee </a> <a class="source" href="assert_Array.html"> assert_Array.litcoffee </a> <a class="source" href="assert_Boolean.html"> assert_Boolean.litcoffee </a> <a class="source" href="assert_Function.html"> assert_Function.litcoffee </a> <a class="source" href="assert_Number.html"> assert_Number.litcoffee </a> <a class="source" href="assert_Object.html"> assert_Object.litcoffee </a> <a class="source" href="assert_String.html"> assert_String.litcoffee </a> <a class="source" href="console.html"> console.litcoffee </a> <a class="source" href="fs.html"> fs.litcoffee </a> <a class="source" href="globals.html"> globals.litcoffee </a> <a class="source" href="http.html"> http.litcoffee </a> <a class="source" href="index.html"> index.md </a> <a class="source" href="path.html"> path.litcoffee </a> <a class="source" href="process.html"> process.litcoffee </a> <a class="source" href="Array.test.html"> Array.test.coffee </a> <a class="source" href="Boolean.test.html"> Boolean.test.coffee </a> <a class="source" href="Function.test.html"> Function.test.coffee </a> <a class="source" href="Number.test.html"> Number.test.coffee </a> <a class="source" href="Object.test.html"> Object.test.coffee </a> <a class="source" href="String.test.html"> String.test.coffee </a> <a class="source" href="Array.test.html"> Array.test.coffee </a> <a class="source" href="Boolean.test.html"> Boolean.test.coffee </a> <a class="source" href="Function.test.html"> Function.test.coffee </a> <a class="source" href="Number.test.html"> Number.test.coffee </a> <a class="source" href="Object.test.html"> Object.test.coffee </a> <a class="source" href="String.test.html"> String.test.coffee </a> <a class="source" href="console.test.html"> console.test.coffee </a> <a class="source" href="fs.test.html"> fs.test.coffee </a> <a class="source" href="globals.test.html"> globals.test.coffee </a> <a class="source" href="http.test.html"> http.test.coffee </a> <a class="source" href="path.test.html"> path.test.coffee </a> <a class="source" href="process.test.html"> process.test.coffee </a> </div> </li> </ul> <ul class="sections"> <li id="title"> <div class="annotation"> <h1>String.litcoffee</h1> </div> </li> <li id="section-1"> <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-1">&#182;</a> </div> <p>Methods that extend the native Javascript String class</p> <p>dependencies</p> </div> <div class="content"><div class='highlight'><pre>crypto = <span class="hljs-built_in">require</span>(<span class="hljs-string">'crypto'</span>)</pre></div></div> </li> <li id="section-2"> <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>methods</p> <p>@.<strong>append</strong> value</p> </div> <div class="content"><div class='highlight'><pre><span class="hljs-attribute">String</span>::append = <span class="hljs-function"><span class="hljs-params">(value)</span>-&gt;</span> @ + <span class="hljs-keyword">if</span> value <span class="hljs-keyword">then</span> value <span class="hljs-keyword">else</span> <span class="hljs-string">''</span></pre></div></div> </li> <li id="section-3"> <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>@.<strong>add_Random_Chars</strong> size</p> </div> <div class="content"><div class='highlight'><pre><span class="hljs-attribute">String</span>::add_Random_Chars = <span class="hljs-function"><span class="hljs-params">(size )</span>-&gt;</span> @ + crypto.randomBytes(size || <span class="hljs-number">10</span>) <span class="hljs-attribute">String</span>::add_Random_String = <span class="hljs-function"><span class="hljs-params">(size )</span>-&gt;</span> @ + crypto.randomBytes(size || <span class="hljs-number">10</span>).toString(<span class="hljs-string">'hex'</span>).slice(<span class="hljs-number">0</span>,size|| <span class="hljs-number">10</span>) <span class="hljs-attribute">String</span>::add_Random_Letters = <span class="hljs-function"><span class="hljs-params">(size )</span>-&gt;</span> charSet = <span class="hljs-string">'abcdefghijklmnopqrstuvwxyz'</span> @ + (charSet[Math.floor(Math.random() * charSet.length)] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> [<span class="hljs-number">1.</span>.size]).join(<span class="hljs-string">''</span>) <span class="hljs-attribute">String</span>::add_5_Random_Letters = <span class="hljs-function"><span class="hljs-params">( )</span>-&gt;</span> @.add_Random_Letters(<span class="hljs-number">5</span>) <span class="hljs-attribute">String</span>::add_Random_Numbers = <span class="hljs-function"><span class="hljs-params">(size )</span>-&gt;</span> charSet = <span class="hljs-string">'0123456789'</span> @ + (charSet[Math.floor(Math.random() * charSet.length)] <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> [<span class="hljs-number">1.</span>.size]).join(<span class="hljs-string">''</span>) <span class="hljs-attribute">String</span>::after = <span class="hljs-function"><span class="hljs-params">(value)</span>-&gt;</span> <span class="hljs-keyword">if</span> ((index = @.indexOf( value)) == -<span class="hljs-number">1</span> ) <span class="hljs-keyword">then</span> <span class="hljs-string">''</span> <span class="hljs-keyword">else</span> @.substr(index + value.size()) <span class="hljs-attribute">String</span>::after_Last = <span class="hljs-function"><span class="hljs-params">(value)</span>-&gt;</span> <span class="hljs-keyword">if</span> ((index = @.lastIndexOf(value)) == -<span class="hljs-number">1</span> ) <span class="hljs-keyword">then</span> <span class="hljs-string">''</span> <span class="hljs-keyword">else</span> @.substr(index + value.size()) <span class="hljs-attribute">String</span>::before = <span class="hljs-function"><span class="hljs-params">(value)</span>-&gt;</span> @.substring(<span class="hljs-number">0</span>,@.indexOf(value)) <span class="hljs-attribute">String</span>::before_Last = <span class="hljs-function"><span class="hljs-params">(value)</span>-&gt;</span> @.substring(<span class="hljs-number">0</span>,@.lastIndexOf(value))</pre></div></div> </li> <li id="section-4"> <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>@.<strong>contains</strong> value</p> <p>Checks that <code>value</code> is inside @. If <code>value</code> is an Array, then all elements are expected to be found inside @</p> </div> <div class="content"><div class='highlight'><pre><span class="hljs-attribute">String</span>::contains = <span class="hljs-function"><span class="hljs-params">(value)</span>-&gt;</span> <span class="hljs-keyword">if</span> value <span class="hljs-keyword">instanceof</span> Array <span class="hljs-keyword">for</span> item <span class="hljs-keyword">in</span> value <span class="hljs-keyword">if</span> @.indexOf(item) == -<span class="hljs-number">1</span> <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span> <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span> <span class="hljs-keyword">else</span> @.indexOf(value) &gt; -<span class="hljs-number">1</span> <span class="hljs-attribute">String</span>::ends_With = <span class="hljs-function"><span class="hljs-params">(value)</span>-&gt;</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> value <span class="hljs-keyword">then</span> <span class="hljs-literal">false</span> <span class="hljs-keyword">else</span> @.toString().slice(-value.length)==value <span class="hljs-attribute">String</span>::lower = <span class="hljs-function"><span class="hljs-params">( )</span>-&gt;</span> @.toLowerCase() <span class="hljs-attribute">String</span>::not_Contains = <span class="hljs-function"><span class="hljs-params">(value)</span>-&gt;</span> @.indexOf(value) == -<span class="hljs-number">1</span> <span class="hljs-attribute">String</span>::size = <span class="hljs-function"><span class="hljs-params">( )</span>-&gt;</span> @.length <span class="hljs-attribute">String</span>::starts_With = <span class="hljs-function"><span class="hljs-params">(value)</span>-&gt;</span> <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> value <span class="hljs-keyword">then</span> <span class="hljs-literal">false</span> <span class="hljs-keyword">else</span> @.toString().slice(<span class="hljs-number">0</span>,value.length)==value <span class="hljs-attribute">String</span>::trim = <span class="hljs-function"><span class="hljs-params">( )</span>-&gt;</span> @.replace(<span class="hljs-regexp">/^\s+|\s+$/g</span>, <span class="hljs-string">''</span>) <span class="hljs-attribute">String</span>::upper = <span class="hljs-function"><span class="hljs-params">( )</span>-&gt;</span> @.toUpperCase()</pre></div></div> </li> <li id="section-5"> <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-5">&#182;</a> </div> <hr> </div> </li> <li id="section-6"> <div class="annotation"> <div class="pilwrap "> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>back to <a href="index.html">index</a></p> </div> </li> </ul> </div> </body> </html>