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


TypeScript underscore.isString函数代码示例

本文整理汇总了TypeScript中underscore.isString函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isString函数的具体用法?TypeScript isString怎么用?TypeScript isString使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了isString函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: isInvalidQueryStringValue

  private static isInvalidQueryStringValue(value: any) {
    if (isString(value)) {
      return Utils.isEmptyString(value);
    }

    return Utils.isNullOrUndefined(value);
  }
开发者ID:coveo,项目名称:search-ui,代码行数:7,代码来源:UrlUtils.ts

示例2: 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

示例3: detectFloat

		this.forEach((el: any) => {
			// console.log('getRowTypes', el);
			// let float = parseFloat(el);	// does not handle 1.000,12 well
			let float = detectFloat(el);

			let date = Date.parse(el);
			let isDate = !!date && el.indexOf(',') == -1;	// dates are without ","
			let isEmpty = _.isNull(el)
				|| _.isUndefined(el)
				|| el == '';
			let commas = 0;
			if (_.isString(el)) {
				commas = el.split(',').length - 1;
			}
			let elWithoutEUR = (el || '').replace('EUR', '').trim();
			let onlyNumbers = /^[\-,\.\d]+$/.test(elWithoutEUR);
			if (float && !isDate && commas == 1 && onlyNumbers) {
				types.push('number');
			} else if (isDate) {
				types.push('date');
			} else if (isEmpty) {
				types.push('null');
			} else {
				types.push('string');
			}
		});
开发者ID:spidgorny,项目名称:umsaetze,代码行数:26,代码来源:Row.ts

示例4: 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

示例5: __render

// TODO: Function overloading?
	__render(html, callback: RenderCallback) {
		var $scope = null;
		var $cheerio = $;

		if (_.isString(html)) {
			$scope = $.load(html)(this._documentSelector);
		} else if (_.isObject(html)) {
			$scope = $(html).find(this._documentSelector); // must be DOM
		} else {
			return callback(new Error('Must be Cheerio DOM object'), null, null);
		}

		if (this._documentSelectorIndex) {
			try {
				$scope = $($scope[this._documentSelectorIndex]);
			} catch (e) {
				throw new Error('No selector index at "' + this._documentSelectorIndex + '"');
			}
		}

		// monkey patch $scope
		$scope.$find = MenioModel.__find($scope);

		let self = {
			model: {}
		};
		_.extend(self, this._props);


		for (let i = 0; i < this._keys.length; i++) {
			let name = this._keys[i];

			try {
				// DI - scope, cheerio and _
				let opts = this._mappings[i].call(self, $($scope), $cheerio, _);

				// only call next if callback and next
				if (callback && opts && opts.next) {
					callback(null, opts.$scope, self.model);
					return;
				} else {
					if (!self.model[name]) {
						self.model[name] = opts;
					}
				}
			} catch (e) {
				throw e;
			}

		}

		if (callback) {
			return callback(null, null, self.model);
		} else {
			return self.model;
		}

	};
开发者ID:molekilla,项目名称:menio,代码行数:59,代码来源:menio.ts

示例6: it

 it('should support rendering as a simple string and not an HTML element', () => {
   facet.options.title = 'My facet title';
   const builtAsString = new BreadcrumbValueList(facet, facetValues, BreadcrumbValueElement).buildAsString();
   expect(_.isString(builtAsString)).toBe(true);
   expect(builtAsString).toContain('My facet title');
   expect(builtAsString).toContain('foo0');
   expect(builtAsString).toContain('foo1');
   expect(builtAsString).toContain('foo2');
 });
开发者ID:coveo,项目名称:search-ui,代码行数:9,代码来源:BreadcrumbValuesListTest.ts

示例7: _toolbox_monitor

    public static _toolbox_monitor(
        subscription: ClientSubscription,
        timestampsToReturn: TimestampsToReturn,
        monitoredItems: ClientMonitoredItemBase[],
        done: ErrorCallback
    ) {
        assert(_.isFunction(done));
        const itemsToCreate: MonitoredItemCreateRequestOptions[] = [];
        for (const monitoredItem of monitoredItems) {

            const monitoredItemI = monitoredItem as ClientMonitoredItemBaseImpl;
            const itemToCreate = monitoredItemI._prepare_for_monitoring();
            if (_.isString(itemToCreate.error)) {
                return done(new Error(itemToCreate.error));
            }
            itemsToCreate.push(itemToCreate as MonitoredItemCreateRequestOptions);
        }

        const createMonitorItemsRequest = new CreateMonitoredItemsRequest({
            itemsToCreate,
            subscriptionId: subscription.subscriptionId,
            timestampsToReturn,
        });

        const session = subscription.session as ClientSessionImpl;
        assert(session,
            "expecting a valid session attached to the subscription ");
        session.createMonitoredItems(
            createMonitorItemsRequest,
            (err?: Error | null, response?: CreateMonitoredItemsResponse) => {

                /* istanbul ignore next */
                if (err) {
                    debugLog(chalk.red("ClientMonitoredItemBase#_toolbox_monitor:  ERROR in createMonitoredItems "));
                } else {
                    if (!response) {
                        return done(new Error("Internal Error"));
                    }

                    response.results = response.results || [];

                    for (let i = 0; i < response.results.length; i++) {
                        const monitoredItemResult = response.results[i];
                        const monitoredItem = monitoredItems[i] as ClientMonitoredItemBaseImpl;
                        monitoredItem._after_create(monitoredItemResult);
                    }
                }
                done(err ? err : undefined);
            });

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

示例8: 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

示例9: if

 _.each(result.raw, (value: any, key: string) => {
   let fieldDescription = fieldDescriptions['@' + key];
   if (fieldDescription == null && key.match(/^sys/)) {
     fieldDescription = fieldDescriptions['@' + key.substr(3)];
   }
   if (fieldDescription == null) {
     fields['@' + key] = value;
   } else if (fieldDescription.fieldType == 'Date') {
     fields['@' + key] = new Date(value);
   } else if (fieldDescription.splitGroupByField && _.isString(value)) {
     fields['@' + key] = value.split(/\s*;\s*/);
   } else {
     fields['@' + key] = value;
   }
 });
开发者ID:coveo,项目名称:search-ui,代码行数:15,代码来源:DebugForResult.ts

示例10: _coerceNode

    public _coerceNode(node: State | BaseNode | null | string | NodeId): BaseNode | null {

        if (node === null) {
            return null;
        }
        const addressSpace = this.addressSpace;
        if (node instanceof BaseNode) {
            return node;
        } else if (node instanceof NodeId) {
            return addressSpace.findNode(node) as BaseNode;

        } else if (_.isString(node)) {
            return this.getStateByName(node) as any as BaseNode;
        }
        return null;
    }
开发者ID:node-opcua,项目名称:node-opcua,代码行数:16,代码来源:finite_state_machine.ts


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