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


TypeScript lodash.zipObject函数代码示例

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


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

示例1:

 this.getPerusteprojektiKaannokset = (tyyppi?: string) => {
     if (tyyppi === "opas") {
         return _.zipObject(_.keys(PerusteContextMapping), _.map(PerusteContextMapping, "opas"));
     } else {
         return _.zipObject(_.keys(PerusteContextMapping), _.keys(PerusteContextMapping));
     }
 };
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:7,代码来源:perusteprojekti.ts

示例2: function

 zipBy: function(array, kfield, vfield) {
     if (_.isArray(array) && kfield) {
         if (vfield) {
             return _.zipObject(_.map(array, kfield), _.map(array, vfield));
         } else {
             return _.zipObject(_.map(array, kfield), array);
         }
     } else {
         return {};
     }
 }
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:11,代码来源:app.ts

示例3: _fetchAssociatedHasMany

 private async _fetchAssociatedHasMany(records: any, target_model: any, foreign_key: any,
   column: any, select: any, options: any) {
   if (Array.isArray(records)) {
     const ids = records.map((record) => {
       if (options.lean) {
         record[column] = [];
       } else {
         Object.defineProperty(record, column, { enumerable: true, value: [] });
       }
       return record.id;
     });
     const query = target_model.where(_.zipObject([foreign_key], [{ $in: ids }]));
     if (select) {
       query.select(select + ' ' + foreign_key);
     }
     if (options.lean) {
       query.lean();
     }
     try {
       const sub_records = await query.exec();
       sub_records.forEach((sub_record: any) => {
         records.forEach((record) => {
           if (record.id === sub_record[foreign_key]) {
             record[column].push(sub_record);
           }
         });
       });
     } catch (error) {
       //
     }
   } else {
     if (options.lean) {
       records[column] = [];
     } else {
       Object.defineProperty(records, column, { enumerable: true, value: [] });
     }
     const query = target_model.where(_.zipObject([foreign_key], [records.id]));
     if (select) {
       query.select(select + ' ' + foreign_key);
     }
     if (options.lean) {
       query.lean();
     }
     try {
       const sub_records = await query.exec();
       sub_records.forEach((sub_record: any) => {
         return records[column].push(sub_record);
       });
     } catch (error) {
       //
     }
   }
 }
开发者ID:croquiscom,项目名称:cormo,代码行数:53,代码来源:index.ts

示例4:

 const sub_promises = integrities.map(async (integrity) => {
   const query = integrity.child.select('');
   query.where(_.zipObject([integrity.column], [{ $not: { $in: ids } }]));
   const property = integrity.child._schema[integrity.column];
   if (!property.required) {
     query.where(_.zipObject([integrity.column], [{ $not: null }]));
   }
   records = await query.exec();
   if (records.length > 0) {
     const array = result[integrity.child._name] || (result[integrity.child._name] = []);
     array.push(...records.map((record: any) => record.id));
     _.uniq(array);
   }
 });
开发者ID:croquiscom,项目名称:cormo,代码行数:14,代码来源:index.ts

示例5: getTypeByStates

  getTypeByStates(pgStatesText: string): string {
    const pgStates = this.getPgStatesFromText(pgStatesText);

    if (pgStates.length === 0) {
      return PgCategory.CATEGORY_UNKNOWN;
    }

    const intersections = _.zipObject(
      PgCategory.VALID_CATEGORIES,
      PgCategory.VALID_CATEGORIES.map(
        (category) => _.intersection(this.categories[category].states, pgStates).length
      )
    );

    if (intersections[PgCategory.CATEGORY_WARNING] > 0) {
      return PgCategory.CATEGORY_WARNING;
    }

    const pgWorkingStates = intersections[PgCategory.CATEGORY_WORKING];
    if (pgStates.length > intersections[PgCategory.CATEGORY_CLEAN] + pgWorkingStates) {
      return PgCategory.CATEGORY_UNKNOWN;
    }

    return pgWorkingStates ? PgCategory.CATEGORY_WORKING : PgCategory.CATEGORY_CLEAN;
  }
开发者ID:IlsooByun,项目名称:ceph,代码行数:25,代码来源:pg-category.service.ts

示例6: rakennaKommenttiPuu

        function rakennaKommenttiPuu(viestit) {
            viestit = _(viestit)
                .map(function(viesti) {
                    viesti.muokattu = viesti.luotu === viesti.muokattu ? null : viesti.muokattu;
                    viesti.viestit = [];
                    return viesti;
                })
                .sortBy("luotu")
                .value();

            var viestiMap = _.zipObject(_.map(viestit, "id"), viestit);

            _.forEach(viestit, function(viesti) {
                if (viesti.parentId && viestiMap[viesti.parentId]) {
                    viestiMap[viesti.parentId].viestit.unshift(viesti);
                }
            });

            var sisaltoObject = {
                $resolved: true,
                $yhteensa: _.size(viestit),
                seuraajat: [],
                viestit: _(viestiMap)
                    .values()
                    .reject(function(viesti) {
                        return (viesti as any).parentId !== null;
                    })
                    .sortBy("luotu")
                    .reverse()
                    .value()
            };
            return sisaltoObject;
        }
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:33,代码来源:kommentit.ts

示例7: _get_entries

function _get_entries(response) {
    let entries = deepGetKey(response, 'entry');
    if (!_.isArray(entries)) return undefined;
    let r = _.zipObject(_.map(entries, 'key'), _.map(entries, 'value'));
    r = _.mapValues(r, val => val.split(conf.esup_activ_bo.multiValue_separator));
    return r;
}
开发者ID:prigaux,项目名称:compte-externe,代码行数:7,代码来源:esup_activ_bo.ts

示例8: getCanonicalTranscriptsByHugoSymbol

export async function getCanonicalTranscriptsByHugoSymbol(hugoSymbols: string[],
                                                          isoformOverrideSource: string,
                                                          client:GenomeNexusAPI = genomeNexusClient)
{
    const transcripts = await fetchCanonicalTranscripts(hugoSymbols, isoformOverrideSource, client);
    return transcripts? _.zipObject(hugoSymbols, transcripts) : undefined;
}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:7,代码来源:StoreUtils.ts

示例9: function

 LukiokoulutusService.getOsat(LukiokoulutusService.OPPIAINEET_OPPIMAARAT, true).then(function(data) {
     $scope.oppiaineet = data;
     $scope.oppiaineMap = _.zipObject(
         _.map(data, function(oppiaine: any) {
             oppiaine.$url = $scope.generateLink(oppiaine);
             return ["" + oppiaine.id, oppiaine];
         })
     );
 });
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:9,代码来源:oppiaine.ts

示例10: verifySignature

  /**
   * Verify the signature(s) on a (half-signed) transaction
   * @param transaction provajs-lib tx object
   * @param inputIndex The input whose signature is to be verified
   * @param amount The input amount needs to be known for signature verification
   * @param verificationSettings
   * @param verificationSettings.signatureIndex The index of the signature to verify (only iterates over non-empty signatures)
   * @param verificationSettings.publicKey The hex of the public key to verify (will verify all signatures)
   * @returns {boolean}
   */
  verifySignature(transaction, inputIndex, amount, verificationSettings: any = {}) {
    if (!(transaction instanceof prova.Transaction)) {
      throw new Error('transaction has to be an instance of prova.Transaction');
    }

    const currentInput = transaction.ins[inputIndex];
    const signatureScript = currentInput.script;
    const decompiledSigScript = prova.script.decompile(signatureScript);
    // the public keys are all the even-indexed entries
    const publicKeys = _.filter(decompiledSigScript, (item, index: number) => index % 2 === 0);
    // convert the keys to their hex representations
    const publicKeyHexes = _.map(publicKeys, k => (k as any).toString('hex'));
    // the signatures are all the odd-indexed ones
    const signatures = _.filter(decompiledSigScript, (item, index: number) => index % 2 === 1);
    // we map them to each other
    const signaturesByKeys = _.zipObject(publicKeyHexes, signatures);

    let publicKeysToVerify = publicKeyHexes;
    const publicKeyHex = verificationSettings.publicKey;

    if (!_.isUndefined(verificationSettings.signatureIndex)) {
      publicKeysToVerify = [publicKeyHexes[verificationSettings.signatureIndex]];
    }

    let areAllSignaturesValid = true;
    for (const currentPublicKeyHex of publicKeysToVerify) {

      if (!_.isUndefined(publicKeyHex) && publicKeyHex !== currentPublicKeyHex) {
        areAllSignaturesValid = false;
        continue;
      }

      if (_.isEmpty(currentPublicKeyHex)) {
        areAllSignaturesValid = false;
        continue;
      }

      let isSignatureValid = false;
      const publicKeyBuffer = Buffer.from(currentPublicKeyHex, 'hex');
      const signatureBuffer = signaturesByKeys[currentPublicKeyHex];

      if (Buffer.isBuffer(publicKeyBuffer) && publicKeyBuffer.length > 0 && Buffer.isBuffer(signatureBuffer) && signatureBuffer.length > 0) {
        const publicKey = prova.ECPair.fromPublicKeyBuffer(publicKeyBuffer);
        const signatureHash = transaction.hashForWitnessV0(inputIndex, null, amount, prova.Transaction.SIGHASH_ALL);
        isSignatureValid = publicKey.verify(signatureHash, signatureBuffer);
      }

      if (!_.isUndefined(publicKeyHex) && isSignatureValid) {
        // We were trying to see if any of the signatures was valid for the given public key. Evidently yes.
        return true;
      }

      areAllSignaturesValid = isSignatureValid && areAllSignaturesValid;
    }

    return areAllSignaturesValid;
  }
开发者ID:BitGo,项目名称:BitGoJS,代码行数:67,代码来源:rmg.ts


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