当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Map.has方法代码示例

本文整理汇总了TypeScript中Immutable.Map.has方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Map.has方法的具体用法?TypeScript Map.has怎么用?TypeScript Map.has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Immutable.Map的用法示例。


在下文中一共展示了Map.has方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: transform

  /**
   * Brief format for references
   */
  transform(item: Map<string, any>): string {
    let referenceHTML = '';
    let hasRefUrl = false;
    let title = '';
    let author = '';
    let arxivEprint = '';
    let label = '';
    let pubNote = '';
    let reportNumber = '';
    let misc = '';

    hasRefUrl = item.hasIn(['record', '$ref']);

    item = item.get('reference');

    if (!item) {
      return referenceHTML;
    }

    arxivEprint = item.get('arxiv_eprint', '');
    reportNumber = item.getIn(['report_numbers', 0], '');
    if (item.has('label')) {
      label = `[${item.get('label')}] `;
    }

    if (item.has('titles')) {
      title = item.getIn(['titles', 0, 'title'], '');
    }
    if (item.has('authors')) {
      author = item.getIn(['authors', 0, 'full_name'], '') + ' ';
      if (item.get('authors').size > 1) {
        author += 'el al. ';
      }
    }
    if (item.has('publication_info')) {
      pubNote += item.getIn(['publication_info', 'journal_title'], '') + ' ';
      pubNote += item.getIn(['publication_info', 'journal_volume'], '') + ' ';
      pubNote += '(' + item.getIn(['publication_info', 'year'], '') + ') ';
      pubNote += item.getIn(['publication_info', 'artid'], '') + ' ';
    }
    if (!author) {
      if (item.has('collaborations')) {
        author = item.getIn(['collaborations', 0]) + ' ';
      }
    }

    if (!hasRefUrl) {
      misc = item.getIn(['misc', 0], '');
    }

    referenceHTML = label + title + author + pubNote + arxivEprint + reportNumber + misc;

    return referenceHTML;

  }
开发者ID:inspirehep,项目名称:record-editor,代码行数:58,代码来源:reference-brief.ts

示例2: binary

  binary(n: ast.BinaryExpr): string {
    // exponentiation isn't a builtin operator in JS, it
    // is implemented as a function in the Math module.
    if (n.op === '^') {
      const l = n.l.walk(this);
      const r = n.r.walk(this);
      return `Math.pow(${l}, ${r})`;
    } else if (n.op === '=' && n.l instanceof ast.Constant && isNaN(n.l.value)) {
      const r = n.r.walk(this);
      return `isNaN(${r})`;
    } else if (n.op === '=' && n.r instanceof ast.Constant && isNaN(n.r.value)) {
      const l = n.r.walk(this);
      return `isNaN(${l})`;
    }

    let op = n.op;
    // only need to convert some of them
    if (JsOps.has(n.op)) {
      op = defined(JsOps.get(n.op));
    }

    const l = n.l.walk(this);
    const r = n.r.walk(this);
    return `${l} ${op} ${r}`;
  }
开发者ID:bpowers,项目名称:sd.js,代码行数:25,代码来源:vars.ts

示例3: referencedModels

export function referencedModels(
  project: Project,
  mod: Module,
  all?: Map<string, ModelDef>,
): Map<string, ModelDef> {
  if (!all) {
    all = Map();
  }
  const mdl = defined(project.model(mod.modelName));
  const name = mdl.ident;
  if (all.has(name)) {
    const def = defined(all.get(name)).update('modules', (modules: Set<Module>) =>
      modules.add(mod),
    );
    all = all.set(name, def);
  } else {
    all = all.set(
      name,
      new ModelDef({
        model: mdl,
        modules: Set<Module>([mod]),
      }),
    );
  }
  for (const [name, module] of mdl.modules) {
    all = referencedModels(project, module, all);
  }
  return all;
}
开发者ID:bpowers,项目名称:sd.js,代码行数:29,代码来源:vars.ts

示例4: getDiskAllocation

 public getDiskAllocation(disk: any) {
     let allocation;
     if (this.diskUsage.has('attached') && (this.diskUsage.get('attached').has(disk.path) || this.diskUsage.get('attached').has(disk.id))) {
         allocation = {
             name: this.diskUsage.get('attached').get(disk.path) || this.diskUsage.get('attached').get(disk.id),
             type: 'VOLUME'
         };
     } else if (this.diskUsage.has('detached') && (this.diskUsage.get('detached').has(disk.path) || this.diskUsage.get('detached').has(disk.id))) {
         allocation = {
             name: this.diskUsage.get('detached').get(disk.path) || this.diskUsage.get('detached').get(disk.id),
             type: 'EXPORTED_VOLUME'
         };
     } else if (this.diskUsage.has('boot') && (this.diskUsage.get('boot').has(disk.path) || this.diskUsage.get('boot').has(disk.id))) {
         allocation = {
             type: 'BOOT'
         };
     }
     return allocation;
 }
开发者ID:mactanxin,项目名称:gui,代码行数:19,代码来源:disk-repository.ts

示例5: model

  model(name?: string): type.Model | undefined {
    if (!name) {
      name = 'main';
    }
    if (this.models.has(name)) {
      return this.models.get(name);
    }

    return this.models.get('stdlib¡' + name);
  }
开发者ID:sdlabs,项目名称:sd.js,代码行数:10,代码来源:project.ts

示例6: addFile

  addFile(xmileDoc: XMLDocument, isMain = false): [Project, undefined] | [undefined, Error] {
    const [file, err] = Project.parseFile(xmileDoc);
    if (err) {
      return [undefined, err];
    }

    const files = this.files.push(defined(file));

    // FIXME: merge the other parts of the model into the project
    const models = Map(
      defined(file).models.map(
        (xModel): [string, Model] => {
          const model = new Model(this, xModel);
          return [model.ident, model];
        },
      ),
    );

    let dupErr: Error | undefined;
    models.forEach((model, name) => {
      if (this.models.has(name)) {
        dupErr = new Error(`duplicate name ${name}`);
      }
    });
    if (dupErr) {
      return [undefined, dupErr];
    }

    const xMod = new xmile.Variable({
      type: 'module',
      name: 'main',
    });
    const main = new Module(xMod);

    let newProject = this.mergeDeep({
      files,
      models: this.models.merge(models),
      main,
    });

    if (models.has('main') && defined(file).header && defined(defined(file).header).name) {
      newProject = newProject.set('name', defined(defined(file).header).name);
    }

    return [newProject, undefined];
  }
开发者ID:sdlabs,项目名称:sd.js,代码行数:46,代码来源:project.ts

示例7: lexIdentifier

  private lexIdentifier(startPos: SourceLoc): Token {
    const quoted = this.rpeek === '"';

    const line = this.line;
    const pos = this.pos;

    if (quoted) {
      this.nextRune();
    }

    let r: string | null;
    while ((r = this.nextRune())) {
      if (r === null) {
        break;
      }
      if ((isIdentifierStart(r) && r !== '"') || /\d/.test(r)) {
        continue;
      }
      if (quoted) {
        if (r === '"') {
          // eat closing "
          this.nextRune();
          break;
        }
        // any utf-8 chars are valid inside quotes
        continue;
      }
      break;
    }

    const len = this.pos - pos;
    let ident = this.text.substring(pos, pos + len);

    let type = TokenType.IDENT;

    if (reserved.has(ident)) {
      type = TokenType.RESERVED;
    } else if (OP.has(ident)) {
      type = TokenType.TOKEN;
      ident = defined(OP.get(ident));
    }

    return new Token(ident, type, startPos, startPos.off(len));
  }
开发者ID:sdlabs,项目名称:sd.js,代码行数:44,代码来源:lex.ts

示例8:

 _.forEachRight(uiObjects, uiObject => {
     if (!state.has(uiObject.id) && (!objectType || objectType === uiObject._objectType)) {
         uiObjects.splice(_.indexOf(uiObjects, uiObject), 1);
     }
 });
开发者ID:mactanxin,项目名称:gui,代码行数:5,代码来源:data-object-change-service.ts

示例9: isDiskUsed

 private isDiskUsed(disk: any, diskUsage: Map<string, string>) {
     return diskUsage && (diskUsage.has(disk.get('path')) || diskUsage.has(disk.get('id')));
 }
开发者ID:mactanxin,项目名称:gui,代码行数:3,代码来源:disk-repository.ts

示例10: Error

 models.forEach((model, name) => {
   if (this.models.has(name)) {
     dupErr = new Error(`duplicate name ${name}`);
   }
 });
开发者ID:sdlabs,项目名称:sd.js,代码行数:5,代码来源:project.ts


注:本文中的Immutable.Map.has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。