seeq
Version:
Search or detect name on some resource (GitHub, NPM, Bower, ...)
2,546 lines (850 loc) • 33.8 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>seeq Module: resource</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="navbar navbar-default navbar-fixed-top ">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">seeq</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="topNavigation">
<ul class="nav navbar-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-cdnjs.html">cdnjs</a></li><li><a href="module-cli.html">cli</a></li><li><a href="module-format.html">format</a></li><li><a href="module-format_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-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="module-resource_util.html">resource/util</a></li><li><a href="module-seeq.html">seeq</a></li><li><a href="module-text.html">text</a></li><li><a href="module-webcomponents.html">webcomponents</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="module-resource_util-FailedHttpRequestError.html">resource/util~FailedHttpRequestError</a></li><li><a href="module-resource_util-IncorrectResponseError.html">resource/util~IncorrectResponseError</a></li>
</ul>
</li>
</ul>
<div class="col-sm-3 col-md-3">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
<div class="input-group-btn">
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="container" id="toc-content">
<div class="row">
<div class="col-md-8">
<div id="main">
<h1 class="page-title">Module: resource</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
<div class="description">API to work with resources.</div>
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<dl>
<hr>
<dt>
<h4 class="name" id=".add"><span class="type-signature"><static> </span>add(resource)</h4>
</dt>
<dd>
<div class="description">
Add data about a resource into the list of available resources.
</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>resource</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Represents data about a resource that should be added.
Object should contain the following fields (name - type - description):
<ul>
<li><code>name</code> - <code>String</code> - resource name (required)
<li><code>description</code> - <code>String</code> - resource description
<li><code>url</code> - <code>String</code> - URL of resource's site
<li><code>tag</code> - <code>Array of String</code> - tags/keywords of resource
<li><code>note</code> - <code>String</code> - additional information about resource usage
<li><code>module</code> - <code>String</code> - path to the module that should be used to work with resource;
the module should implement necessary API
<li><code>api</code> - <code>Object</code> - object that implements necessary API to work with resource
</ul>
The only mandatory field is <code>name</code>. Also <code>module</code> or <code>api</code> field should be specified.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-see method-doc-label method-doc-details-label">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-resource.html#.isAvailable">isAvailable</a></li>
</ul>
</dd>
</dl>
<h5>Throws:</h5>
<ul>
<li>
<div class="param-desc">
Will throw an error if resource name is not specified.
</div>
</li>
<li>
<div class="param-desc">
Will throw an error if resource API object and path to resource module are not specified.
</div>
</li>
<li>
<div class="param-desc">
Will throw an error if there is a resource with the same name.
</div>
</li>
</ul>
<h5>Returns:</h5>
<div class="param-desc">
Object that represents module <code>exports</code>.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".checkResourceTags"><span class="type-signature"><static> </span>checkResourceTags(resource, tagList [, checkAllTags])</h4>
</dt>
<dd>
<div class="description">
Check resource on presence or absence of specified tags.
</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>resource</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
</td>
<td class="description last">Represents data about a resource that should be checked.</td>
</tr>
<tr>
<td class="name"><code>tagList</code></td>
<td class="type">
<span class="param-type">Array</span>
</td>
<td class="attributes">
</td>
<td class="description last">List of tags (in lower case) that should be checked on presence or absence in resource tags.
Tag in form "name" (without quotes; a positive tag) means that resource should be checked on presence of "name" tag.
Tag in form "-name" (without quotes; a negative tag) means that resource should be checked on absence of "name" tag.</td>
</tr>
<tr>
<td class="name"><code>checkAllTags</code></td>
<td class="type">
<span class="param-type">Boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">Whether all tags specified in <code>tagList</code> should be checked on presence/absence in resource tags.
When parameter has <code>true</code> value it means that resource should have all positive tags
and should not have any negative tag.
When parameter has <code>false</code> value (by default) it means that resource should have one of positive tags
and should not have one of negative tags.</td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<code>true</code> if resource tags satisfy to specified tags (depending on <code>checkAllTags</code> value),
<code>false</code> otherwise.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".filterList"><span class="type-signature"><static> </span>filterList( [settings])</h4>
</dt>
<dd>
<div class="description">
Apply filter on list of currently available resources.
<br>
After operation only resources conforming to filter will be available.
<br>
In essence, this method is a wrapper for the following code:
<br>
<code>setList( getList(settings) )</code>
</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">Specifies which resources should be selected.
The following settings can be used to select resources:
<code>selectName, selectTag, checkAllTags</code>.
See <a href="module-resource.html#.getList">getList</a> for details.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-see method-doc-label method-doc-details-label">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-resource.html#.getList">getList</a></li>
<li><a href="module-resource.html#.resetList">resetList</a></li>
<li><a href="module-resource.html#.setList">setList</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Object that represents module <code>exports</code>.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".getAllNameList"><span class="type-signature"><static> </span>getAllNameList()</h4>
</dt>
<dd>
<div class="description">
Return list that contains names of all available resources.
</div>
<dl class="details">
<dt class="tag-see method-doc-label method-doc-details-label">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-resource.html#.getNameList">getNameList</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
List that contains names of all available resources.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".getIdByName"><span class="type-signature"><static> </span>getIdByName(name)</h4>
</dt>
<dd>
<div class="description">
Return identifier of resource with given name.
</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>name</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">A resource name (case-insensitive).</td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Identifier of resource that has the given name
or <code>null</code> if no one of available resources has the specified name.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">String</span>
|
<span class="param-type">null</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".getList"><span class="type-signature"><static> </span>getList( [settings])</h4>
</dt>
<dd>
<div class="description">
Return list of specified resources.
If no selection criteria is set then returns list of all available resources.
</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">Specifies which data items should be returned.
The following settings are supported (name - type - description):
<ul>
<li><code>includeApi</code> - <code>Boolean</code> - whether API object for resource should be included into data item
under <code>api</code> field; <code>false</code> by default
<li><code>selectName</code> - <code>Array | String</code> - specifies filter for available resources by name;
list of names of resources or name of resource (case-insensitive) that should be included into result
<li><code>selectTag</code> - <code>Array | String</code> - specifies filter for available resources by tag;
list of tags or tag (case-insensitive) that should be used to select resources into result;
resources that satisfy to specified tags (depending on <code>checkAllTags</code> setting)
will be included in result; see <a href="module-resource.html#.checkResourceTags">checkResourceTags</a> for details
<li><code>checkAllTags</code> - <code>Boolean</code> - whether all tags specified in <code>selectTag</code>
should be checked; see <a href="module-resource.html#.checkResourceTags">checkResourceTags</a> for details
</ul>
Filter by name (<code>selectName</code>) and filter by tag (<code>selectTag</code>)
can be used separately or together.
If no filter is specified, all resources will be included into result.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-see method-doc-label method-doc-details-label">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-resource.html#.checkResourceTags">checkResourceTags</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
List that contains objects presenting data about selected resources.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".getMap"><span class="type-signature"><static> </span>getMap( [settings])</h4>
</dt>
<dd>
<div class="description">
Return object that represents specified resources.
If no selection criteria is set then returns object that contains data about all available resources.
</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">Specifies which data items should be returned.
See <a href="module-resource.html#.getList">getList</a> for details.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-see method-doc-label method-doc-details-label">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-resource.html#.getList">getList</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Object that contains data about selected resources.
Fields are resource keys, values are objects representing data about resources.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".getNameList"><span class="type-signature"><static> </span>getNameList( [settings])</h4>
</dt>
<dd>
<div class="description">
Return list that contains names of selected resources.
<br>
If no selection criteria is set then returns list of names of all available resources.
</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">Specifies selection criteria. The following settings can be used to select resources:
<code>selectName, selectTag, checkAllTags</code>.
See <a href="module-resource.html#.getList">getList</a> for details.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-see method-doc-label method-doc-details-label">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-resource.html#.getAllNameList">getAllNameList</a></li>
<li><a href="module-resource.html#.getList">getList</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
List that contains names of selected resources.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Array</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".initList"><span class="type-signature"><static> </span>initList(list)</h4>
</dt>
<dd>
<div class="description">
Set initial list of all available resources.
<br>
This list is used to <a href="module-resource.html#.resetList">reset</a> to initial state.
</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>list</code></td>
<td class="type">
<span class="param-type">Array</span>
|
<span class="param-type">Object</span>
</td>
<td class="description last">List that contains objects presenting data about resources,
or object with data about an resource.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-see method-doc-label method-doc-details-label">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-resource.html#.resetList">resetList</a></li>
<li><a href="module-resource.html#.setList">setList</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Object that represents module <code>exports</code>.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".isAvailable"><span class="type-signature"><static> </span>isAvailable(name)</h4>
</dt>
<dd>
<div class="description">
Check whether there is a resource with given name.
</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>name</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">A name that should be checked (case-insensitive).</td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<code>true</code> if there is a resource with the given name,
<code>false</code> if no one of available resources has the specified name.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Boolean</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".remove"><span class="type-signature"><static> </span>remove(name)</h4>
</dt>
<dd>
<div class="description">
Remove resource with given name from list of resources.
</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>name</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Name of resource that should be removed (case-insensitive).</td>
</tr>
</tbody>
</table>
<dl class="details">
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Object that represents removed resource
or <code>null</code> if no one of resources from list has the specified name.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
|
<span class="param-type">null</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".removeAll"><span class="type-signature"><static> </span>removeAll()</h4>
</dt>
<dd>
<div class="description">
Clear list of resources.
</div>
<dl class="details">
<dt class="tag-see method-doc-label method-doc-details-label">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-resource.html#.add">add</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Object that represents module <code>exports</code>.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".resetList"><span class="type-signature"><static> </span>resetList()</h4>
</dt>
<dd>
<div class="description">
Set list of resources to initial state containing data about all available resources.
</div>
<dl class="details">
<dt class="tag-see method-doc-label method-doc-details-label">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-resource.html#.setList">setList</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Object that represents module <code>exports</code>.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
<hr>
<dt>
<h4 class="name" id=".setList"><span class="type-signature"><static> </span>setList(list)</h4>
</dt>
<dd>
<div class="description">
Change list of available resources.
<br>
In essence this method <a href="module-resource.html#.removeAll">removes all</a> available resources
and <a href="module-resource.html#.add">adds</a> data about each given resource into the list of available resources.
</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>list</code></td>
<td class="type">
<span class="param-type">Array</span>
|
<span class="param-type">Object</span>
</td>
<td class="description last">List that contains objects presenting data about resources,
or object with data about an resource.</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-see method-doc-label method-doc-details-label">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="module-resource.html#.add">add</a></li>
<li><a href="module-resource.html#.removeAll">removeAll</a></li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Object that represents module <code>exports</code>.
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
</dd>
</dl>
</article>
</section>
</div>
</div>
<div class="clearfix"></div>
<div class="col-md-3">
<div id="toc" class="col-md-3 hidden-xs hidden-sm hidden-md"></div>
</div>
</div>
</div>
<div class="modal fade" id="searchResults">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Search results</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<footer>
<span class="copyright">
Copyright (c) 2014-2020 Denis Sikuler
</span>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a>
on 2020-03-08T01:34:35+03:00
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
<script>
$( function () {
$( "[id*='$']" ).each( function () {
var $this = $( this );
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
} );
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
var $this = $( this );
var example = $this.find( "code" );
exampleText = example.html();
var lang = /{@lang (.*?)}/.exec( exampleText );
if ( lang && lang[1] ) {
exampleText = exampleText.replace( lang[0], "" );
example.html( exampleText );
lang = lang[1];
} else {
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
lang = langClassMatch ? langClassMatch[1] : "javascript";
}
if ( lang ) {
$this
.addClass( "sunlight-highlight-" + lang )
.addClass( "linenums" )
.html( example.html() );
}
} );
Sunlight.highlightAll( {
lineNumbers : true,
showMenu : true,
enableDoclinks : true
} );
$.catchAnchorLinks( {
navbarOffset: 10
} );
$( "#toc" ).toc( {
anchorName : function ( i, heading, prefix ) {
return $( heading ).attr( "id" ) || ( prefix + i );
},
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
showAndHide : false,
smoothScrolling: true
} );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
$( '.dropdown-toggle' ).dropdown();
$( "table" ).each( function () {
var $this = $( this );
$this.addClass('table');
} );
} );
</script>
<!--Navigation and Symbol Display-->
<!--Google Analytics-->
<script type="text/javascript">
$(document).ready(function() {
SearcherDisplay.init();
});
</script>
</body>
</html>