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


TypeScript lodash.compact函数代码示例

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


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

示例1: getFileIds

	/**
	 * Returns all file IDs from a populated release.
	 *
	 * @see [[ReleaseDocument.getFileIds]]
	 * @param {ReleaseDocument} release Release
	 * @returns {string[]} File IDs
	 */
	public static getFileIds(release: ReleaseDocument): string[] {
		const files = flatten(map(release.versions, 'files'));
		const tableFileIds = map(files, '_file').map(file => file ? file._id.toString() : null);
		const playfieldImageId = compact(map(files, '_playfield_image')).map(file => file._id.toString());
		const playfieldVideoId = compact(map(files, '_playfield_video')).map(file => file._id.toString());
		return compact(flatten([...tableFileIds, playfieldImageId, playfieldVideoId]));
	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:14,代码来源:release.ts

示例2: mergeVendors

 ).then((vendors) => {
   const nonNullVendors = _.compact(vendors);
   if (nonNullVendors.length) {
     const mergedVendor = mergeVendors(_.compact(vendors));
     service.vendors[mergedVendor.hash] = mergedVendor;
   } else {
     delete service.vendors[vendorDef.hash];
   }
 });
开发者ID:w1cked,项目名称:DIM,代码行数:9,代码来源:vendor.service.ts

示例3: compact

  (
    state: SearchStateType,
    regionCode: string,
    lookup: ConversationLookupType,
    selectedConversation?: string,
    selectedMessage?: string
  ) => {
    return {
      contacts: compact(
        state.contacts.map(id => {
          const value = lookup[id];

          if (value && id === selectedConversation) {
            return {
              ...value,
              isSelected: true,
            };
          }

          return value;
        })
      ),
      conversations: compact(
        state.conversations.map(id => {
          const value = lookup[id];

          if (value && id === selectedConversation) {
            return {
              ...value,
              isSelected: true,
            };
          }

          return value;
        })
      ),
      hideMessagesHeader: false,
      messages: state.messages.map(message => {
        if (message.id === selectedMessage) {
          return {
            ...message,
            isSelected: true,
          };
        }

        return message;
      }),
      regionCode: regionCode,
      searchTerm: state.query,
      showStartNewConversation: Boolean(
        state.normalizedPhoneNumber && !lookup[state.normalizedPhoneNumber]
      ),
    };
  }
开发者ID:WhisperSystems,项目名称:Signal-Desktop,代码行数:54,代码来源:search.ts

示例4: it

                        it(name, () => {
                            let modules = parseCode(fs.readFileSync(sourceFile).toString(), name);
                            let typings = format(modules, { colors: false, warnings: false });

                            let expected = fs.readFileSync(definitionFile).toString();

                            typings = _.compact(typings.split(/\r\n|\r|\n/).map(line => line.replace(/\s*([,!?:.\{\}\(\)\=])\s*/g, '$1').trim())).join('\n');
                            expected = _.compact(expected.split(/\r\n|\r|\n/).map(line => line.replace(/\s*([,!?:.\{\}\(\)\=])\s*/g, '$1').trim())).join('\n');

                            expect(typings).to.eq(expected);
                        })
开发者ID:Bolisov,项目名称:js2typings,代码行数:11,代码来源:parser.ts

示例5: extractItemsBy

      R.values(filteredAssociations).map(async field => {
        const selectable = R.pathOr([], ['options', 'selectable'])(field);
        logger.debug(TAG, { field, selectable });
        if (selectable) {
          const primaryKey = _.first(AppContext.adapters.models.getPrimaryKeys(selectable));
          const fieldsOfAssociations = AppContext.adapters.models.getFieldsOfAssociations();

          const foreignOpts = [
            {
              modelName: selectable,
              association: fieldsOfAssociations[selectable],
              onSearch: _.debounce(async (value, callback) => {
                logger.log(TAG, 'onSearch', { value });

                AppContext.adapters.models
                  .loadAssociation(selectable, { keywords: value })
                  .then(response => {
                    const items = extractItemsBy(primaryKey)([response]);
                    callback(items);
                  })
                  .catch(reason => {
                    logger.error(TAG, reason);
                  });
              }, 500),
            },
          ];
          logger.debug(TAG, { fieldsOfAssociations, foreignOpts });

          try {
            const results = await bluebird.props({
              itemsResponse: AppContext.adapters.models.loadAssociation(selectable),
              existItemsResponse: AppContext.adapters.models.loadAssociationByIds(
                selectable,
                field.value,
              ),
            });

            // 当前方法只处理了单个外键的情况,没有考虑如联合主键的处理
            const foreignKeysResponse = {
              [selectable]: {
                items: _.compact(extractItemsBy(primaryKey)([results.itemsResponse])),
                existItems: _.compact(extractItemsBy(primaryKey)([results.existItemsResponse])),
              },
            };
            logger.debug(TAG, { foreignOpts, foreignKeysResponse });
            return { ...field, foreignOpts, associations: foreignKeysResponse };
          } catch (e) {
            logger.error(TAG, e);
          }
        }
        logger.warn(TAG, 'no foreignKeys with association', { field });
        return { ...field, type: DynamicFormTypes.Input };
      }),
开发者ID:danielwii,项目名称:asuna-admin,代码行数:53,代码来源:async.ts

示例6: cb

      this.storage.fetchPreferences(notification.walletId, null, (
        err,
        preferences
      ) => {
        if (err) log.error(err);
        if (_.isEmpty(preferences)) preferences = [];

        const recipientPreferences = _.compact(
          _.map(preferences, (p) => {
            if (!_.includes(this.availableLanguages, p.language)) {
              if (p.language)
                log.warn(
                  'Language for notifications "' +
                  p.language +
                  '" not available.'
                );
              p.language = this.defaultLanguage;
            }

            return {
              copayerId: p.copayerId,
              language: p.language,
              unit: unit || p.unit || this.defaultUnit
            };
          })
        );

        const copayers = _.keyBy(recipientPreferences, 'copayerId');

        const recipientsList = _.compact(
          _.map(wallet.copayers, (copayer) => {
            if (
              (copayer.id == notification.creatorId &&
                notificationType.notifyCreatorOnly) ||
              (copayer.id != notification.creatorId &&
                !notificationType.notifyCreatorOnly)
            ) {
              const p = copayers[copayer.id] || {
                language: this.defaultLanguage,
                unit: this.defaultUnit
              };
              return {
                copayerId: copayer.id,
                language: p.language || this.defaultLanguage,
                unit: unit || p.unit || this.defaultUnit
              };
            }
          })
        );

        return cb(null, recipientsList);
      });
开发者ID:bitpay,项目名称:bitcore,代码行数:52,代码来源:pushnotificationsservice.ts

示例7: processRawSymbols

/**
 * Iterates through raw symbols and choose appropriate handler for each one
 * @param {Array} rawSymbols
 * @param {String[]} text - text editor content splitted by lines
 * @return {SymbolInformation[]}
 */
function processRawSymbols(rawSymbols: StylusNode[], text: string[]): SymbolInformation[] {
  return _.compact(
    rawSymbols.map(symNode => {
      if (isVariableNode(symNode)) {
        return _variableSymbol(symNode, text);
      }

      if (isFunctionNode(symNode)) {
        return _functionSymbol(symNode, text);
      }

      if (isSelectorNode(symNode)) {
        return _selectorSymbol(symNode, text);
      }

      if (isSelectorCallNode(symNode)) {
        return _selectorCallSymbol(symNode, text);
      }

      if (isAtRuleNode(symNode)) {
        return _atRuleSymbol(symNode, text);
      }
    })
  );
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:31,代码来源:symbols-finder.ts

示例8: annotationQuery

  annotationQuery(options) {
    const start = this.convertToTSDBTime(options.rangeRaw.from, false);
    const end = this.convertToTSDBTime(options.rangeRaw.to, true);
    const qs = [];
    const eventList = [];

    qs.push({ aggregator: 'sum', metric: options.annotation.target });

    const queries = _.compact(qs);

    return this.performTimeSeriesQuery(queries, start, end).then(results => {
      if (results.data[0]) {
        let annotationObject = results.data[0].annotations;
        if (options.annotation.isGlobal) {
          annotationObject = results.data[0].globalAnnotations;
        }
        if (annotationObject) {
          _.each(annotationObject, annotation => {
            const event = {
              text: annotation.description,
              time: Math.floor(annotation.startTime) * 1000,
              annotation: options.annotation,
            };

            eventList.push(event);
          });
        }
      }
      return eventList;
    });
  }
开发者ID:acedrew,项目名称:grafana,代码行数:31,代码来源:datasource.ts

示例9: before

                before(async () => {
                    await principalToken.setBalance.sendTransactionAsync(PAYER, Units.ether(1.1), {
                        from: CONTRACT_OWNER,
                    });
                    await principalToken.approve.sendTransactionAsync(
                        tokenTransferProxy.address,
                        Units.ether(1.1),
                        { from: PAYER },
                    );

                    payerBalanceBefore = await principalToken.balanceOf.callAsync(PAYER);
                    beneficiaryBalanceBefore = await principalToken.balanceOf.callAsync(
                        BENEFICIARY_1,
                    );

                    const txHash = await router.repay.sendTransactionAsync(
                        agreementId,
                        Units.ether(1.1),
                        principalToken.address,
                        { from: PAYER },
                    );
                    receipt = await web3.eth.getTransactionReceipt(txHash);

                    [repaymentLog] = _.compact(ABIDecoder.decodeLogs(receipt.logs));
                });
开发者ID:TheRealest,项目名称:charta,代码行数:25,代码来源:repayment_router.ts

示例10:

        ]).spread(function(cryptoCertificates: Array<any>, uiDescriptor) {
            (cryptoCertificates as any)._objectType = objectType;
            context.object = _.compact(cryptoCertificates);
            context.userInterfaceDescriptor = uiDescriptor;

            return self.updateStackWithContext(stack, context);
        });
开发者ID:mactanxin,项目名称:gui,代码行数:7,代码来源:system.ts


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