当前位置: 首页>>代码示例>>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;未经允许,请勿转载。