當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript io-ts.type函數代碼示例

本文整理匯總了TypeScript中io-ts.type函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript type函數的具體用法?TypeScript type怎麽用?TypeScript type使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了type函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getStaticDefaultSourceConfiguration

  private async getStaticDefaultSourceConfiguration() {
    const staticConfiguration = await this.libs.configuration.get();
    const staticSourceConfiguration = runtimeTypes
      .type({
        sources: runtimeTypes.type({
          default: PartialInfraSourceConfigurationRuntimeType,
        }),
      })
      .decode(staticConfiguration)
      .map(({ sources: { default: defaultConfiguration } }) => defaultConfiguration)
      .getOrElse({});

    return mergeSourceConfiguration(defaultSourceConfiguration, staticSourceConfiguration);
  }
開發者ID:lucabelluccini,項目名稱:kibana,代碼行數:14,代碼來源:sources.ts

示例2:

 (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

示例3: getAllOrders

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

export const AllOrdersParams = t.type({
  account: t.string,
});

export interface AllOrders {
  [orderId: string]: AllOrdersRow<string>;
}

export async function getAllOrders(db: Knex, augur: {}, params: t.TypeOf<typeof AllOrdersParams>): Promise<AllOrders> {
  const query = db.select(
    [
      "orderId",
      "marketId",
      "originalTokensEscrowed",
      "originalSharesEscrowed",
      "tokensEscrowed",
      "sharesEscrowed",
    ]).from("orders")
    .where("orderCreator", params.account)
    .where("orderState", "OPEN");
  const allOrders: Array<AllOrdersRow<BigNumber>> = await query;
  return allOrders.reduce((acc: AllOrders, cur: AllOrdersRow<BigNumber>) => {
    acc[cur.orderId] = formatBigNumberAsFixed<AllOrdersRow<BigNumber>, AllOrdersRow<string>>({
      orderId: cur.orderId,
      originalTokensEscrowed: cur.originalTokensEscrowed,
      originalSharesEscrowed: cur.originalSharesEscrowed,
開發者ID:AugurProject,項目名稱:augur_node,代碼行數:31,代碼來源:get-all-orders.ts

示例4: unionWithNullType

  updated: unionWithNullType(runtimeTypes.number),
  updatedBy: unionWithNullType(runtimeTypes.string),
});

export interface SavedTimeline extends runtimeTypes.TypeOf<typeof SavedTimelineRuntimeType> {}

export interface SavedTimelineNote extends runtimeTypes.TypeOf<typeof SavedTimelineRuntimeType> {}

/**
 * Timeline Saved object type with metadata
 */

export const TimelineSavedObjectRuntimeType = runtimeTypes.intersection([
  runtimeTypes.type({
    id: runtimeTypes.string,
    attributes: SavedTimelineRuntimeType,
    version: runtimeTypes.string,
  }),
  runtimeTypes.partial({
    savedObjectId: runtimeTypes.string,
  }),
]);

export const TimelineSavedToReturnObjectRuntimeType = runtimeTypes.intersection([
  SavedTimelineRuntimeType,
  runtimeTypes.type({
    savedObjectId: runtimeTypes.string,
    version: runtimeTypes.string,
  }),
  runtimeTypes.partial({
    eventIdToNoteIds: runtimeTypes.array(NoteSavedObjectToReturnRuntimeType),
開發者ID:,項目名稱:,代碼行數:31,代碼來源:

示例5: getSyncData

import * as t from "io-ts";
import * as Knex from "knex";
import Augur from "augur.js";
import { isSyncFinished } from "../../blockchain/bulk-sync-augur-node-with-blockchain";
import { version } from "../../version";

export const NoParams = t.type({
});

export interface UISyncData {
  version: string;
  augurNodeVersion: string;
  net_version: string;
  netId: string;
  isSyncFinished: boolean;
  addresses: {};
  highestBlock: {};
  lastProcessedBlock: {};
}

export async function getSyncData(db: Knex, augur: Augur, params: t.TypeOf<typeof NoParams>): Promise<UISyncData> {
  const currentBlock = augur.rpc.getCurrentBlock();
  const highestBlock = {
    number: parseInt(currentBlock.number, 16),
    hash: currentBlock.hash,
    timestamp: parseInt(currentBlock.timestamp, 16),
  };
  const lastProcessedBlock = await db("blocks").first(["blockNumber as number", "blockHash as hash", "timestamp"]).orderBy("blockNumber", "DESC");
  return {
    version: augur.version,
    augurNodeVersion: version,
開發者ID:AugurProject,項目名稱:augur_node,代碼行數:31,代碼來源:get-sync-data.ts

示例6: getForkMigrationTotals

import * as t from "io-ts";
import * as Knex from "knex";
import Augur from "augur.js";
import { BigNumber } from "bignumber.js";
import { ForkMigrationTotalsRow, UIForkMigrationTotals, UIForkMigrationTotalsRow } from "../../types";
import { formatBigNumberAsFixed } from "../../utils/format-big-number-as-fixed";

export const ForkMigrationTotalsParams = t.type({
  parentUniverse: t.string,
});

export async function getForkMigrationTotals(db: Knex, augur: Augur, params: t.TypeOf<typeof ForkMigrationTotalsParams>) {
  const query = db.select([
      "universe",
      "payouts.isInvalid",
      "payouts.payout0",
      "payouts.payout1",
      "payouts.payout2",
      "payouts.payout3",
      "payouts.payout4",
      "payouts.payout5",
      "payouts.payout6",
      "payouts.payout7",
      "token_supply.supply AS repTotal"]).from("universes")
    .join("token_supply", "universes.reputationToken", "token_supply.token")
    .join("payouts", "payouts.marketId", "universes.universe")
    .where("universes.parentUniverse", params.parentUniverse);

  const forkMigrationTotals: Array<ForkMigrationTotalsRow<BigNumber>> = await query;
  return forkMigrationTotals.reduce((acc: UIForkMigrationTotals<string>, cur) => {
    const payout: Array<string> = [
開發者ID:AugurProject,項目名稱:augur_node,代碼行數:31,代碼來源:get-fork-migration-totals.ts

示例7: moment

    runtimeTypes.string.validate(input, context).chain(stringInput => {
      const momentValue = moment(stringInput);
      return momentValue.isValid()
        ? runtimeTypes.success(momentValue.valueOf())
        : runtimeTypes.failure(stringInput, context);
    }),
  output => new Date(output).toISOString()
);

export const InfraSourceConfigurationRuntimeType = runtimeTypes.type({
  name: runtimeTypes.string,
  description: runtimeTypes.string,
  metricAlias: runtimeTypes.string,
  logAlias: runtimeTypes.string,
  fields: runtimeTypes.type({
    container: runtimeTypes.string,
    host: runtimeTypes.string,
    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),
});
開發者ID:lucabelluccini,項目名稱:kibana,代碼行數:30,代碼來源:types.ts

示例8: getCategoriesRows

import * as t from "io-ts";
import * as Knex from "knex";
import * as _ from "lodash";
import Augur from "augur.js";
import BigNumber from "bignumber.js";
import { CategoriesRow, UICategory, TagAggregation, ReportingState } from "../../types";

export const CategoriesParams = t.type({
  universe: t.string,
});

interface MarketsTagRow {
  category: string;
  openInterest: BigNumber;
  reportingState: ReportingState;
  tag1: string;
  tag2: string;
}

export async function getCategoriesRows(db: Knex, universe: string): Promise<Array<CategoriesRow<BigNumber>>> {
  return db.select(["category", "nonFinalizedOpenInterest", "openInterest", "universe"]).from("categories").where({ universe });
}

export async function getMarketsTagRows(db: Knex, universe: string): Promise<Array<MarketsTagRow>> {
  return db.select([
    "markets.category as category",
    "markets.openInterest as openInterest",
    "markets.tag1 as tag1",
    "markets.tag2 as tag2",
    "market_state.reportingState as reportingState",
  ]).from("markets")
開發者ID:AugurProject,項目名稱:augur_node,代碼行數:31,代碼來源:get-categories.ts

示例9:

import Augur from "augur.js";
import { BigNumber } from "bignumber.js";
import * as t from "io-ts";
import * as Knex from "knex";
import * as _ from "lodash";
import { FrozenFunds } from "../../blockchain/log-processors/profit-loss/frozen-funds";
import { BN_WEI_PER_ETHER, ZERO } from "../../constants";
import { Address, MarketsRow, OutcomeParam, ReportingState, SortLimitParams } from "../../types";
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;
開發者ID:AugurProject,項目名稱:augur_node,代碼行數:32,代碼來源:get-user-trading-positions.ts


注:本文中的io-ts.type函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。