本文整理汇总了TypeScript中node-opcua-utils.isNullOrUndefined函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isNullOrUndefined函数的具体用法?TypeScript isNullOrUndefined怎么用?TypeScript isNullOrUndefined使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isNullOrUndefined函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: makeAccessLevelFlag
export function makeAccessLevelFlag(str: string | number | null): AccessLevelFlag {
if (typeof str === "number") {
const value = str as number;
if (value === 0) { return AccessLevelFlag.None; }
return value as AccessLevelFlag;
}
let accessFlag: AccessLevelFlag | null;
if (str === "" || str === null) {
accessFlag = AccessLevelFlag.None;
} else {
const flags = str.split(" | ");
accessFlag = 0;
for (const flag of flags) {
accessFlag |= (AccessLevelFlag as any)[flag];
}
}
if (utils.isNullOrUndefined(accessFlag)) {
throw new Error("Invalid access flag specified '" + str + "' should be one of " + AccessLevelFlag.toString());
}
return accessFlag as AccessLevelFlag;
}
示例2: _updateAlarmState
public _updateAlarmState(normalStateValue?: any, inputValue?: any) {
const alarm = this;
if (utils.isNullOrUndefined(normalStateValue) || utils.isNullOrUndefined(inputValue)) {
this.activeState.setValue(false);
return;
}
const isActive = !isEqual(normalStateValue, inputValue);
if (isActive === alarm.activeState.getValue()) {
// no change => ignore !
return;
}
const stateName = isActive ? "Active" : "Inactive";
// also raise the event
alarm._signalNewCondition(stateName, isActive, "");
}
示例3:
_.forEach(indexes.nameIndex, (defItem: any, key) => {
xw.startElement("Field");
xw.writeAttribute("Name", defItem.name);
if (defItem.dataType && !defItem.dataType.isEmpty()) {
// there is no dataType on enumeration
const dataTypeStr = defItem.dataType.toString();
xw.writeAttribute("DataType", dataTypeStr);
}
if (!utils.isNullOrUndefined(defItem.valueRank)) {
xw.writeAttribute("ValueRank", defItem.valueRank);
}
if (!utils.isNullOrUndefined(defItem.value)) {
xw.writeAttribute("Value", defItem.value);
}
if (defItem.description) {
xw.startElement("Description");
xw.text(defItem.description);
xw.endElement();
}
xw.endElement();
});
示例4: is_valid_reference
function is_valid_reference(ref: Reference): boolean {
const hasRequestedProperties = ref.hasOwnProperty("referenceType") &&
ref.hasOwnProperty("nodeId") &&
!utils.isNullOrUndefined(ref.isForward);
if (!hasRequestedProperties) {
return false;
}
assert(ref.referenceType instanceof NodeId);
assert(!ref.node || sameNodeId(ref.node.nodeId, ref.nodeId));
// xx assert(!ref.referenceTypeName || typeof ref.referenceTypeName === "string");
// xx // referenceType shall no be a nodeId string (this could happen by mistake)
// xx assert(!isNodeIdString(ref.referenceType));
return true;
}
示例5: constructor
constructor(options?: OPCUAClientOptions) {
options = options || {};
super(options);
// @property endpoint_must_exist {Boolean}
// if set to true , create Session will only accept connection from server which endpoint_url has been reported
// by GetEndpointsRequest.
// By default, the client is strict.
this.endpoint_must_exist = (isNullOrUndefined(options.endpoint_must_exist))
? true
: !!options.endpoint_must_exist;
this.requestedSessionTimeout = options.requestedSessionTimeout || 60000; // 1 minute
this.___sessionName_counter = 0;
this.userIdentityInfo = { type: UserTokenType.Anonymous };
this.endpoint = undefined;
}
示例6: _arrayEllipsis
function _arrayEllipsis(value: any[] | null) {
if (!value) {
return "null []";
} else {
if (value.length === 0) {
return "[ /* empty*/ ]";
}
assert(_.isArray(value));
const v = [];
const m = Math.min(_nbElements, value.length);
for (let i = 0; i < m; i++) {
let element = value[i];
if (element instanceof Buffer) {
element = hexDump(element, 32, 16);
}
v.push(!utils.isNullOrUndefined(element) ? element.toString() : null);
}
return "[ " + v.join(",") + (value.length > 10 ? " ... " : "") + "] (l=" + value.length + ")";
}
}