當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。