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

TypeScript wildcard.isWildcard函数代码示例

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

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



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

示例1:

  return encodings.reduce((encodingMixins, encQ) => {
    if (isWildcard(encQ.channel)) {
      encodingMixins.anyEncodings.push(encQ);
    } else {
      const {channel: _, ...fieldDef} = encQ;
      encodingMixins.encoding[encQ.channel] = fieldDef;
    }

    return encodingMixins;
  }, {encoding: {}, anyEncodings: []});
开发者ID:rpmunoz,项目名称:voyager,代码行数:10,代码来源:encoding.ts


示例2: hasWildcards

export function hasWildcards(spec: SpecQuery): HasWildcard {
  let hasWildcardField = false, hasWildcardFn = false, hasWildcardChannel = false;
  for (const encQ of spec.encodings) {
    if (isValueQuery(encQ)) {
      continue;
    } else if (isAutoCountQuery(encQ)) {
      if (isWildcard(encQ.autoCount)) {
        hasWildcardFn = true;
      }
    } else { // encQ is FieldQuery
      if (isWildcard(encQ.field)) {
        hasWildcardField = true;
      }

      if (isWildcard(encQ.aggregate) ||
          isWildcard(encQ.bin) ||
          isWildcard(encQ.timeUnit)) {
        hasWildcardFn = true;
      }

      if (isWildcard(encQ.channel)) {
        hasWildcardChannel = true;
      }
    }
  }
  return {
    hasAnyWildcard: hasWildcardChannel || hasWildcardField || hasWildcardFn,
    hasWildcardField,
    hasWildcardFn,
    hasWildcardChannel
  };
}
开发者ID:rpmunoz,项目名称:voyager,代码行数:32,代码来源:spec.ts


示例3: isWildcardChannelId

export function isWildcardChannelId(shelfId: ShelfId): shelfId is ShelfWildcardChannelId {
  return isWildcard(shelfId.channel);
}
开发者ID:rpmunoz,项目名称:voyager,代码行数:3,代码来源:encoding.ts


示例4: shelfSpecReducer

export function shelfSpecReducer(shelfSpec: Readonly<ShelfUnitSpec> = DEFAULT_SHELF_UNIT_SPEC,
                                 action: Action,
                                 schema: Schema): ShelfUnitSpec {
  switch (action.type) {
    case SHELF_CLEAR:
      return DEFAULT_SHELF_UNIT_SPEC;

    case SHELF_MARK_CHANGE_TYPE: {
      const mark = action.payload;
      return {
        ...shelfSpec,
        mark
      };
    }

    case SHELF_FIELD_ADD: {
      const {shelfId, fieldDef} = action.payload;
      return addEncoding(shelfSpec, shelfId, fieldDef);
    }

    case SHELF_FIELD_AUTO_ADD: {
      const {fieldDef} = action.payload;

      if (shelfSpec.anyEncodings.length > 0 || isWildcard(fieldDef.field)) {
        // If there was an encoding shelf or if the field is a wildcard, just add to wildcard shelf
        return {
          ...shelfSpec,
          anyEncodings: [
            ...shelfSpec.anyEncodings,
            {
              channel: SHORT_WILDCARD,
              ...fieldDef
            }
          ]
        };
      } else {
        // Otherwise, query for the best encoding if there is no wildcard channel
        const query = autoAddFieldQuery(shelfSpec, fieldDef);
        const rec = recommend(query, schema);
        const topSpecQuery = getTopSpecQueryItem(rec.result).specQuery;

        return {
          ...fromSpecQuery(topSpecQuery, shelfSpec.config),
          // retain auto-mark if mark is previously auto
          ...(isWildcard(shelfSpec.mark) ? {mark: shelfSpec.mark} : {})
        };
      }
    }

    case SHELF_FIELD_REMOVE:
      return removeEncoding(shelfSpec, action.payload).shelf;

    case SHELF_FIELD_MOVE: {
      const {to, from} = action.payload;

      const {fieldDef: fieldDefFrom, shelf: removedShelf1} = removeEncoding(shelfSpec, from);
      const {fieldDef: fieldDefTo, shelf: removedShelf2} = removeEncoding(removedShelf1, to);

      const addedShelf1 = addEncoding(removedShelf2, to, fieldDefFrom);
      const addedShelf2 = addEncoding(addedShelf1, from, fieldDefTo);

      return addedShelf2;
    }

    case SHELF_FUNCTION_CHANGE: {
      const {shelfId, fn} = action.payload;

      return modifyEncoding(shelfSpec, shelfId, (fieldDef: Readonly<ShelfFieldDef | ShelfAnyEncodingDef>) => {
        // Remove all existing functions then assign new function
        const {aggregate: _a, bin: _b, timeUnit: _t, hasFn: _h, ...newFieldDef} = fieldDef;

        return {
          ...newFieldDef,
          ...(getFunctionMixins(fn))
        };
      });
    }

    case SHELF_SPEC_LOAD:
      const {spec} = action.payload;
      const specQ = isWildcard(shelfSpec.mark) ? {
        ...fromSpec(spec),
        mark: SHORT_WILDCARD
      } : fromSpec(spec);

      // Restore wildcard mark if the shelf previously has wildcard mark.
      return fromSpecQuery(specQ, shelfSpec.config);
  }
  return shelfSpec;
}
开发者ID:rpmunoz,项目名称:voyager,代码行数:90,代码来源:spec.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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