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

TypeScript io-ts.union函数代码示例

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

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



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

示例1:

export const createConfigurationBlockInterface = (
  configType: t.LiteralType<string> | t.UnionType<Array<t.LiteralType<string>>> = t.union(
    configBlockSchemas.map(s => t.literal(s.id))
  ),
  beatConfigInterface: t.Mixed = t.Dictionary
) =>
  t.interface(
    {
      id: t.union([t.undefined, t.string]),
      type: configType,
      description: t.union([t.undefined, t.string]),
      tag: t.string,
      config: beatConfigInterface,
      last_updated: t.union([t.undefined, t.number]),
    },
    'ConfigBlock'
  );
开发者ID:elastic,项目名称:kibana,代码行数:17,代码来源:domain_types.ts


示例2: if

      (props, config) => {
        if (config.options) {
          props[config.id] = t.union(config.options.map(opt => t.literal(opt.value)));
        } else if (config.validation) {
          props[config.id] = validationMap[config.validation];
        }

        return props;
      },
开发者ID:elastic,项目名称:kibana,代码行数:9,代码来源:config_block_validation.ts


示例3:

 (self) => t.intersection([
   RWebpackStatsModuleBase,
   t.type({
     // More levels of modules.
     // https://webpack.js.org/api/stats/#module-objects
     modules: t.array(t.union([
       RWebpackStatsModuleSource,
       self,
     ])),
   }),
 ]),
开发者ID:FormidableLabs,项目名称:inspectpack,代码行数:11,代码来源:webpack-stats.ts


示例4: registerManagementUI

    iconName: string;
    order?: number;
  }): void;
  registerManagementUI(settings: {
    sectionId?: string;
    name: string;
    basePath: string;
    visable?: boolean;
    order?: number;
  }): void;
}

export const RuntimeFrameworkInfo = t.type({
  basePath: t.string,
  license: t.type({
    type: t.union(LICENSES.map(s => t.literal(s))),
    expired: t.boolean,
    expiry_date_in_millis: t.number,
  }),
  security: t.type({
    enabled: t.boolean,
    available: t.boolean,
  }),
  settings: t.type({
    encryptionKey: t.string,
    enrollmentTokensTtlInSeconds: t.number,
    defaultUserRoles: t.array(t.string),
  }),
});

export interface FrameworkInfo extends t.TypeOf<typeof RuntimeFrameworkInfo> {}
开发者ID:lucabelluccini,项目名称:kibana,代码行数:31,代码来源:adapter_types.ts


示例5: getVolume

  amountStaked: BigNumberType;
}

export interface PlatformActivityResult {
  activeUsers: BigNumber;
  numberOfTrades: BigNumber;
  openInterest: BigNumber;
  marketsCreated: BigNumber;
  volume: BigNumber;
  amountStaked: BigNumber;
  disputedMarkets: BigNumber;
}

export const PlatformActivityStatsParams = t.type({
  universe: t.string,
  endTime: t.union([t.number, t.null]),
  startTime: t.union([t.number, t.null]),
});
export type PlatformActivityStatsParamsType = t.TypeOf<typeof PlatformActivityStatsParams>;

async function getVolume(db: Knex, startBlock: number, endBlock: number, params: PlatformActivityStatsParamsType): Promise<Knex.QueryBuilder> {
  return db
    .select("amount as volume")
    .from("trades")
    .innerJoin("markets", "markets.marketId", "trades.marketId")
    .whereBetween("trades.blockNumber", [startBlock, endBlock])
    .andWhere("markets.universe", params.universe);
}

async function getAmountStaked(db: Knex, startBlock: number, endBlock: number, params: PlatformActivityStatsParamsType): Promise<Knex.QueryBuilder> {
  return db
开发者ID:AugurProject,项目名称:augur_node,代码行数:31,代码来源:get-platform-activity-stats.ts


示例6: getInitialReporters

import * as t from "io-ts";
import * as Knex from "knex";
import { formatBigNumberAsFixed } from "../../utils/format-big-number-as-fixed";
import { InitialReportersRow, UIInitialReporters } from "../../types";

export const InitialReportersParams = t.type({
  universe: t.string,
  reporter: t.string,
  redeemed: t.union([t.boolean, t.null, t.undefined]),
  withRepBalance: t.union([t.boolean, t.null, t.undefined]),
});

export async function getInitialReporters(db: Knex, augur: {}, params: t.TypeOf<typeof InitialReportersParams>) {
  const query = db("initial_reports")
    .select(["marketID", "reporter", "amountStaked", "initialReporter", "redeemed", "isDesignatedReporter", "balances.balance AS repBalance"])
    .select(["transactionHash", "initial_reports.blockNumber", "logIndex", "blocks.timestamp"])
    .join("balances", "balances.owner", "=", "initial_reports.initialReporter")
    .join("universes", "universes.reputationToken", "balances.token")
    .join("blocks", "initial_reports.blockNumber", "blocks.blockNumber")
    .where("reporter", params.reporter)
    .where("universes.universe", params.universe);
  if (params.withRepBalance) query.where("repBalance", ">", "0");
  if (params.redeemed != null) query.where("redeemed", params.redeemed);
  const initialReporters: Array<InitialReportersRow<BigNumber>> = await query;
  return initialReporters.reduce((acc: UIInitialReporters<string>, cur) => {
    acc[cur.initialReporter] = formatBigNumberAsFixed<InitialReportersRow<BigNumber>, InitialReportersRow<string>>(cur);
    return acc;
  }, {});
}
开发者ID:AugurProject,项目名称:augur_node,代码行数:29,代码来源:get-initial-reporters.ts


示例7: getDisputeTokens

import * as t from "io-ts";
import * as Knex from "knex";
import { formatBigNumberAsFixed } from "../../utils/format-big-number-as-fixed";
import { ReportingState, DisputeTokensRowWithTokenState, UIDisputeTokens, UIDisputeTokenInfo } from "../../types";
import { reshapeDisputeTokensRowToUIDisputeTokenInfo } from "./database";

export const DisputeTokenState = t.keyof({
  ALL: null,
  UNCLAIMED: null,
  UNFINALIZED: null,
});

export const DisputeTokensParams = t.type({
  universe: t.string,
  account: t.string,
  stakeTokenState: t.union([DisputeTokenState, t.null, t.undefined]),
});

export async function getDisputeTokens(db: Knex, augur: {}, params: t.TypeOf<typeof DisputeTokensParams>) {
  const query: Knex.QueryBuilder = db.select(["payouts.*", "disputes.crowdsourcerId as disputeToken", "balances.balance", "market_state.reportingState"]).from("disputes");
  query.join("markets", "markets.marketId", "crowdsourcers.marketId");
  query.leftJoin("market_state", "markets.marketStateId", "market_state.marketStateId");
  query.leftJoin("blocks", "markets.creationBlockNumber", "blocks.blockNumber");
  query.join("crowdsourcers", "crowdsourcers.crowdsourcerId", "disputes.crowdsourcerId");
  query.join("payouts", "payouts.payoutId", "crowdsourcers.payoutId");
  query.join("balances", "crowdsourcers.crowdsourcerId", "balances.token");
  query.where("universe", params.universe).where("disputes.reporter", params.account).where("balances.balance", ">", 0).where("balances.owner", params.account);
  if (params.stakeTokenState == null || params.stakeTokenState === "ALL") {
    // currently, do nothing, leaving this in case we want to flavor how we group or present response
  } else if (params.stakeTokenState === "UNFINALIZED") {
    query.whereNot("market_state.reportingState", ReportingState.FINALIZED);
开发者ID:AugurProject,项目名称:augur_node,代码行数:31,代码来源:get-dispute-tokens.ts


示例8:

export const unionWithNullType = <T extends runtimeTypes.Mixed>(type: T) =>
  runtimeTypes.union([type, runtimeTypes.null]);
开发者ID:,项目名称:,代码行数:2,代码来源:


示例9: getMarkets

import * as t from "io-ts";
import * as Knex from "knex";
import { Address, MarketsContractAddressRow, SortLimitParams } from "../../types";
import { getMarketsWithReportingState, queryModifier } from "./database";
import { createSearchProvider } from "../../database/fts";

export const GetMarketsParamsSpecific = t.type({
  universe: t.string,
  creator: t.union([t.string, t.null, t.undefined]),
  category: t.union([t.string, t.null, t.undefined]),
  search: t.union([t.string, t.null, t.undefined]),
  reportingState: t.union([t.string, t.null, t.undefined, t.array(t.string)]), // filter markets by ReportingState. If non-empty, expected to be a ReportingState or ReportingState[]
  feeWindow: t.union([t.string, t.null, t.undefined]),
  designatedReporter: t.union([t.string, t.null, t.undefined]),
  maxFee: t.union([t.number, t.null, t.undefined]),
  hasOrders: t.union([t.boolean, t.null, t.undefined]),
});

export const GetMarketsParams = t.intersection([
  GetMarketsParamsSpecific,
  SortLimitParams,
]);

// Returning marketIds should likely be more generalized, since it is a single line change for most getters (awaiting reporting, by user, etc)
export async function getMarkets(db: Knex, augur: {}, params: t.TypeOf<typeof GetMarketsParams>) {
  const columns = ["markets.marketId", "marketStateBlock.timestamp as reportingStateUpdatedOn"];
  const query = getMarketsWithReportingState(db, columns);
  query.join("blocks as marketStateBlock", "marketStateBlock.blockNumber", "market_state.blockNumber");
  query.leftJoin("blocks as lastTradeBlock", "lastTradeBlock.blockNumber", "markets.lastTradeBlockNumber").select("lastTradeBlock.timestamp as lastTradeTime");

  if (params.universe != null) query.where("universe", params.universe);
开发者ID:AugurProject,项目名称:augur_node,代码行数:31,代码来源:get-markets.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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