当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript node-opcua-utils.isNullOrUndefined函数代码示例

本文整理汇总了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;
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:25,代码来源:access_level.ts

示例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, "");

    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:20,代码来源:ua_off_normal_alarm.ts

示例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();
        });
开发者ID:node-opcua,项目名称:node-opcua,代码行数:24,代码来源:nodeset_to_xml.ts

示例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;
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:16,代码来源:reference.ts

示例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;
    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:19,代码来源:opcua_client_impl.ts

示例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 + ")";
    }
}
开发者ID:node-opcua,项目名称:node-opcua,代码行数:21,代码来源:factories_baseobject.ts


注:本文中的node-opcua-utils.isNullOrUndefined函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。