src/resource/index.js
/**
 * Add data about a resource into the list of available resources.
 * 
 * @param {Object} resource
 *      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.
 * @return {Object}
 *      Object that represents module <code>exports</code>.
 * @throws Will throw an error if resource name is not specified.
 * @throws Will throw an error if resource API object and path to resource module are not specified.
 * @throws Will throw an error if there is a resource with the same name.
 * @alias module:resource.add
 * @see {@link module:resource.isAvailable isAvailable}
 */
Add data about a resource into the list of available resources.

@param {Object} resource
Represents data about a resource that should be added.
Add data about a resource into the list of available resources . @param { Object } resource Represents data about a resource that should be added .
function add(resource) {
    var sName = resource.name,
        sId;
    if (! sName) {
        throw Error("Unknown name: resource name is not specified");
    }
    if ((! resource.api || typeof resource.api !== "object") && (! resource.module || typeof resource.module !== "string")) {
        throw Error("Unknown API: resource API object or path to resource module must be specified");
    }
    if (isAvailable(sName)) {
        throw Error("Duplicate name: there is a resource with the same name");
    }
    sId = resource.id = sName.toLowerCase();
    if (! resource.tag) {
        resource.tag = [];
    }
    if (! resource.shortDescr) {
        resource.shortDescr = resource.description;
    }
    resourceList.push(resource);
    resourceMap[sId] = resource;
    return exports;
}
function add ( resource ) { var sName = resource . name , sId ; if ( ! sName ) { throw Error ( "Unknown name: resource name is not specified" ) ; } if ( ( ! resource . api || typeof resource . api !== "object" ) && ( ! resource . module || typeof resource . module !== "string" ) ) { throw Error ( "Unknown API: resource API object or path to resource module must be specified" ) ; } if ( isAvailable ( sName ) ) { throw Error ( "Duplicate name: there is a resource with the same name" ) ; } sId = resource . id = sName . toLowerCase ( ) ; if ( ! resource . tag ) { resource . tag = [ ] ; } if ( ! resource . shortDescr ) { resource . shortDescr = resource . description ; } resourceList . push ( resource ) ; resourceMap [ sId ] = resource ; return exports ; }
Add data about a resource into the list of available resources.
Add data about a resource into the list of available resources .
/*jshint newcap:false*/