當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript underscore.default函數代碼示例

本文整理匯總了TypeScript中underscore.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: filterJoiners

  async filterJoiners(preJoinData:any) {
    const filtered:any = {};
    const newcomers = _(preJoinData).keys();
    const uids:string[] = [];
    newcomers.forEach((newcomer:string) => uids.push(preJoinData[newcomer].ms.userid));

    if (newcomers.length > 0) {
      const answers = await inquirer.prompt([{
          type: "checkbox",
          name: "uids",
          message: "Newcomers to add",
          choices: uids,
          default: uids[0]
        }]);
      newcomers.forEach((newcomer:string) => {
        if (~answers.uids.indexOf(preJoinData[newcomer].ms.userid))
          filtered[newcomer] = preJoinData[newcomer];
      });
      if (answers.uids.length == 0)
        throw 'No newcomer selected';
      return filtered
    } else {
      throw 'No newcomer found';
    }
  }
開發者ID:Kalmac,項目名稱:duniter,代碼行數:25,代碼來源:blockGenerator.ts

示例2: loadConf

 async loadConf() {
   const data = await this.coreFS.readJSON('conf.json');
   if (data) {
     return _(ConfDTO.defaultConf()).extend(data);
   } else {
     // Silent error
     this.logger.warn('No configuration loaded');
     return {};
   }
 }
開發者ID:duniter,項目名稱:duniter,代碼行數:10,代碼來源:ConfDAL.ts

示例3: Error

 checkCertificationIsntForLeaverOrExcluded: async (block:BlockDTO, conf:ConfDTO, index:IndexEntry[]) => {
   const cindex = Indexer.cindex(index);
   const iindex = Indexer.iindex(index);
   const mindex = Indexer.mindex(index);
   const certified = cindex.map((row:CindexEntry) => row.receiver);
   for (const pub of certified) {
     const exclusions = _(iindex).where({ op: constants.IDX_UPDATE, member: false, pub: pub });
     const leavers    = _(mindex).where({ op: constants.IDX_UPDATE, leaving: true, pub: pub });
     if (exclusions.length > 0 || leavers.length > 0) {
       throw Error('Block cannot contain certifications concerning leavers or excluded members');
     }
   }
   return true;
 },
開發者ID:duniter,項目名稱:duniter,代碼行數:14,代碼來源:local_rules.ts

示例4: finish

					fs.readdir(src, (err, files:string[]) => {
						if (err) return finish(err, ret);

						files = _(files).filter((name) => {
							return extDef.test(name);
						});

						if (files.length == 0) {
							return finish(null, ret);
						}

						async.forEach(files, (name, callback:(err) => void) => {
							//src + '/' + file + '/' + sub;
							var tmp = path.join(src, name);
							fs.stat(tmp, (err, stats) => {
								if (err) return callback(err);
								if (stats.isDirectory()) return callback(null);

								//console.log('-> def ' + name);
								ret.push(new Def(project, name.replace(extDef, '')));
								callback(null);
							});
						}, (err) => {
							finish(err, ret);
						});
					});
開發者ID:Bartvds,項目名稱:tsd-deftools,代碼行數:26,代碼來源:loader.ts

示例5:

			fs.readdir(path.join(self.repos.tsd, 'repo_data'), (err, files:string[]) => {
				if (err) return finish(err, []);

				finish(null, _(files).filter((value) => {
					return !ignoreFile.test(value) && extJson.test(value);
				}).map((value) => {
					return value.replace(stripExt, '');
				}));
			});
開發者ID:Bartvds,項目名稱:tsd-deftools,代碼行數:9,代碼來源:loader.ts

示例6:

			fs.readdir(repos.tsd + 'repo_data', (err, files:string[]) => {
				if (err) return finish(err, []);

				finish(null, _(files).filter((value) => {
					return !ignoreFile.test(value) && isJson.test(value);
				}).map((value) => {
					return value.replace(stripExt, '');
				}));
			});
開發者ID:Diullei,項目名稱:tsd-deftools,代碼行數:9,代碼來源:loader.ts

示例7: getBestLocalIPv6

function getBestLocalIPv6() {
  const osInterfaces = listInterfaces();
  for (let netInterface of osInterfaces) {
    const addresses = netInterface.addresses;
    const filtered = _(addresses).where({family: 'IPv6', scopeid: 0, internal: false });
    const filtered2 = _.filter(filtered, (address:any) => !address.address.match(/^fe80/) && !address.address.match(/^::1/));
    if (filtered2[0]) {
      return filtered2[0].address;
    }
  }
  return null;
}
開發者ID:Kalmac,項目名稱:duniter,代碼行數:12,代碼來源:network.ts

示例8: if

 constructor(json:any) {
   _(json || {}).keys().forEach((key:string) => {
     let value = json[key];
     if (key == "number") {
       value = parseInt(value);
     }
     else if (key == "consumed") {
       value = !!value;
     }
     this[key] = value;
   })
 }
開發者ID:Kalmac,項目名稱:duniter,代碼行數:12,代碼來源:source.ts

示例9: generateNextBlock

 /**
  * Generate next block, gathering both updates & newcomers
  */
 private async generateNextBlock(generator:BlockGeneratorInterface, manualValues:any = null, simulationValues:any = null) {
   const vHEAD_1 = await this.mainContext.getvHEAD_1()
   if (simulationValues && simulationValues.medianTime) {
     vHEAD_1.medianTime = simulationValues.medianTime
   }
   const current = await this.dal.getCurrentBlockOrNull();
   const revocations = await this.dal.getRevocatingMembers();
   const exclusions = await this.dal.getToBeKickedPubkeys();
   const wereExcludeds = await this.dal.getRevokedPubkeys();
   const newCertsFromWoT = await generator.findNewCertsFromWoT(current);
   const newcomersLeavers = await this.findNewcomersAndLeavers(current, (joinersData:any) => generator.filterJoiners(joinersData));
   const transactions = await this.findTransactions(current, manualValues);
   const joinData = newcomersLeavers[2];
   const leaveData = newcomersLeavers[3];
   const newCertsFromNewcomers = newcomersLeavers[4];
   const certifiersOfNewcomers = _.uniq(_.keys(joinData).reduce((theCertifiers:any, newcomer:string) => {
     return theCertifiers.concat(_.pluck(joinData[newcomer].certs, 'from'));
   }, []));
   const certifiers:string[] = [].concat(certifiersOfNewcomers);
   // Merges updates
   _(newCertsFromWoT).keys().forEach(function(certified:string){
     newCertsFromWoT[certified] = newCertsFromWoT[certified].filter((cert:any) => {
       // Must not certify a newcomer, since it would mean multiple certifications at same time from one member
       const isCertifier = certifiers.indexOf(cert.from) != -1;
       if (!isCertifier) {
         certifiers.push(cert.from);
       }
       return !isCertifier;
     });
   });
   _(newCertsFromNewcomers).keys().forEach((certified:string) => {
     newCertsFromWoT[certified] = (newCertsFromWoT[certified] || []).concat(newCertsFromNewcomers[certified]);
   });
   // Revocations
   // Create the block
   return this.createBlock(current, joinData, leaveData, newCertsFromWoT, revocations, exclusions, wereExcludeds, transactions, manualValues);
 }
開發者ID:duniter,項目名稱:duniter,代碼行數:40,代碼來源:blockGenerator.ts


注:本文中的underscore.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。