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


TypeScript fp.isObject函数代码示例

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


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

示例1: get

 Object.keys(sources).reduce<DetailItem[]>((accumulator, source) => {
   const item = get(source, sources);
   if (Array.isArray(item) || isString(item) || isNumber(item)) {
     const field = path ? `${path}.${source}` : source;
     category = field.split('.')[0];
     if (isEmpty(category) && baseCategoryFields.includes(category)) {
       category = 'base';
     }
     return [
       ...accumulator,
       {
         category,
         field,
         values: item,
         originalValue: item,
       } as DetailItem,
     ];
   } else if (isObject(item)) {
     return [
       ...accumulator,
       ...getDataFromHits(item, category || source, path ? `${path}.${source}` : source),
     ];
   }
   return accumulator;
 }, []);
开发者ID:,项目名称:,代码行数:25,代码来源:

示例2:

export const parseValue = (
  value: string | number | object | undefined | null
): string | number | undefined | null => {
  if (isObject(value)) {
    return JSON.stringify(value);
  }
  return value as string | number | undefined | null;
};
开发者ID:,项目名称:,代码行数:8,代码来源:

示例3: Boolean

const convertToBoolean = (value: object | number | boolean | string): boolean => {
  if (isObject(value)) {
    return false;
  } else if (isString(value)) {
    return value.toLowerCase() === 'true' || value.toLowerCase() === 't' ? true : false;
  } else {
    return Boolean(value);
  }
};
开发者ID:,项目名称:,代码行数:9,代码来源:

示例4: catch

const convertToString = (value: object | number | boolean | string): string => {
  if (isObject(value)) {
    try {
      return JSON.stringify(value);
    } catch (_) {
      return 'Invalid Object';
    }
  }
  return value.toString();
};
开发者ID:,项目名称:,代码行数:10,代码来源:

示例5: if

export const parseQueryValue = (
  value: string | number | object | undefined | null
): string | number => {
  if (value == null) {
    return '';
  } else if (isObject(value)) {
    return JSON.stringify(value);
  } else if (isNumber(value)) {
    return value;
  }
  return value.toString();
};
开发者ID:,项目名称:,代码行数:12,代码来源:

示例6: GraphQLScalarType

 *  serialize: gets invoked when serializing the result to send it back to a client.
 *
 *  parseValue: gets invoked to parse client input that was passed through variables.
 *
 *  parseLiteral: gets invoked to parse client input that was passed inline in the query.
 */

export const toNumberArrayScalar = new GraphQLScalarType({
  name: 'NumberArray',
  description: 'Represents value in detail item from the timeline who wants to more than one type',
  serialize(value): number[] | null {
    if (value == null) {
      return null;
    } else if (Array.isArray(value)) {
      return convertArrayToNumber(value) as number[];
    } else if (isBoolean(value) || isString(value) || isObject(value)) {
      return [convertToNumber(value)];
    }
    return [value];
  },
  parseValue(value) {
    return value;
  },
  parseLiteral(ast) {
    switch (ast.kind) {
      case Kind.INT:
        return ast.value;
      case Kind.FLOAT:
        return ast.value;
      case Kind.STRING:
        return parseFloat(ast.value);
开发者ID:,项目名称:,代码行数:31,代码来源:

示例7: isObject

 ([targetKey, targetValue]) =>
   source.hasOwnProperty(targetKey) && isObject(source[targetKey])
开发者ID:wikipathways,项目名称:gpml2pvjson-js,代码行数:2,代码来源:toPvjson.ts


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