本文整理汇总了TypeScript中@nestjs/common/utils/shared.utils.isFunction方法的典型用法代码示例。如果您正苦于以下问题:TypeScript utils.isFunction方法的具体用法?TypeScript utils.isFunction怎么用?TypeScript utils.isFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@nestjs/common/utils/shared.utils
的用法示例。
在下文中一共展示了utils.isFunction方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: isFunction
.filter(prop => {
const descriptor = Object.getOwnPropertyDescriptor(prototype, prop);
if (descriptor.set || descriptor.get) {
return false;
}
return !isConstructor(prop) && isFunction(prototype[prop]);
})
示例2: transformToResult
public async transformToResult(resultOrDeffered) {
if (resultOrDeffered instanceof Promise) {
return await resultOrDeffered;
} else if (resultOrDeffered && isFunction(resultOrDeffered.subscribe)) {
return await resultOrDeffered.toPromise();
}
return resultOrDeffered;
}
示例3: create
public create(
port: number,
options?: any & { namespace?: string; server?: any },
): any {
if (!options) {
return this.createIOServer(port);
}
const { namespace, server, ...opt } = options;
return server && isFunction(server.of)
? server.of(namespace)
: namespace
? this.createIOServer(port, opt).of(namespace)
: this.createIOServer(port, opt);
}
示例4: mapPayload
public mapPayload(payload: any): { data: any; ack?: Function } {
if (!Array.isArray(payload)) {
return { data: payload };
}
const lastElement = payload[payload.length - 1];
const isAck = isFunction(lastElement);
if (isAck) {
const size = payload.length - 1;
return {
data: size === 1 ? payload[0] : payload.slice(0, size),
ack: lastElement,
};
}
return { data: payload };
}
示例5: String
public *scanForServerHooks(instance: NestGateway): IterableIterator<string> {
for (const propertyKey in instance) {
if (isFunction(propertyKey)) {
continue;
}
const property = String(propertyKey);
const isServer = Reflect.getMetadata(
GATEWAY_SERVER_METADATA,
instance,
property,
);
if (!isUndefined(isServer)) {
yield property;
}
}
}
示例6: UndefinedDependencyException
public async resolveSingleParam<T>(
wrapper: InstanceWrapper<T>,
param: Type<any> | string | symbol | any,
{ index, length }: { index: number; length: number },
module: Module,
) {
if (isUndefined(param)) {
throw new UndefinedDependencyException(wrapper.name, index, length);
}
const token = this.resolveParamToken(wrapper, param);
return await this.resolveComponentInstance<T>(
module,
isFunction(token) ? (token as Type<any>).name : token,
{ index, length },
wrapper,
);
}
示例7: UndefinedDependencyException
public async resolveSingleParam<T>(
wrapper: InstanceWrapper<T>,
param: Type<any> | string | symbol | any,
dependencyContext: InjectorDependencyContext,
module: Module,
) {
if (isUndefined(param)) {
throw new UndefinedDependencyException(wrapper.name, dependencyContext, module);
}
const token = this.resolveParamToken(wrapper, param);
return this.resolveComponentInstance<T>(
module,
isFunction(token) ? (token as Type<any>).name : token,
dependencyContext,
wrapper,
);
}
示例8: Map
protected findInstanceByPrototypeOrToken<TInput = any, TResult = TInput>(
metatypeOrToken: Type<TInput> | string | symbol,
contextModule: Partial<Module>,
): TResult {
const dependencies = new Map([
...contextModule.components,
...contextModule.routes,
...contextModule.injectables,
]);
const name = isFunction(metatypeOrToken)
? (metatypeOrToken as any).name
: metatypeOrToken;
const instanceWrapper = dependencies.get(name);
if (!instanceWrapper) {
throw new UnknownElementException();
}
return (instanceWrapper as InstanceWrapper<any>).instance;
}
示例9: String
public *scanForClientHooks(
instance: Controller,
): IterableIterator<ClientProperties> {
for (const propertyKey in instance) {
if (isFunction(propertyKey)) continue;
const property = String(propertyKey);
const isClient = Reflect.getMetadata(CLIENT_METADATA, instance, property);
if (isUndefined(isClient)) continue;
const metadata = Reflect.getMetadata(
CLIENT_CONFIGURATION_METADATA,
instance,
property,
);
yield { property, metadata };
}
}
示例10: isFunction
(interceptor: NestInterceptor) =>
interceptor && isFunction(interceptor.intercept),