當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript underscore.isBoolean函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。