{"size": 820, "ext": "js", "max_stars_repo_path": "src/tag/RecordType.js", "max_stars_repo_name": "azu/jsdoc-to-assert", "max_stars_repo_stars_event_min_datetime": "2016-03-21T13:05:26.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-26T13:13:41.000Z", "max_issues_repo_path": "src/tag/RecordType.js", "max_issues_repo_name": "GRAPHISOFT/jsdoc-to-assert", "max_issues_repo_issues_event_min_datetime": "2016-03-25T02:23:46.000Z", "max_issues_repo_issues_event_max_datetime": "2017-11-14T15:04:32.000Z", "max_forks_repo_path": "src/tag/RecordType.js", "max_forks_repo_name": "GRAPHISOFT/jsdoc-to-assert", "max_forks_repo_forks_event_min_datetime": "2016-11-16T03:41:15.000Z", "max_forks_repo_forks_event_max_datetime": "2017-11-29T14:54:48.000Z"}
{"max_stars_count": 38, "max_issues_count": 13, "max_forks_count": 5, "avg_line_length": 37.2727272727, "max_line_length": 85, "alphanum_fraction": 0.6317073171}
// LICENSE : MIT
"use strict";
//  * @param {{foo: ?number, bar: string}} x - this is object param.
//  * @param {{foo, bar}} x - this is object param.
import {Expression} from "./Expression";
/**
 * @return {string}
 */
export function RecordType(tag, CodeGenerator) {
    const fields = tag.type.fields;
    const isFiledType = filed => filed.type === "FieldType";
    // It is {{}}-self
    const recordTypeAssertion = `typeof ${tag.name} !== "undefined"`;
    // These are {{ xxx }}
    const propertyAssertions = fields.filter(isFiledType).map(field => {
        const fieldPath = `${tag.name}.${field.key}`;
        return Expression(fieldPath, field.value);
    });
    // join &&
    const expression = [recordTypeAssertion].concat(propertyAssertions).join(" && ");
    return CodeGenerator.assert(expression);
}