• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript common.defined函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中common.defined函数的典型用法代码示例。如果您正苦于以下问题:TypeScript defined函数的具体用法?TypeScript defined怎么用?TypeScript defined使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: renderMove

export function renderMove(ctx, node): MaybeVNodes {
  const ev = node.eval || node.ceval || {};
  return [
    node.san,
    defined(ev.cp) ? renderEval(normalizeEval(ev.cp)) : (
      defined(ev.mate) ? renderEval('#' + ev.mate) : null
    ),
    puzzleGlyph(ctx, node)
  ];
}
开发者ID:ornicar,项目名称:lila,代码行数:10,代码来源:tree.ts


示例2: renderMove

export function renderMove(ctx: Ctx, node: Tree.Node): VNode[] {
  const ev: any = cevalView.getBestEval({client: node.ceval, server: node.eval}) || {};
  return [h('san', fixCrazySan(node.san!))]
    .concat((node.glyphs && ctx.showGlyphs) ? renderGlyphs(node.glyphs) : [])
    .concat(ctx.showEval ? (
      defined(ev.cp) ? [renderEval(normalizeEval(ev.cp))] : (
        defined(ev.mate) ? [renderEval('#' + ev.mate)] : []
      )
    ) : []);
}
开发者ID:lexisvar,项目名称:lila,代码行数:10,代码来源:moveView.ts


示例3: addNode

 // returns new path
 function addNode(node: Tree.Node, path: Tree.Path): Tree.Path | undefined {
   const newPath = path + node.id;
   var existing = nodeAtPathOrNull(newPath);
   if (existing) {
     if (defined(node.dests) && !defined(existing.dests)) existing.dests = node.dests;
     if (defined(node.drops) && !defined(existing.drops)) existing.drops = node.drops;
     return newPath;
   }
   return updateAt(path, function(parent: Tree.Node) {
     parent.children.push(node);
   }) ? newPath : undefined;
 }
开发者ID:lexisvar,项目名称:lila,代码行数:13,代码来源:tree.ts


示例4: playerTable

function playerTable(ctrl: AnalyseCtrl, color: Color): VNode {
  const d = ctrl.data, trans = ctrl.trans.noarg;
  const acpl = d.analysis![color].acpl;
  return h('table', {
    hook: {
      insert(vnode) {
        window.lichess.powertip.manualUserIn(vnode.elm);
      }
    }
  }, [
    h('thead', h('tr', [
      h('td', h('i.is.color-icon.' + color)),
      h('th', renderPlayer(ctrl, color))
    ])),
    h('tbody',
      advices.map(a => {
        const nb: number = d.analysis![color][a[0]];
        const attrs: VNodeData = nb ? {
          'data-color': color,
          'data-symbol': a[2]
        } : {};
        return h('tr' + (nb ? '.symbol' : ''), { attrs }, [
          h('td', '' + nb),
          h('th', trans(a[1]))
        ]);
      }).concat(
        h('tr', [
          h('td', '' + (defined(acpl) ? acpl : '?')),
          h('th', trans('averageCentipawnLoss'))
        ])
      ))
  ])
}
开发者ID:ornicar,项目名称:lila,代码行数:33,代码来源:acpl.ts


示例5:

 pvs: e.pvs.map(function(from) {
   const to: any = {
     moves: from.moves.split(' ')
   };
   if (defined(from.cp)) to.cp = from.cp;
   else to.mate = from.mate;
   return to;
 }),
开发者ID:luanlv,项目名称:lila,代码行数:8,代码来源:evalCache.ts


示例6: detectThreefold

export function detectThreefold(nodeList, node): void {
  if (defined(node.threefold)) return;
  const currentFen = threefoldFen(node.fen);
  let nbSimilarPositions = 0, i;
  for (i in nodeList)
    if (threefoldFen(nodeList[i].fen) === currentFen)
      nbSimilarPositions++;
  node.threefold = nbSimilarPositions > 2;
};
开发者ID:ddugovic,项目名称:lila,代码行数:9,代码来源:nodeFinder.ts


示例7: range

 }, range(multiPv).map(function(i) {
   if (!pvs[i]) return h('div.pv');
   const san = pv2san(instance.variant.key, node.fen, threat, pvs[i].moves.slice(0, 12), pvs[i].mate);
   return h('div.pv', threat ? {} : {
     attrs: { 'data-uci': pvs[i].moves[0] }
   }, [
     multiPv > 1 ? h('strong', defined(pvs[i].mate) ? ('#' + pvs[i].mate) : renderEval(pvs[i].cp!)) : null,
     h('span', san)
   ]);
 }));
开发者ID:ornicar,项目名称:lila,代码行数:10,代码来源:view.ts


示例8: unselect

 li.pubsub.on('analysis.change', (fen: Fen, _, mainlinePly: Ply | false) => {
   let chart, point, $chart = $("#adv-chart");
   if (fen && fen !== lastFen) {
     inputFen.value = fen;
     lastFen = fen;
   }
   if ($chart.length) {
     chart = window.Highcharts && $chart.highcharts();
     if (chart) {
       if (mainlinePly != chart.lastPly) {
         if (mainlinePly === false) unselect(chart);
         else {
           point = chart.series[0].data[mainlinePly - 1 - data.game.startedAtTurn];
           if (defined(point)) point.select();
           else unselect(chart);
         }
       }
       chart.lastPly = mainlinePly;
     }
   }
   if ($timeChart.length) {
     chart = window.Highcharts && $timeChart.highcharts();
     if (chart) {
       if (mainlinePly != chart.lastPly) {
         if (mainlinePly === false) unselect(chart);
         else {
           const white = mainlinePly % 2 !== 0;
           const serie = white ? 0 : 1;
           const turn = Math.floor((mainlinePly - 1 - data.game.startedAtTurn) / 2);
           point = chart.series[serie].data[turn];
           if (defined(point)) point.select();
           else unselect(chart);
         }
       }
       chart.lastPly = mainlinePly;
     }
   }
 });
开发者ID:ornicar,项目名称:lila,代码行数:38,代码来源:serverSideUnderboard.ts


示例9: lastPly

 li.pubsub.on('analysis.change', (_fen: string, _path: string, mainlinePly: number | false) => {
   if (!li.advantageChart || lastPly() === mainlinePly) return;
   const lp = lastPly(typeof mainlinePly === 'undefined' ? lastPly() : mainlinePly),
   el = chartEl();
   if (el && window.Highcharts) {
     const $chart = $(el);
     if ($chart.length) {
       const chart = $chart.highcharts();
       if (chart) {
         if (lp === false) unselect(chart);
         else {
           const point = chart.series[0].data[lp - 1 - root.tree.root.ply];
           if (defined(point)) point.select();
           else unselect(chart);
         }
       } else lastPly(false);
     }
   } else lastPly(false);
 });
开发者ID:mate-amargo,项目名称:lila,代码行数:19,代码来源:serverEval.ts


示例10: toCeval

// from server eval to client eval
function toCeval(e) {
  const res: any = {
    fen: e.fen,
    nodes: e.knodes * 1000,
    depth: e.depth,
    pvs: e.pvs.map(function(from) {
      const to: any = {
        moves: from.moves.split(' ')
      };
      if (defined(from.cp)) to.cp = from.cp;
      else to.mate = from.mate;
      return to;
    }),
    cloud: true
  };
  if (defined(res.pvs[0].cp)) res.cp = res.pvs[0].cp;
  else res.mate = res.pvs[0].mate;
  res.cloud = true;
  return res;
}
开发者ID:luanlv,项目名称:lila,代码行数:21,代码来源:evalCache.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript common.empty函数代码示例发布时间:2022-05-25
下一篇:
TypeScript comment-json.stringify函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap