util#isFunction TypeScript Examples
The following examples show how to use
util#isFunction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: server-discovery-service.ts From pebula-node with MIT License | 6 votes |
private async initSubscriber(subscriber: SubscriberMetadataForTarget[0],
instanceWrapper: InstanceWrapper<any>): Promise<void> {
const { key, metadata } = subscriber;
if (!metadata.ready) {
await metadata.init(this.metadataHelper);
}
const { metaOptions } = metadata;
const server = sbResourceManager.getServer(metaOptions.serverId);
if (!server) {
throw errors.missingSubscriberResource(metadata);
}
const legacyMessageHandler = this.legacyHandlers.get(metadata);
if (legacyMessageHandler) {
this.legacyHandlers.delete(metadata);
server.registerRoute('method', key, metadata, instanceWrapper, legacyMessageHandler);
} else {
const handler = instanceWrapper.instance[key];
if (!isFunction(handler)) {
throw errors.invalidSubscriberDecoration(key, metadata);
}
server.registerRoute('pipe', key, metadata, instanceWrapper, handler);
}
}
Example #2
Source File: defaults.ts From pebula-node with MIT License | 6 votes |
export function resolveRules(topicName: string,
subscriptionName: string,
provision: SbTopicSubscriptionEntityProvision,
defaults: SbManagementDefaultsAdapter): SbRuleEntityProvision[] {
const rules = typeof provision.rules === 'function' ? provision.rules(topicName, subscriptionName) : provision.rules;
const forSureRules = Array.isArray(rules) ? rules : [];
if (isFunction(defaults.onNewSubscriptionRules)) {
return defaults.onNewSubscriptionRules(
topicName,
subscriptionName,
forSureRules,
provision,
);
} else {
return forSureRules;
}
}
Example #3
Source File: module.ts From pebula-node with MIT License | 6 votes |
async init(port = 4000) {
const moduleBuilder = Test.createTestingModule(this.moduleMetadata);
const testingModule = await moduleBuilder.compile();
if (isFunction(this.fn)) {
this.fn(testingModule);
}
const app = testingModule.createNestApplication();
app.connectMicroservice({ strategy: createSbServer() });
await app.startAllMicroservicesAsync();
await app.listenAsync(port);
// app = moduleFixture.createNestMicroservice({ strategy: createSbServer() });
// await app.listenAsync();
return app;
}
Example #4
Source File: emitter-metadata.ts From pebula-node with MIT License | 5 votes |
constructor(public readonly type: T,
metaOptions: SbEmitterTypeMap[T] extends SbEmitterMetadataOptions ? MetaOrMetaFactory<SbEmitterTypeMap[T]> : never) {
if (isFunction(metaOptions)) {
this.metaFactory = metaOptions as any;
} else {
this.metaOptions = { ...(metaOptions as any) };
}
}
Example #5
Source File: subscriber-metadata.ts From pebula-node with MIT License | 5 votes |
constructor(public readonly type: T,
metaOptions: SbSubscriberTypeMap[T] extends SbSubscriberMetadataOptions ? MetaOrMetaFactory<SbSubscriberTypeMap[T]> : never) {
if (isFunction(metaOptions)) {
this.metaFactory = metaOptions as any;
} else {
this.metaOptions = { ...(metaOptions as any) };
}
}