本文整理汇总了TypeScript中underscore.isFunction函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isFunction函数的具体用法?TypeScript isFunction怎么用?TypeScript isFunction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isFunction函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: addSubscriber
/**
* add a subscriber to the WatchDog.
* @method addSubscriber
*
* add a subscriber to the WatchDog.
*
* This method modifies the subscriber be adding a
* new method to it called 'keepAlive'
* The subscriber must also provide a "watchdogReset". watchdogReset will be called
* if the subscriber failed to call keepAlive withing the timeout period.
* @param subscriber
* @param timeout
* @return the numerical key associated with this subscriber
*/
public addSubscriber(subscriber: ISubscriber, timeout: number): number {
const self = this;
self._currentTime = Date.now();
timeout = timeout || 1000;
assert(_.isNumber(timeout), " invalid timeout ");
assert(_.isFunction(subscriber.watchdogReset), " the subscriber must provide a watchdogReset method ");
assert(!_.isFunction(subscriber.keepAlive));
self._counter += 1;
const key = self._counter;
subscriber._watchDog = self;
subscriber._watchDogData = {
key,
lastSeen: self._currentTime,
subscriber,
timeout,
visitCount: 0
} as IWatchdogData2;
self._watchdogDataMap[key] = subscriber._watchDogData;
if (subscriber.onClientSeen) {
subscriber.onClientSeen(new Date(subscriber._watchDogData.lastSeen));
}
subscriber.keepAlive = keepAliveFunc.bind(subscriber);
// start timer when the first subscriber comes in
if (self.subscriberCount === 1) {
assert(self._timer === null);
this._start_timer();
}
return key;
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:49,代码来源:watchdog.ts
示例2: constructor
constructor(options: EnumerationDefinitionOptions) {
super(options);
// create a new Enum
const typedEnum = new Enum(options.enumValues);
options.typedEnum = typedEnum;
assert(!options.encode || _.isFunction(options.encode));
assert(!options.decode || _.isFunction(options.decode));
this.encode = options.encode || _encode_enumeration;
this.decode = options.decode || function _decode_enumeration(stream: BinaryStream): EnumItem {
const value = stream.readInteger();
const e = typedEnum.get(value);
// istanbul ignore next
if (!e) {
throw new Error("cannot coerce value=" + value + " to " + typedEnum.constructor.name);
}
return e;
};
this.typedEnum = options.typedEnum;
this.defaultValue = this.typedEnum.getDefaultValue().value;
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:25,代码来源:factories_enumerations.ts
示例3: withSubscription
public withSubscription(
endpointUrl: string,
subscriptionParameters: ClientSubscriptionOptions,
innerFunc: (session: ClientSession, subscription: ClientSubscription, done: (err?: Error) => void) => void,
callback: (err?: Error) => void
) {
assert(_.isFunction(innerFunc));
assert(_.isFunction(callback));
this.withSession(endpointUrl, (session: ClientSession, done: (err?: Error) => void) => {
assert(_.isFunction(done));
const subscription = new ClientSubscriptionImpl(session as ClientSessionImpl, subscriptionParameters);
try {
innerFunc(session, subscription, (err?: Error) => {
subscription.terminate((err1?: Error) => {
done(err1);
});
});
} catch (err) {
debugLog(err);
done(err);
}
}, callback);
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:30,代码来源:opcua_client_impl.ts
示例4: registerType
export function registerType(schema: BasicTypeDefinitionOptions): void {
assert(typeof schema.name === "string");
if (!_.isFunction(schema.encode)) {
throw new Error("schema " + schema.name + " has no encode function");
}
if (!_.isFunction(schema.decode)) {
throw new Error("schema " + schema.name + " has no decode function");
}
schema.category = FieldCategory.basic;
const definition = new BasicTypeSchema(schema);
_defaultTypeMap.set(schema.name, definition);
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:14,代码来源:factories_builtin_types.ts
示例5:
Marionette.TemplateCache.prototype.compileTemplate = (rawTemplate: any): any => {
if (_.isFunction(rawTemplate)) {
return rawTemplate;
} else {
return Handlebars.compile(rawTemplate);
}
};
开发者ID:fafnirical,项目名称:test--marionette,代码行数:7,代码来源:view.ts
示例6: _self_coerce
function _self_coerce(constructor: any) {
assert(_.isFunction(constructor));
return (value: any) => {
const obj = new constructor(value);
return obj;
};
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:7,代码来源:factories_builtin_types_special.ts
示例7: getEndpoints
public getEndpoints(...args: any[]): any {
if (args.length === 1) {
return this.getEndpoints({}, args[0]);
}
const options = args[0] as GetEndpointsOptions;
const callback = args[1] as ResponseCallback<EndpointDescription[]>;
assert(_.isFunction(callback));
options.localeIds = options.localeIds || [];
options.profileUris = options.profileUris || [];
const request = new GetEndpointsRequest({
endpointUrl: options.endpointUrl || this.endpointUrl,
localeIds: options.localeIds,
profileUris: options.profileUris,
requestHeader: {
auditEntryId: null
}
});
this.performMessageTransaction(request, (err: Error | null, response?: Response) => {
this._serverEndpoints = [];
if (err) {
return callback(err);
}
if (!response || !(response instanceof GetEndpointsResponse)) {
return callback(new Error("Internal Error"));
}
if (response && response.endpoints) {
this._serverEndpoints = response.endpoints;
}
callback(null, this._serverEndpoints);
});
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:34,代码来源:client_base_impl.ts
示例8: debugLog
this._recreate_secure_channel((err1?: Error) => {
debugLog("secureChannel#on(close) => _recreate_secure_channel returns ",
err1 ? err1.message : "OK");
if (err1) {
// xx assert(!this._secureChannel);
debugLog("_recreate_secure_channel has failed");
// xx this.emit("close", err1);
return;
} else {
/**
* @event connection_reestablished
* send when the connection is reestablished after a connection break
*/
this.emit("connection_reestablished");
// now delegate to upper class the
if (this._on_connection_reestablished) {
assert(_.isFunction(this._on_connection_reestablished));
this._on_connection_reestablished((err2?: Error) => {
if (err2) {
debugLog("connection_reestablished has failed");
this.disconnect(() => {
// callback(err);
});
}
});
}
}
});
开发者ID:node-opcua,项目名称:node-opcua,代码行数:32,代码来源:client_base_impl.ts
示例9: write_field
// --------------------------------------------------------------
// implement decode
function write_field(field: FieldType, member: string, i: number) {
if (field.category === FieldCategory.enumeration || field.category === FieldCategory.basic) {
if (field.isArray) {
write(" this." + member + " = decodeArray(stream, decode" + field.fieldType + ");");
} else {
if (false) {
write(" this." + member + ".decode(stream);");
} else {
if (_.isFunction(field.decode)) {
write(" this." + member + " = " + "schema" + ".fields[" + i + "].decode(stream);");
} else {
write(" this." + member + " = decode" + field.fieldType + "(stream);");
}
}
}
} else {
assert(field.category === FieldCategory.complex);
if (field.isArray) {
write(" this." + member + " = decodeArray(stream, (stream1: BinaryStream) => {");
write(" const obj = new " + field.fieldType + "();");
write(" obj.decode(stream1);");
write(" return obj;");
write(" });");
} else {
write(" this." + member + ".decode(stream);");
// xx write(" this." + member + ".decode(stream);");
}
}
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:31,代码来源:factory_code_generator.ts
示例10: createSession
/**
* @internal
* @param args
*/
public createSession(...args: any[]): any {
if (args.length === 1) {
return this.createSession({ type: UserTokenType.Anonymous }, args[0]);
}
const userIdentityInfo = args[0];
const callback = args[1];
this.userIdentityInfo = userIdentityInfo;
assert(_.isFunction(callback));
this._createSession((err: Error | null, session?: ClientSession) => {
if (err) {
callback(err);
} else {
if (!session) {
return callback(new Error("Internal Error"));
}
this._addSession(session as ClientSessionImpl);
this._activateSession(session as ClientSessionImpl,
(err1: Error | null, session2?: ClientSessionImpl) => {
callback(err1, session2);
});
}
});
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:34,代码来源:opcua_client_impl.ts
注:本文中的underscore.isFunction函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论