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


TypeScript fp.isArray函数代码示例

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


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

示例1: isArray

const convertFieldsToAssociativeArray = (
  schemaFields: Partial<SchemaItem | SchemaFields>,
  path: string = ''
): OutputSchema =>
  schemaFields.fields && isArray(schemaFields.fields)
    ? schemaFields.fields.reduce((accumulator: OutputSchema, item: Partial<SchemaFields>) => {
        if (item.name) {
          const attr = isEmpty(path) ? item.name : `${path}.${item.name}`;
          if (!isEmpty(item.fields) && isEmpty(path)) {
            return {
              ...accumulator,
              [attr]: {
                ...onlyStringOrNumber(pick(paramsToPick, item)),
                fields: {
                  ...convertFieldsToAssociativeArray(item, attr),
                },
              },
            };
          } else if (!isEmpty(item.fields) && !isEmpty(path)) {
            return {
              ...accumulator,
              [attr]: onlyStringOrNumber(pick(paramsToPick, item)),
              ...convertFieldsToAssociativeArray(item, attr),
            };
          } else {
            return {
              ...accumulator,
              [attr]: onlyStringOrNumber(pick(paramsToPick, item)),
            };
          }
        }
        return accumulator;
      }, {})
    : {};
开发者ID:,项目名称:,代码行数:34,代码来源:

示例2: toPairs

 toPairs(GPML2013aGroupMappingsByStyle[Group.Style]).forEach(function(
   [mappingKey, mappingValue]
 ) {
   const oldValue = Group[mappingKey];
   let newValue;
   if (isPlainObject(mappingValue)) {
     newValue = assign(oldValue || {}, mappingValue);
   } else if (Group.hasOwnProperty(mappingKey)) {
     if (isArray(mappingValue)) {
       newValue = unionLSV(mappingValue, oldValue);
     } else {
       newValue = oldValue;
     }
   } else {
     // override prototype with default by style
     newValue = mappingValue;
   }
   Group[mappingKey] = newValue;
 });
开发者ID:wikipathways,项目名称:gpml2pvjson-js,代码行数:19,代码来源:group.ts

示例3: extendDeep

function extendDeep(targetOrTargetArray, source) {
  const target = isArray(targetOrTargetArray)
    ? targetOrTargetArray[0]
    : targetOrTargetArray;
  // TODO: We run into problems if we try to extend both
  // GraphicalLine and Interaction, because they share
  // EdgeGraphicsType. To avoid an infinite recursion of
  // extending, I'm using a short-term solution of just
  // marking whether a target has been extended, and
  // if so, skipping it.
  // Look into a better way of handling this.
  if (!target.hasOwnProperty("_extended")) {
    toPairsIn(target)
      .filter(
        ([targetKey, targetValue]) =>
          source.hasOwnProperty(targetKey) && isObject(source[targetKey])
      )
      .forEach(function([targetKey, targetValue]) {
        extendDeep(targetValue, source[targetKey]);
      });
    assignM(target.constructor.prototype, source);
    target._extended = true;
  }
}
开发者ID:wikipathways,项目名称:gpml2pvjson-js,代码行数:24,代码来源:toPvjson.ts

示例4: test

 test('Packetbeat transformation', async () => {
   const convertData: Schema = cloneDeep(packetbeatSchema).slice(0, 1);
   convertData[0].fields = isArray(convertData[0].fields)
     ? convertData[0].fields!.slice(0, 6)
     : [];
   expect(convertSchemaToAssociativeArray(convertData)).toEqual({
     '@timestamp': {
       description:
         'Date/time when the event originated. For log events this is the date/time when the event was generated, and not when it was read. Required field for all events.',
       example: '2016-05-23T08:05:34.853Z',
       name: '@timestamp',
       type: 'date',
     },
     tags: {
       description: 'List of keywords used to tag each event.',
       example: '["production", "env2"]',
       name: 'tags',
       type: 'keyword',
     },
     labels: {
       description:
         'Key/value pairs. Can be used to add meta information to events. Should not contain nested objects. All values are stored as keyword. Example: `docker` and `k8s` labels.',
       example: '{"env":"production","application":"foo-bar"}',
       name: 'labels',
       type: 'object',
     },
     message: {
       description:
         'For log events the message field contains the log message. In other use cases the message field can be used to concatenate different values which are then freely searchable. If multiple messages exist, they can be combined into one message.',
       example: 'Hello World',
       name: 'message',
       type: 'text',
     },
     agent: {
       description:
         'The agent fields contain the data about the software entity, if any, that collects, detects, or observes events on a host, or takes measurements on a host. Examples include Beats. Agents may also run on observers. ECS agent.* fields shall be populated with details of the agent running on the host or observer where the event happened or the measurement was taken.',
       name: 'agent',
       type: 'group',
       fields: {
         'agent.version': {
           description: 'Version of the agent.',
           example: '6.0.0-rc2',
           name: 'version',
           type: 'keyword',
         },
         'agent.name': {
           description:
             'Name of the agent. This is a name that can be given to an agent. This can be helpful if for example two Filebeat instances are running on the same host but a human readable separation is needed on which Filebeat instance data is coming from. If no name is given, the name is often left empty.',
           example: 'foo',
           name: 'name',
           type: 'keyword',
         },
         'agent.type': {
           description:
             'Type of the agent. The agent type stays always the same and should be given by the agent used. In case of Filebeat the agent would always be Filebeat also if two Filebeat instances are run on the same machine.',
           example: 'filebeat',
           name: 'type',
           type: 'keyword',
         },
         'agent.id': {
           description:
             'Unique identifier of this agent (if one exists). Example: For Beats this would be beat.id.',
           example: '8a4f500d',
           name: 'id',
           type: 'keyword',
         },
         'agent.ephemeral_id': {
           description:
             'Ephemeral identifier of this agent (if one exists). This id normally changes across restarts, but `agent.id` does not.',
           example: '8a4f500f',
           name: 'ephemeral_id',
           type: 'keyword',
         },
       },
     },
     client: {
       description:
         'A client is defined as the initiator of a network connection for events regarding sessions, connections, or bidirectional flow records. For TCP events, the client is the initiator of the TCP connection that sends the SYN packet(s). For other protocols, the client is generally the initiator or requestor in the network transaction. Some systems use the term "originator" to refer the client in TCP connections. The client fields describe details about the system acting as the client in the network event. Client fields are usually populated in conjunction with server fields.  Client fields are generally not populated for packet-level events. Client / server representations can add semantic context to an exchange, which is helpful to visualize the data in certain situations. If your context falls in that category, you should still ensure that source and destination are filled appropriately.',
       name: 'client',
       type: 'group',
       fields: {
         'client.address': {
           description:
             'Some event client addresses are defined ambiguously. The event will sometimes list an IP, a domain or a unix socket.  You should always store the raw address in the `.address` field. Then it should be duplicated to `.ip` or `.domain`, depending on which one it is.',
           name: 'address',
           type: 'keyword',
         },
         'client.ip': {
           description:
             'IP address of the client. Can be one or multiple IPv4 or IPv6 addresses.',
           name: 'ip',
           type: 'ip',
         },
         'client.port': {
           description: 'Port of the client.',
           name: 'port',
           type: 'long',
         },
         'client.mac': {
           description: 'MAC address of the client.',
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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