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


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

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


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

示例1:

 (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

示例2:

  title: GameNameType,
}))

// tslint:disable-next-line no-empty-interface
export interface CreateGameRequest extends t.TypeOf<typeof CreateGameRequestType> {}

const PositionType = t.exact(t.type({
  row: t.string,
  col: t.string,
}))

export const MoveRequestType = t.exact(t.intersection([
  t.type({
    from: PositionType,
    dest: PositionType,
  }),
  t.partial({
    promotionType: t.string,
  }),
]))

// tslint:disable-next-line no-empty-interface
export interface MoveRequest extends t.TypeOf<typeof MoveRequestType> {}

export interface ApiUser {
  id: string
  name: string
  email: string
}

export interface ApiGameInfo {
开发者ID:Majavapaja,项目名称:Mursushakki,代码行数:31,代码来源:types.ts

示例3:

export const C5TCurrentVector_Primitives_IO = C5TCurrent.Vector_IO(Primitives_IO);
export type C5TCurrentVector_Primitives = iots.TypeOf<typeof C5TCurrentVector_Primitives_IO>;

export const C5TCurrentPair_C5TCurrentString_Primitives_IO = C5TCurrent.Pair_IO(C5TCurrent.String_IO, Primitives_IO);
export type C5TCurrentPair_C5TCurrentString_Primitives = iots.TypeOf<typeof C5TCurrentPair_C5TCurrentString_Primitives_IO>;

export const C5TCurrentOptional_Primitives_IO = C5TCurrent.Optional_IO(Primitives_IO);
export type C5TCurrentOptional_Primitives = iots.TypeOf<typeof C5TCurrentOptional_Primitives_IO>;

export const A_IO = iots.interface({
  a: C5TCurrent.Int32_IO,
}, 'A');
export type A = iots.TypeOf<typeof A_IO>;

export const B_IO = iots.intersection([ A_IO, iots.interface({
  b: C5TCurrent.Int32_IO,
}) ], 'B');
export type B = iots.TypeOf<typeof B_IO>;

export const B2_IO = iots.intersection([ A_IO ], 'B2');
export type B2 = iots.TypeOf<typeof B2_IO>;

export const Empty_IO = iots.interface({}, 'Empty');
export type Empty = iots.TypeOf<typeof Empty_IO>;

export const X_IO = iots.interface({
  x: C5TCurrent.Int32_IO,
}, 'X');
export type X = iots.TypeOf<typeof X_IO>;

export const E_IO = C5TCurrent.Enum_IO('E');
开发者ID:grixa,项目名称:Current,代码行数:31,代码来源:smoke_test_struct.ts

示例4: getOrders

import { formatBigNumberAsFixed } from "../../utils/format-big-number-as-fixed";

export const OrdersParamsSpecific = t.type({
  universe: t.union([t.string, t.null, t.undefined]),
  marketId: t.union([t.string, t.null, t.undefined]),
  outcome: t.union([OutcomeParam, t.number, t.null, t.undefined]),
  orderType: t.union([t.string, t.null, t.undefined]),
  creator: t.union([t.string, t.null, t.undefined]),
  orderState: t.union([t.string, t.null, t.undefined]),
  orphaned: t.union([t.boolean, t.null, t.undefined]),
  earliestCreationTime: t.union([t.number, t.null, t.undefined]),
  latestCreationTime: t.union([t.number, t.null, t.undefined]),
});

export const OrdersParams = t.intersection([
  OrdersParamsSpecific,
  SortLimitParams,
]);

interface OrdersRowWithCreationTimeAndCanceled extends OrdersRow<BigNumber> {
  creationTime: number;
  canceledBlockNumber: Bytes32|null;
  canceledTransactionHash: Bytes32|null;
  canceledTime: number;
}

export async function getOrders(db: Knex, augur: {}, params: t.TypeOf<typeof OrdersParams>): Promise<UIOrders<string>> {
  if (params.universe == null && params.marketId == null) throw new Error("Must provide universe, either via universe or marketId");
  const queryData: {} = _.omitBy({
    "universe": params.universe,
    "outcome": params.outcome,
    "orderType": params.orderType,
开发者ID:AugurProject,项目名称:augur_node,代码行数:32,代码来源:get-orders.ts

示例5:

import { fixedPointToDecimal, numTicksToTickSize } from "../../utils/convert-fixed-point-to-decimal";
import { Percent, safePercent, Tokens } from "../../utils/dimension-quantity";
import { getRealizedProfitPercent, getTotalProfitPercent, getUnrealizedProfitPercent } from "../../utils/financial-math";
import { getAllOutcomesProfitLoss, ProfitLossResult } from "./get-profit-loss";

export const UserTradingPositionsParamsSpecific = t.type({
  universe: t.union([t.string, t.null, t.undefined]),
  marketId: t.union([t.string, t.null, t.undefined]),
  account: t.union([t.string, t.null, t.undefined]),
  outcome: t.union([OutcomeParam, t.number, t.null, t.undefined]),
});

export const UserTradingPositionsParams = t.intersection([
  UserTradingPositionsParamsSpecific,
  SortLimitParams,
  t.partial({
    endTime: t.number,
  }),
]);

// TradingPosition represents a user's current or historical
// trading activity in one market outcome. See NetPosition.
export interface TradingPosition extends ProfitLossResult, FrozenFunds {
  position: string;
}

// AggregatedTradingPosition is an aggregation of TradingPosition for some
// scope, eg. an aggregation of all TradingPosition in a user's portfolio.
export interface AggregatedTradingPosition extends Pick<ProfitLossResult,
  "realized" | "unrealized" | "total" | "unrealizedCost" | "realizedCost" | "totalCost" | "realizedPercent" |
  "unrealizedPercent" | "totalPercent" | "unrealizedRevenue" | "unrealizedRevenue24hAgo" | "unrealizedRevenue24hChangePercent"
开发者ID:AugurProject,项目名称:augur_node,代码行数:31,代码来源:get-user-trading-positions.ts

示例6: useAppContext

import { useAppContext } from './useAppContext';

// Typed app routing via brilliant gcanti/io-ts.
// Soon in Next.js: https://twitter.com/timneutkens/status/1109092151907045376

const AppHrefIO = t.union([
  t.type({ pathname: t.literal('/') }),
  t.type({ pathname: t.literal('/me') }),
  t.type({ pathname: t.literal('https://twitter.com/steida') }),
  t.type({
    pathname: t.literal('/web'),
    query: t.type({ id: t.string }),
  }),
  // https://github.com/gcanti/io-ts#mixing-required-and-optional-props
  t.intersection([
    t.type({ pathname: t.literal('/signin') }),
    t.partial({ query: t.type({ redirectUrl: t.string }) }),
  ]),
]);

export type AppHref = t.TypeOf<typeof AppHrefIO>;

export const useAppHref = () => {
  const { router } = useAppContext();

  // This should be memoized globally. In serverless, it means per request :-)
  const current = useMemo<AppHref | undefined>(() => {
    let maybeAppHref: AppHref | undefined;
    const routerAppHref = { pathname: router.pathname, query: router.query };
    AppHrefIO.decode(routerAppHref).fold(
      _errors => {}, // No need to report unmatched app href.
      value => {
开发者ID:este,项目名称:este,代码行数:32,代码来源:useAppHref.ts

示例7: getReportingHistory

import * as Knex from "knex";
import { JoinedReportsMarketsRow, SortLimitParams, UIReport } from "../../types";
import { formatBigNumberAsFixed } from "../../utils/format-big-number-as-fixed";
import { queryModifier } from "./database";

export const ReportingHistoryParamsSpecific = t.type({
  reporter: t.string,
  universe: t.union([t.string, t.null, t.undefined]),
  marketId: t.union([t.string, t.null, t.undefined]),
  feeWindow: t.union([t.string, t.null, t.undefined]),
  earliestCreationTime: t.union([t.number, t.null, t.undefined]),
  latestCreationTime: t.union([t.number, t.null, t.undefined]),
});

export const ReportingHistoryParams = t.intersection([
  ReportingHistoryParamsSpecific,
  SortLimitParams,
]);

export interface UIReports<BigNumberType> {
  [universe: string]: {
    [marketId: string]: {
      crowdsourcers: Array<UIReport<BigNumberType>>;
      initialReporter: UIReport<BigNumberType>|null;
    },
  };
}

// Look up a user's reporting history (i.e., all reports submitted by a given reporter); should take reporter (address) as a required parameter and take market, universe, and feeWindow all as optional parameters. For reporting windows that are complete, should also include the consensus outcome, whether the user's report matched the consensus, how much REP the user gained or lost from redistribution, and how much the user earned in reporting fees.
export async function getReportingHistory(db: Knex, augur: {}, params: t.TypeOf<typeof ReportingHistoryParams>): Promise<UIReports<string>> {
  if (params.universe == null && params.marketId == null && params.feeWindow == null) throw new Error("Must provide reference to universe, specify universe, marketId, or feeWindow");
开发者ID:AugurProject,项目名称:augur_node,代码行数:31,代码来源:get-reporting-history.ts

示例8:

    pod: runtimeTypes.string,
    tiebreaker: runtimeTypes.string,
    timestamp: runtimeTypes.string,
  }),
});

export interface InfraSourceConfiguration
  extends runtimeTypes.TypeOf<typeof InfraSourceConfigurationRuntimeType> {}

export const PartialInfraSourceConfigurationRuntimeType = runtimeTypes.partial({
  ...InfraSourceConfigurationRuntimeType.props,
  fields: runtimeTypes.partial(InfraSourceConfigurationRuntimeType.props.fields.props),
});

export interface PartialInfraSourceConfiguration
  extends runtimeTypes.TypeOf<typeof PartialInfraSourceConfigurationRuntimeType> {}

export const InfraSavedSourceConfigurationRuntimeType = runtimeTypes.intersection([
  runtimeTypes.type({
    id: runtimeTypes.string,
    attributes: PartialInfraSourceConfigurationRuntimeType,
  }),
  runtimeTypes.partial({
    version: runtimeTypes.string,
    updated_at: TimestampFromString,
  }),
]);

export interface InfraSavedSourceConfiguration
  extends runtimeTypes.TypeOf<typeof InfraSavedSourceConfigurationRuntimeType> {}
开发者ID:lucabelluccini,项目名称:kibana,代码行数:30,代码来源:types.ts

示例9:

import * as t from "io-ts";
import * as Knex from "knex";
import { Address, Bytes32, SortLimitParams } from "../../types";
import { queryModifier } from "./database";
import { formatBigNumberAsFixed } from "../../utils/format-big-number-as-fixed";

export const AccountTransferHistoryParamsSpecific = t.type({
  account: t.string,
  token: t.union([t.string, t.null, t.undefined]),
  isInternalTransfer: t.union([t.boolean, t.null, t.undefined]),
  earliestCreationTime: t.union([t.number, t.null, t.undefined]),
  latestCreationTime: t.union([t.number, t.null, t.undefined]),
});

export const AccountTransferHistoryParams = t.intersection([
  AccountTransferHistoryParamsSpecific,
  SortLimitParams,
]);

export interface TransferRow<BigNumberType> {
  transactionHash: Bytes32;
  logIndex: number;
  blockNumber: number;
  blockHash: string;
  timestamp: number;
  sender: Address;
  recipient: Address;
  token: Address;
  value: BigNumberType;
  symbol: string|null;
  outcome: number|null;
  marketId: Address|null;
开发者ID:AugurProject,项目名称:augur_node,代码行数:32,代码来源:get-account-transfer-history.ts

示例10:

/* eslint-disable @typescript-eslint/no-empty-interface */

import * as runtimeTypes from 'io-ts';

import { unionWithNullType } from '../framework';

/*
 *  Note Types
 */
export const SavedPinnedEventRuntimeType = runtimeTypes.intersection([
  runtimeTypes.type({
    timelineId: runtimeTypes.string,
    eventId: runtimeTypes.string,
  }),
  runtimeTypes.partial({
    created: runtimeTypes.number,
    createdBy: runtimeTypes.string,
    updated: runtimeTypes.number,
    updatedBy: runtimeTypes.string,
  }),
]);

export interface SavedPinnedEvent extends runtimeTypes.TypeOf<typeof SavedPinnedEventRuntimeType> {}

/**
 * Note Saved object type with metadata
 */

export const PinnedEventSavedObjectRuntimeType = runtimeTypes.intersection([
  runtimeTypes.type({
    id: runtimeTypes.string,
开发者ID:,项目名称:,代码行数:31,代码来源:


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