本文整理汇总了TypeScript中type-detect.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
Arr["groupAggregate"] = function (
key: string | Mapper<T, string>,
value: string | Mapper<T, any>,
aggregation: "min" | "max" | "sum" | "avg" | "count")
: X.Dictionary<number> {
// if key is passed as generator function, use it,
// else create generator function that assumes key is a property name.
// If key is null/missing, the string representation of an object is used as the key.
var keyGenerator: Mapper<T, string> = type(key) === "function"
? key as Mapper<T, string>
: (datum) => key
? datum[key.toString()]
: datum.toString();
//Same for value
var valueGenerator: Mapper<T, any> = type(value) === "function"
? value as Mapper<T, any>
: (datum) => value
? datum[value.toString()]
: datum.toString();
var groups: Dictionary<any> = (this as X.Array<T>).groupBy(keyGenerator);
Object.keys(groups)
.forEach(key => {
groups[key] = groups[key][aggregation](valueGenerator)
});
return groups;
}
开发者ID:prmph,项目名称:lambda.js,代码行数:31,代码来源:index.ts
示例2: createPluginInstance
private createPluginInstance() {
this.log.debug('Initializing plugin');
const pluginDefinition = require(join(this.path, 'server'));
if (!('plugin' in pluginDefinition)) {
throw new Error(`Plugin "${this.name}" does not export "plugin" definition (${this.path}).`);
}
const { plugin: initializer } = pluginDefinition as {
plugin: PluginInitializer<TSetup, TDependenciesSetup>;
};
if (!initializer || typeof initializer !== 'function') {
throw new Error(`Definition of plugin "${this.name}" should be a function (${this.path}).`);
}
const instance = initializer(this.initializerContext);
if (!instance || typeof instance !== 'object') {
throw new Error(
`Initializer for plugin "${
this.manifest.id
}" is expected to return plugin instance, but returned "${typeDetect(instance)}".`
);
}
if (typeof instance.setup !== 'function') {
throw new Error(`Instance of plugin "${this.name}" does not define "setup" function.`);
}
return instance;
}
开发者ID:njd5475,项目名称:kibana,代码行数:30,代码来源:plugin.ts
示例3: handleError
protected handleError(type: string, { message, value }: Record<string, any>, path: string[]) {
switch (type) {
case 'any.required':
case 'duration.base':
return `expected value of type [moment.Duration] but got [${typeDetect(value)}]`;
case 'duration.parse':
return new SchemaTypeError(message, path);
}
}
开发者ID:elastic,项目名称:kibana,代码行数:9,代码来源:duration_type.ts
示例4: handleError
protected handleError(type: string, { reason, value }: Record<string, any>) {
switch (type) {
case 'any.required':
case 'object.base':
return `expected a plain object value, but found [${typeDetect(value)}] instead.`;
case 'object.allowUnknown':
return `definition for this key is missing`;
case 'object.child':
return reason[0];
}
}
开发者ID:austec-automation,项目名称:kibana,代码行数:11,代码来源:object_type.ts
示例5: handleError
protected handleError(type: string, { limit, value }: Record<string, any>) {
switch (type) {
case 'any.required':
case 'number.base':
return `expected value of type [number] but got [${typeDetect(value)}]`;
case 'number.min':
return `Value is [${value}] but it must be equal to or greater than [${limit}].`;
case 'number.max':
return `Value is [${value}] but it must be equal to or lower than [${limit}].`;
}
}
开发者ID:Jaaess,项目名称:kibana,代码行数:11,代码来源:number_type.ts
示例6: handleError
protected handleError(type: string, { value, scheme }: Record<string, unknown>) {
switch (type) {
case 'any.required':
case 'string.base':
return `expected value of type [string] but got [${typeDetect(value)}].`;
case 'string.uriCustomScheme':
return `expected URI with scheme [${scheme}] but but got [${value}].`;
case 'string.uri':
return `value is [${value}] but it must be a valid URI (see RFC 3986).`;
}
}
开发者ID:elastic,项目名称:kibana,代码行数:11,代码来源:uri_type.ts
示例7: handleError
protected handleError(type: string, { limit, value }: Record<string, any>) {
switch (type) {
case 'any.required':
case 'string.base':
return `expected value of type [string] but got [${typeDetect(value)}]`;
case 'string.min':
return `value is [${value}] but it must have a minimum length of [${limit}].`;
case 'string.max':
return `value is [${value}] but it must have a maximum length of [${limit}].`;
}
}
开发者ID:Jaaess,项目名称:kibana,代码行数:11,代码来源:string_type.ts
示例8:
Arr["union"] = function <T>(array: T[]): ArrayX<T> {
var arr = [];
var self = (this as any[]);
for (var i = 0; i < self.length; i++)
arr.push(self[i]);
if (type(array) === "Array")
for (var k = 0; k < array.length; k++)
arr.push(array[k]);
return new ArrayX<T>(...arr);
}
开发者ID:prmph,项目名称:lambda.js,代码行数:12,代码来源:index.ts
示例9: handleError
protected handleError(type: string, { limit, reason, value }: Record<string, any>) {
switch (type) {
case 'any.required':
case 'array.base':
return `expected value of type [array] but got [${typeDetect(value)}]`;
case 'array.min':
return `array size is [${value.length}], but cannot be smaller than [${limit}]`;
case 'array.max':
return `array size is [${value.length}], but cannot be greater than [${limit}]`;
case 'array.includesOne':
return reason[0];
}
}
开发者ID:Jaaess,项目名称:kibana,代码行数:13,代码来源:array_type.ts
示例10: if
var arr: T[] = clone(this).sort(function (a, b) {
var objA = func ? func(a) : a;
var objB = func ? func(b) : b;
var comparison = null;
if (objA && objB) {
if (type(objA) === "number")
comparison = objA - objB;
else if (type(objA) === "date")
comparison = objA.getTime() - objB.getTime();
else
comparison = objA.toString().localeCompare(objB.toString());
}
else {
if (!objA && !objB)
comparison = 0;
else if (!objA)
comparison = -1;
else
comparison = 1;
}
return comparison;
});
开发者ID:prmph,项目名称:lambda.js,代码行数:23,代码来源:index.ts
注:本文中的type-detect.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论