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

TypeScript fp.isFinite函数代码示例

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

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



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

示例1: function

      function(
        { runningDimensions, topLeftCorner, bottomRightCorner },
        entity: PvjsonSingleFreeNode | PvjsonEdge
      ) {
        const { zIndex } = entity;
        const zIndexIsFinite = isFinite(zIndex);
        const runningDimensionsZIndexIsFinite = isFinite(
          runningDimensions.zIndex
        );
        if (zIndexIsFinite && runningDimensionsZIndexIsFinite) {
          runningDimensions.zIndex = Math.min(zIndex, runningDimensions.zIndex);
        } else if (zIndexIsFinite) {
          runningDimensions.zIndex = zIndex;
        }

        if (isPvjsonEdge(entity)) {
          const points = entity.points;
          // If entity is an edge
          const firstPoint = points[0];
          const firstPointX = firstPoint.x;
          const firstPointY = firstPoint.y;
          const lastPoint = points[points.length - 1];
          const lastPointX = lastPoint.x;
          const lastPointY = lastPoint.y;
          topLeftCorner.x = Math.min(topLeftCorner.x, firstPointX, lastPointX);
          topLeftCorner.y = Math.min(topLeftCorner.y, firstPointY, lastPointY);
          bottomRightCorner.x = Math.max(
            bottomRightCorner.x,
            firstPointX,
            lastPointX
          );
          bottomRightCorner.y = Math.max(
            bottomRightCorner.y,
            firstPointY,
            lastPointY
          );
        } else {
          // If entity is a node
          topLeftCorner.x = Math.min(topLeftCorner.x, entity.x);
          topLeftCorner.y = Math.min(topLeftCorner.y, entity.y);
          bottomRightCorner.x = Math.max(
            bottomRightCorner.x,
            entity.x + entity.width
          );
          bottomRightCorner.y = Math.max(
            bottomRightCorner.y,
            entity.y + entity.height
          );
        }

        runningDimensions.x = topLeftCorner.x - padding - strokeWidth;
        runningDimensions.y = topLeftCorner.y - padding - strokeWidth;
        runningDimensions.width =
          bottomRightCorner.x - topLeftCorner.x + 2 * (padding + strokeWidth);
        runningDimensions.height =
          bottomRightCorner.y - topLeftCorner.y + 2 * (padding + strokeWidth);

        return { runningDimensions, topLeftCorner, bottomRightCorner };
      },
开发者ID:wikipathways,项目名称:gpml2pvjson-js,代码行数:59,代码来源:group.ts


示例2: getOffsetAndOrientationScalarsAlongAxis

/**
 * getOffsetAndOrientationScalarsAlongAxis
 *
 * @param relValue {number}
 * @param axis {string}
 * @param referencedEntity
 * @return {OffsetOrientationAndPositionScalarsAlongAxis}
 */
function getOffsetAndOrientationScalarsAlongAxis(
  positionScalar: number,
  relativeOffsetScalar: number,
  axis: "x" | "y",
  // TODO are we correctly handling the case of a group as the referenced
  // entity? Do we have the group width and height yet to properly calculate
  // this?
  referencedEntity: PvjsonNode
): OffsetOrientationAndPositionScalarsAlongAxis {
  let offsetScalar =
    relativeOffsetScalar *
    (axis === "x" ? referencedEntity.width : referencedEntity.height);
  // TODO WP536 has a referenced entity that lacks width/height. Why?
  // The referenced entity was a group.
  // Is the problem that the group was nested?
  // Or is it a problem with the order of evaluation of entities (trying to
  //   parse a dependent entity before its dependencies were parsed)?
  if (!isFinite(offsetScalar)) {
    throw new Error(
      `
			Got non-finite value ${offsetScalar} for offsetScalar
			along ${axis} axis for
			getOffsetAndOrientationScalarsAlongAxis(
				positionScalar=${positionScalar},
				relativeOffsetScalar=${relativeOffsetScalar},
				referencedEntity=
				${JSON.stringify(referencedEntity, null, "  ")}
			)
		`
    );
  }

  // orientationScalar here refers to the initial direction the edge takes as
  // it moves away from the entity to which it is attached.
  let orientationScalar;
  if (positionScalar === 0) {
    orientationScalar = -1;
  } else if (positionScalar === 1) {
    orientationScalar = 1;
  } else {
    orientationScalar = 0;
  }

  return { offsetScalar, orientationScalar, positionScalar };
}
开发者ID:wikipathways,项目名称:gpml2pvjson-js,代码行数:53,代码来源:edge.ts


示例3:

 .filter(dims => !isFinite(dims[1]));
开发者ID:wikipathways,项目名称:gpml2pvjson-js,代码行数:1,代码来源:group.ts


示例4: getGroupDimensions

export function getGroupDimensions(
  padding: number,
  strokeWidth: number,
  containedEntities: PvjsonEntity[]
): NodeDimensions {
  if (containedEntities.length === 0) {
    console.warn(`Warning: Empty group observed.`);
    return {
      x: 0,
      y: 0,
      width: 0,
      height: 0,
      zIndex: 0
    };
  } else if (!isFinite(padding)) {
    throw new Error("Invalid padding value: ${padding}");
  } else if (!isFinite(strokeWidth)) {
    throw new Error("Invalid strokeWidth value: ${strokeWidth}");
  }
  const dimensions = containedEntities
    .filter(entity => isPvjsonSingleFreeNode(entity) || isPvjsonEdge(entity))
    .reduce(
      function(
        { runningDimensions, topLeftCorner, bottomRightCorner },
        entity: PvjsonSingleFreeNode | PvjsonEdge
      ) {
        const { zIndex } = entity;
        const zIndexIsFinite = isFinite(zIndex);
        const runningDimensionsZIndexIsFinite = isFinite(
          runningDimensions.zIndex
        );
        if (zIndexIsFinite && runningDimensionsZIndexIsFinite) {
          runningDimensions.zIndex = Math.min(zIndex, runningDimensions.zIndex);
        } else if (zIndexIsFinite) {
          runningDimensions.zIndex = zIndex;
        }

        if (isPvjsonEdge(entity)) {
          const points = entity.points;
          // If entity is an edge
          const firstPoint = points[0];
          const firstPointX = firstPoint.x;
          const firstPointY = firstPoint.y;
          const lastPoint = points[points.length - 1];
          const lastPointX = lastPoint.x;
          const lastPointY = lastPoint.y;
          topLeftCorner.x = Math.min(topLeftCorner.x, firstPointX, lastPointX);
          topLeftCorner.y = Math.min(topLeftCorner.y, firstPointY, lastPointY);
          bottomRightCorner.x = Math.max(
            bottomRightCorner.x,
            firstPointX,
            lastPointX
          );
          bottomRightCorner.y = Math.max(
            bottomRightCorner.y,
            firstPointY,
            lastPointY
          );
        } else {
          // If entity is a node
          topLeftCorner.x = Math.min(topLeftCorner.x, entity.x);
          topLeftCorner.y = Math.min(topLeftCorner.y, entity.y);
          bottomRightCorner.x = Math.max(
            bottomRightCorner.x,
            entity.x + entity.width
          );
          bottomRightCorner.y = Math.max(
            bottomRightCorner.y,
            entity.y + entity.height
          );
        }

        runningDimensions.x = topLeftCorner.x - padding - strokeWidth;
        runningDimensions.y = topLeftCorner.y - padding - strokeWidth;
        runningDimensions.width =
          bottomRightCorner.x - topLeftCorner.x + 2 * (padding + strokeWidth);
        runningDimensions.height =
          bottomRightCorner.y - topLeftCorner.y + 2 * (padding + strokeWidth);

        return { runningDimensions, topLeftCorner, bottomRightCorner };
      },
      {
        topLeftCorner: {
          x: Infinity,
          y: Infinity
        },
        bottomRightCorner: {
          x: 0,
          y: 0
        },
        runningDimensions: {
          zIndex: Infinity
        }
      } as {
        topLeftCorner: Corner;
        bottomRightCorner: Corner;
        runningDimensions: NodeDimensions;
      }
    ).runningDimensions;

//.........这里部分代码省略.........
开发者ID:wikipathways,项目名称:gpml2pvjson-js,代码行数:101,代码来源:group.ts


示例5: validateOrientation

export function validateOrientation(orientation: Orientation): boolean {
  return !!orientation && isFinite(orientation[0]) && isFinite(orientation[1]);
}
开发者ID:wikipathways,项目名称:gpml2pvjson-js,代码行数:3,代码来源:orientation.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript fp.isNumber函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fp.isEmpty函数代码示例发布时间: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