seeq
Version:
Search or detect name on some resource (GitHub, NPM, Bower, ...)
1,378 lines (533 loc) • 22.3 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>seeq Module: resource/util</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
<link type="text/css" rel="stylesheet" href="styles/site.spacelab.css">
</head>
<body>
<div class="container-fluid">
<div class="navbar navbar-fixed-top ">
<div class="navbar-inner">
<a class="brand" href="index.html">seeq</a>
<ul class="nav">
<li class="dropdown">
<a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li>
<a href="module-bower.html">bower</a>
</li>
<li>
<a href="module-cdn.html">cdn</a>
</li>
<li>
<a href="module-cdnjs.html">cdnjs</a>
</li>
<li>
<a href="module-cli.html">cli</a>
</li>
<li>
<a href="module-component.html">component</a>
</li>
<li>
<a href="module-customelements.html">customelements</a>
</li>
<li>
<a href="module-format.html">format</a>
</li>
<li>
<a href="util.html">format/util</a>
</li>
<li>
<a href="module-github.html">github</a>
</li>
<li>
<a href="module-grunt.html">grunt</a>
</li>
<li>
<a href="module-gulp.html">gulp</a>
</li>
<li>
<a href="module-jam.html">jam</a>
</li>
<li>
<a href="module-jsdelivr.html">jsdelivr</a>
</li>
<li>
<a href="module-json.html">json</a>
</li>
<li>
<a href="module-jster.html">jster</a>
</li>
<li>
<a href="module-markdown.html">markdown</a>
</li>
<li>
<a href="module-microjs.html">microjs</a>
</li>
<li>
<a href="module-npm.html">npm</a>
</li>
<li>
<a href="module-raw.html">raw</a>
</li>
<li>
<a href="module-resource.html">resource</a>
</li>
<li>
<a href="util_.html">resource/util</a>
</li>
<li>
<a href="module-seeq.html">seeq</a>
</li>
<li>
<a href="module-spm.html">spm</a>
</li>
<li>
<a href="module-text.html">text</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li>
<a href="util-FailedHttpRequestError.html">FailedHttpRequestError</a>
</li>
<li>
<a href="util-IncorrectResponseError.html">IncorrectResponseError</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="row-fluid">
<div class="span8">
<div id="main">
<h1 class="page-title">Module: resource/util</h1>
<section>
<header>
<h2>
resource/util
</h2>
</header>
<article>
<div class="container-overview">
<div class="description">Helper functions.</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util.js_.html">resource/util.js</a>, <a href="util.js_.html#sunlight-1-line-1">line 1</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Classes</h3>
<dl>
<dt><a href="util-FailedHttpRequestError.html">FailedHttpRequestError</a></dt>
<dd></dd>
<dt><a href="util-IncorrectResponseError.html">IncorrectResponseError</a></dt>
<dd></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<dl>
<dt>
<h4 class="name" id="decodeHtmlEntity"><span class="type-signature"><static> </span>decodeHtmlEntity<span class="signature">(str)</span><span class="type-signature"> → {String}</span></h4>
</dt>
<dd>
<div class="description">
Decode HTML entities in given string.
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>str</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">String that should be processed.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util.js_.html">resource/util.js</a>, <a href="util.js_.html#sunlight-1-line-18">line 18</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Decoded string.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">String</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="getHttpRequestError"><span class="type-signature"><static> </span>getHttpRequestError<span class="signature">(err, response)</span><span class="type-signature"> → {Error}</span></h4>
</dt>
<dd>
<div class="description">
Return object that represents data about error of HTTP request.
<br>
If <code>err</code> parameter is set then it will be returned.
Otherwise instance of FailedHttpRequestError will be returned.
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>err</code></td>
<td class="type">
<span class="param-type">Error</span>
</td>
<td class="description last">Represents data about error.</td>
</tr>
<tr>
<td class="name"><code>response</code></td>
<td class="type">
<span class="param-type">http.IncomingMessage</span>
</td>
<td class="description last">Represents data about response.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util.js_.html">resource/util.js</a>, <a href="util.js_.html#sunlight-1-line-185">line 185</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Error object.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Error</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="getLimit"><span class="type-signature"><static> </span>getLimit<span class="signature">(<span class="optional">settings</span>, <span class="optional">defaultValue</span>, <span class="optional">maxValue</span>)</span><span class="type-signature"> → {Number}</span></h4>
</dt>
<dd>
<div class="description">
Return value of <code>limit</code> setting.
Default value will be returned if <code>limit</code> field is not present in <code>settings</code> parameter.
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>settings</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Operation settings. The object can have numeric <code>limit</code> field which value will be returned
if the value is positive number and not greater than maximum value.
Otherwise value of <code>defaultValue</code> parameter will be returned.</td>
</tr>
<tr>
<td class="name"><code>defaultValue</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Default value of limit. <code>maxValue</code> is used when parameter value is not passed or 0.</td>
</tr>
<tr>
<td class="name"><code>maxValue</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Maximum value of limit. <code>Number.MAX_VALUE</code> is used when parameter value is not passed.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util.js_.html">resource/util.js</a>, <a href="util.js_.html#sunlight-1-line-38">line 38</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Value that corresponds to <code>limit</code> setting.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Number</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="isRealSearchSet"><span class="type-signature"><static> </span>isRealSearchSet<span class="signature">(<span class="optional">settings</span>)</span><span class="type-signature"> → {Boolean}</span></h4>
</dt>
<dd>
<div class="description">
Determine whether search should be made instead of check according to operation settings.
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>settings</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Operation settings.
The following settings are used to specify real search (name - type - description):
<ul>
<li><code>search</code> - <code>Boolean</code> - Whether search should be made instead of check
</ul></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util.js_.html">resource/util.js</a>, <a href="util.js_.html#sunlight-1-line-62">line 62</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<code>true</code> if real search should be made according to settings,
<code>false</code> otherwise.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="isSearchSet"><span class="type-signature"><static> </span>isSearchSet<span class="signature">(<span class="optional">settings</span>)</span><span class="type-signature"> → {Boolean}</span></h4>
</dt>
<dd>
<div class="description">
Check whether search should be made according to operation settings.
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>settings</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Operation settings.
The following settings are used to specify search (name - type - description):
<ul>
<li><code>caseSensitive</code> - <code>Boolean</code> - Whether case-sensitive check/search should be used
<li><code>partialMatch</code> - <code>Integer</code> - Allow partial matching: 0 - disallow (by default),
1 - allow at the beginning of matching strings, 2 - allow substring matching
<li><code>search</code> - <code>Boolean</code> - Whether search should be made instead of check
</ul></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util.js_.html">resource/util.js</a>, <a href="util.js_.html#sunlight-1-line-82">line 82</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<code>true</code> if search should be made according to settings,
<code>false</code> otherwise.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="isStringMatch"><span class="type-signature"><static> </span>isStringMatch<span class="signature">(value, searchValue, <span class="optional">settings</span>)</span><span class="type-signature"> → {Boolean}</span></h4>
</dt>
<dd>
<div class="description">
Check whether one of given strings is similar to the searched string.
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">Array</span>
|
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="description last">String or array of strings that should be checked.</td>
</tr>
<tr>
<td class="name"><code>searchValue</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="attributes">
</td>
<td class="description last">Value that is searched for.</td>
</tr>
<tr>
<td class="name"><code>settings</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Operation settings.
The following settings are supported (name - type - description):
<ul>
<li><code>caseSensitive</code> - <code>Boolean</code> - Whether case-sensitive check should be used
<li><code>partialMatch</code> - <code>Integer</code> - Allow partial matching: 0 - disallow (by default),
1 - allow at the beginning of matching strings, 2 - allow substring matching
<li><code>search</code> - <code>Boolean</code> - Whether search should be made instead of check
</ul></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="util.js_.html">resource/util.js</a>, <a href="util.js_.html#sunlight-1-line-106">line 106</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<code>true</code> if one of given strings is similar to the searched string according to settings,
<code>false</code> otherwise.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
</dd>
</dl>
</article>
</section>
</div>
<div class="clearfix"></div>
<footer>
<span class="copyright">
Copyright (c) 2014 Denis Sikuler
</span>
<br />
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a>
on Thu Aug 21 2014 23:46:52 GMT+0400 (MSK) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
<div class="span3">
<div id="toc"></div>
</div>
<br clear="both">
</div>
</div>
<script src="scripts/sunlight.js"></script>
<script src="scripts/sunlight.javascript.js"></script>
<script src="scripts/sunlight-plugin.doclinks.js"></script>
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
<script src="scripts/sunlight-plugin.menu.js"></script>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/jquery.scrollTo.js"></script>
<script src="scripts/jquery.localScroll.js"></script>
<script src="scripts/bootstrap-dropdown.js"></script>
<script src="scripts/toc.js"></script>
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
<script>
$( function () {
$( "#toc" ).toc( {
selectors : "h1,h2,h3,h4",
showAndHide : false,
scrollTo : 60
} );
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
} );
</script>
</body>
</html>