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


TypeScript lodash.sample函數代碼示例

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


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

示例1: RandomUsers

    static RandomUsers(count:number): User[]{
        let users:User[]=[];
	    for(let i=0;i<count; i++){
            users.push(new User(i, _.sample(FIRST_NAMES), _.sample(LAST_NAMES)));
        }
        return users;
    }
開發者ID:Jaroost,項目名稱:builder_app,代碼行數:7,代碼來源:user.ts

示例2: parseInt

const addUsers = (count, knex, date) => {
  count = parseInt(count)
  const rows = []

  for (let i = 0; i < count; i++) {
    const channel = _.sample(channels)
    const id = _.uniqueId()

    const first_name = { key: 'first_name', value: generateName(), type: 'string' }
    const last_name = { key: 'last_name', value: generateName(), type: 'string' }
    const gender = { key: 'gender', value: Math.random() < vary(0.65, 0.35) ? 'male' : 'female', type: 'string' }
    const locale = { key: 'locale', value: _.sample(['en_US', 'fr_CA', 'en_CA']), type: 'string' }
    const timezone = { key: 'timezone', value: _.random(-6, 12, false), type: 'string' }

    const user = {
      user_id: id,
      channel: channel,
      attributes: JSON.stringify([first_name, last_name, gender, locale, timezone]),
      created_at: date
    }

    users.push(user)
    rows.push(user)
  }

  return knex.batchInsert('srv_channel_users', rows, 20).then(() => console.log('Added', count, 'users'))
}
開發者ID:alexsandrocruz,項目名稱:botpress,代碼行數:27,代碼來源:seed.ts

示例3: times

 return times(4, () => {
   const device = sample (devices);
   const location = sample(locations);
   return {
     device: device,
     location: location,
     name : sample(['Cloud', 'Lamp', 'Bridge']),
     pin: sample(device.pins)
   };
 });
開發者ID:syafiqrokman,項目名稱:angular5-iot-dashboard,代碼行數:10,代碼來源:mocks.service.ts

示例4: sample

const CONTACTS = COLORS.map((color, index) => {
  const title = `${sample(['Mr.', 'Mrs.', 'Ms.', 'Unknown'])} ${color} 🔥`;
  const key = sample(['name', 'profileName']) as string;
  const id = `+1202555${padStart(index.toString(), 4, '0')}`;

  const contact = {
    color,
    [key]: title,
    id,
    type: 'private',
  };

  return parent.ConversationController.dangerouslyCreateAndAdd(contact);
});
開發者ID:VetoPlayer,項目名稱:Signal-Desktop,代碼行數:14,代碼來源:StyleGuideUtil.ts

示例5: enterScored

function enterScored(state: State) {
  const goalText = sample(goalWords);

  return state
    .setIn(['round', 'scored'], true)
    .setIn(['round', 'goalText'], goalText);
}
開發者ID:thomasboyt,項目名稱:manygolf,代碼行數:7,代碼來源:reducer.ts

示例6: enabler

 "!typegame": enabler((command: Tennu.Command) => {
     var cache = typegameCache[command.channel] = typegameCache[command.channel] || { running: false };
     if (typegameCache[command.channel].running) {
         return util.format("A game is still running! Name %s Pokémon with the type %s!", cache.cnt, cache.types.join("/"));
     } else {
         (runningCache[command.channel] = runningCache[command.channel] || []).push("typegame")
         var {type, cnt} = _.sample(Data.type_count_array);
         console.log(cnt);
         cache = typegameCache[command.channel] = {
             running: true,
             type: type,
             cnt: _.random(1, _.min([5, cnt])),
             max: cnt,
             userCount: {},
             guessed: {},
             types: []
         };
         for (var i = 0; type; type >>= 1, ++i) {
             if (type&1)
                 cache.types.push(Data.type_list[i]);
         }
         return util.format("Name %s Pokémon with the type %s!",
                             cache.cnt, cache.types.join("/")
         );
     }
 }),
開發者ID:Cu3PO42,項目名稱:CuBoid,代碼行數:26,代碼來源:typegame.ts

示例7: getRandomKiller

 async getRandomKiller(): Promise<TKiller> {
   const killers = (await this.fetch()).killers;
   const killer = _.sample( killers.abilities );
   return _.extend({}, killer, {
     addons: _.sampleSize( killers.addons[ killer.name.replace(/The\s/, '') ], 2 )
   });
 }
開發者ID:solarflare045,項目名稱:ultimate-bravery,代碼行數:7,代碼來源:randomizer.service.ts

示例8: constructor

  constructor(private readonly log: Logger, private readonly options: BasePathProxyServerOptions) {
    const ONE_GIGABYTE = 1024 * 1024 * 1024;
    options.httpConfig.maxPayload = new ByteSizeValue(ONE_GIGABYTE);

    if (!options.httpConfig.basePath) {
      options.httpConfig.basePath = `/${sample(alphabet, 3).join('')}`;
    }
  }
開發者ID:Jaaess,項目名稱:kibana,代碼行數:8,代碼來源:base_path_proxy_server.ts

示例9:

 .then(pool => {
     if (pool.length === 0) return null;
     if (this.preferredTaskType) {
         const task = _.find(pool, t => t.templateType === this.preferredTaskType);
         if (task) return task;
     }
     return _.sample(pool);
 });
開發者ID:CMUBigLab,項目名稱:cmuNodeFbot,代碼行數:8,代碼來源:volunteer.ts

示例10: updateNextDirection

 updateNextDirection() {
     let allDirections = [Phaser.LEFT, Phaser.RIGHT, Phaser.UP, Phaser.DOWN];
     let possibleDirections = _.filter(allDirections, (direction) => {
         return direction !== this.currentDirection && direction !== this.opposites[this.currentDirection];
     });
     this.nextDirection = _.sample(possibleDirections);
     return this.nextDirection;
 }
開發者ID:DanEEStar,項目名稱:ld35_shapman,代碼行數:8,代碼來源:main.ts


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