本文整理汇总了TypeScript中underscore.isBoolean函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isBoolean函数的具体用法?TypeScript isBoolean怎么用?TypeScript isBoolean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isBoolean函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
'iftype': function (val: any, type: 'array' | 'object' | 'boolean' | 'number' | 'string' | 'simple', options) {
let condition = false;
switch (type) {
case 'array':
condition = _.isArray(val)
break;
case 'object':
condition = _.isObject(val)
break;
case 'boolean':
condition = _.isBoolean(val)
break;
case 'number':
condition = _.isNumber(val)
break;
case 'string':
condition = _.isString(val)
break;
case 'simple':
condition = !(_.isObject(val) || _.isArray(val) || _.isUndefined(val));
break;
default:
condition = false;
break;
}
return Handlebars.helpers['if'].call(this, condition, options);
},
开发者ID:do5,项目名称:mcgen,代码行数:27,代码来源:global-handler-hbs.ts
示例2: closeSession
/**
* @internals
* @param args
*/
public closeSession(...args: any []): any {
const session = args[0] as ClientSessionImpl;
const deleteSubscriptions = args[1];
const callback = args[2];
assert(_.isBoolean(deleteSubscriptions));
assert(_.isFunction(callback));
assert(session);
assert(session._client === this, "session must be attached to this");
session._closed = true;
// todo : send close session on secure channel
this._closeSession(session, deleteSubscriptions, (err?: Error | null, response?: CloseSessionResponse) => {
session.emitCloseEvent(StatusCodes.Good);
this._removeSession(session);
session.dispose();
assert(!_.contains(this._sessions, session));
assert(session._closed, "session must indicate it is closed");
callback(err ? err : undefined);
});
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:30,代码来源:opcua_client_impl.ts
示例3: createElement
export function createElement(type: string, props: { [name: string]: any },
...children: Array<string | HTMLElement | Array<string | HTMLElement>>): HTMLElement {
let elem;
if (type === "fragment") {
elem = document.createDocumentFragment();
} else {
elem = document.createElement(type);
for (let k in props) {
let v = props[k];
if (k === "className")
k = "class";
if (k === "class" && isArray(v))
v = v.filter(c => c != null).join(" ");
if (v == null || isBoolean(v) && !v)
continue
elem.setAttribute(k, v);
}
}
for (const v of flatten(children, true)) {
if (v instanceof HTMLElement)
elem.appendChild(v);
else if (isString(v))
elem.appendChild(document.createTextNode(v))
}
return elem;
}
开发者ID:jfinkels,项目名称:bokeh,代码行数:28,代码来源:dom.ts
示例4: if
format: (key: string, ...args: any[]) => {
let value = key.toLocaleString();
// Try to find a soft match
// These conditions check if there was a change in the string (meaning toLocaleString found a match). If there was no
// match, try another format.
if (value == key) {
const tryTranslationInUpperCase = key.toUpperCase().toLocaleString();
const tryTranslationInLowerCase = key.toLowerCase().toLocaleString();
const tryTranslationAfterCapitalization = (key.charAt(0).toUpperCase() + key.toLowerCase().slice(1)).toLocaleString();
if (tryTranslationInUpperCase != key.toUpperCase().toLocaleString()) {
value = tryTranslationInUpperCase;
} else if (tryTranslationInLowerCase != key.toLowerCase().toLocaleString()) {
value = tryTranslationInLowerCase;
} else if (tryTranslationAfterCapitalization != key.charAt(0).toUpperCase() + key.toLowerCase().slice(1)) {
value = tryTranslationAfterCapitalization;
}
}
if (args.length > 0) {
let last = _.last(args);
// Last argument is either the count or a boolean forcing plural (true) or singular (false)
if (_.isBoolean(last) || _.isNumber(last)) {
args.pop();
value = L10N.formatPlSn(value, last);
}
_.each(args, (arg, i) => (value = value.replace(`{${i}}`, arg)));
} else {
// If there was no parameters passed, we try to cleanup the possible parameters in the translated string.
value = value.replace(/{[0-9]}|<pl>[a-zA-Z]+<\/pl>|<sn>|<\/sn>/g, '').trim();
}
return value;
},
开发者ID:coveo,项目名称:search-ui,代码行数:31,代码来源:L10N.ts
示例5:
formatPlSn: (value: string, count: number | boolean) => {
let isPlural = _.isBoolean(count) ? count : count > 1;
if (isPlural) {
value = value.replace(pluralRegex, '$1').replace(singularRegex, '');
} else {
value = value.replace(pluralRegex, '').replace(singularRegex, '$1');
}
return value;
}
开发者ID:coveo,项目名称:search-ui,代码行数:9,代码来源:L10N.ts
示例6: setValue
/**
* @method setValue
* @param boolValue {Boolean}
*/
public setValue(boolValue: boolean) {
const node = this;
assert(_.isBoolean(boolValue));
const dataValue = node.id!.readValue();
const oldValue = dataValue.value.value;
if (dataValue.statusCode === StatusCodes.Good && boolValue === oldValue) {
return; // nothing to do
}
//
node.id.setValueFromSource(new Variant({ dataType: DataType.Boolean, value: boolValue }));
_updateTransitionTime(node);
_updateEffectiveTransitionTime(node);
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:18,代码来源:ua_two_state_variable.ts
示例7: convertObjectToTsInterfaces
private convertObjectToTsInterfaces(jsonContent: any, objectName: string = "RootObject"): string {
let optionalKeys: string[] = [];
let objectResult: string[] = [];
for (let key in jsonContent) {
let value = jsonContent[key];
if (_.isObject(value) && !_.isArray(value)) {
let childObjectName = this.toUpperFirstLetter(key);
objectResult.push(this.convertObjectToTsInterfaces(value, childObjectName));
jsonContent[key] = this.removeMajority(childObjectName) + ";";
} else if (_.isArray(value)) {
let arrayTypes: any = this.detectMultiArrayTypes(value);
if (this.isMultiArray(arrayTypes)) {
let multiArrayBrackets = this.getMultiArrayBrackets(value);
if (this.isAllEqual(arrayTypes)) {
jsonContent[key] = arrayTypes[0].replace("[]", multiArrayBrackets);
} else {
jsonContent[key] = "any" + multiArrayBrackets + ";";
}
} else if (value.length > 0 && _.isObject(value[0])) {
let childObjectName = this.toUpperFirstLetter(key);
objectResult.push(this.convertObjectToTsInterfaces(value[0], childObjectName));
jsonContent[key] = this.removeMajority(childObjectName) + "[];";
} else {
jsonContent[key] = arrayTypes[0];
}
} else if (_.isDate(value)) {
jsonContent[key] = "Date;";
} else if (_.isString(value)) {
jsonContent[key] = "string;";
} else if (_.isBoolean(value)) {
jsonContent[key] = "boolean;";
} else if (_.isNumber(value)) {
jsonContent[key] = "number;";
} else {
jsonContent[key] = "any;";
optionalKeys.push(key);
}
}
let result = this.formatCharsToTypeScript(jsonContent, objectName, optionalKeys);
objectResult.push(result);
return objectResult.join("\n\n");
}
开发者ID:lafe,项目名称:VSCode-json2ts,代码行数:49,代码来源:Json2Ts.ts
示例8: dumpReferencedNodesOld
function dumpReferencedNodesOld(
xw: XmlWriter,
node: BaseNode,
forward: boolean
) {
assert(_.isBoolean(forward));
xw.visitedNode[_hash(node)] = 1;
const nodesToVisit: any = {};
visitUANode(node, nodesToVisit, forward);
for (const el of nodesToVisit.elements) {
if (!xw.visitedNode[_hash(el)]) {
el.dumpXML(xw);
}
}
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:19,代码来源:nodeset_to_xml.ts
示例9: visitUANode
function visitUANode(
node: BaseNode,
options: any,
forward: boolean
) {
assert(_.isBoolean(forward));
const addressSpace = node.addressSpace;
options.elements = options.elements || [];
options.index_el = options.index_el || {};
// visit references
function process_reference(reference: Reference) {
// only backward or forward refernces
if (reference.isForward !== forward) {
return;
}
if (reference.nodeId.namespace === 0) {
return; // skip OPCUA namespace
}
const k = _hash(reference);
if (!options.index_el[k]) {
options.index_el[k] = 1;
const o = addressSpace.findNode(k)! as BaseNode;
if (o) {
visitUANode(o, options, forward);
}
}
}
_.forEach(node.ownReferences(), process_reference);
options.elements.push(node);
return node;
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:38,代码来源:nodeset_to_xml.ts
示例10: _closeSession
private _closeSession(
session: ClientSessionImpl,
deleteSubscriptions: boolean,
callback: (err: Error | null, response?: CloseSessionResponse) => void
) {
assert(_.isFunction(callback));
assert(_.isBoolean(deleteSubscriptions));
// istanbul ignore next
if (!this._secureChannel) {
return callback(null); // new Error("no channel"));
}
assert(this._secureChannel);
if (!this._secureChannel.isValid()) {
return callback(null);
}
if (this.isReconnecting) {
errorLog("OPCUAClientImpl#_closeSession called while reconnection in progress ! What shall we do");
return callback(null);
}
const request = new CloseSessionRequest({
deleteSubscriptions
});
session.performMessageTransaction(request, (err: Error | null, response?: Response) => {
if (err) {
callback(err);
} else {
callback(err, response as CloseSessionResponse);
}
});
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:36,代码来源:opcua_client_impl.ts
注:本文中的underscore.isBoolean函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论