當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。