本文整理汇总了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;未经允许,请勿转载。 |
请发表评论