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


TypeScript lodash.orderBy函数代码示例

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


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

示例1: sort

 protected sort (): void {
     if (this.sortByField) {
         this.ordered = _.orderBy(this.filtered, (p: T) => sortableValue(this.getValue(p, this.sortByField)), this.sortByOrder);
     } else {
         this.ordered = this.filtered;
     }
 };
开发者ID:gabyvs,项目名称:ng2-ue-utils,代码行数:7,代码来源:base-storage.ts

示例2: constructor

 /** @ngInject */
 constructor(private $scope, private $timeout, private $rootScope) {
   this.row = this.rowCtrl.row;
   this.dashboard = this.rowCtrl.dashboard;
   this.allPanels = _.orderBy(_.map(config.panels, item => item), 'sort');
   this.panelHits = this.allPanels;
   this.activeIndex = 0;
 }
开发者ID:lpic10,项目名称:grafana,代码行数:8,代码来源:add_panel.ts

示例3: async

 socket.on('rm.watch', async (variableId, cb) => {
   await global.db.engine.remove('custom.variables.watch', { variableId });
   // force reorder
   const variables = _.orderBy((await global.db.engine.find('custom.variables.watch')).map((o) => { o._id = o._id.toString(); return o; }), 'order', 'asc');
   for (let order = 0; order < variables.length; order++) { await global.db.engine.update('custom.variables.watch', { _id: variables[order]._id }, { order }); }
   cb(null, variableId);
 });
开发者ID:sogehige,项目名称:SogeBot,代码行数:7,代码来源:custom_variables.ts

示例4: baseBotTextNLP

export function baseBotTextNLP(text: string): Promise<Array<Intent>> {
  const filtered: Array<Array<Classification>> = _.map(this.classifiers, (classifiers: Classifiers, topic: string) => {
    const trueClassifications = _.map(classifiers, (classifier, label) => checkUsingClassifier(text, classifier, label, topic));
    // console.log(topic, trueClassifications);
    return _.compact(trueClassifications);
  });

  let compacted: Array<Classification> = _.compact(_.flatten(filtered));
  if (this && this.debugOn) { console.log('compacted', util.inspect(compacted, { depth: null })); };

  if (classifier === natural.LogisticRegressionClassifier) {
    compacted = compacted.filter(result => result.value > 0.6);
  }

  if (compacted.length === 0) {
    return null;
  }
  const sorted: Array<Classification> = _.orderBy(compacted, ['value'], 'desc');
  if (this && this.debugOn) { console.log(`${text}\n${util.inspect(sorted, { depth:null })}`); };

  const intents: Array<Intent> = sorted.map(intent => ({
    action: intent.label,
    details: {
      confidence: intent.value,
    },
    topic: intent.topic,
  }));

  return Promise.resolve(intents);
}
开发者ID:LexieCore,项目名称:bot-framework,代码行数:30,代码来源:index.ts

示例5: return

    firebase.database().ref(notesIndexRefPath).orderByChild('timestamp').limitToLast(100).on('value', snapshot => {
      const noteIndices: FirebaseNoteIndex[] = lodash.toArray(snapshot.val()); // rename, reshape

      let cachedNotes = this.store.cachedNotes; // Storeに保存してあるcachedNotesを取得する

      /* 更新の必要があるnoteIndexだけを抽出する(noteidとtimestampが同一のnoteは更新の必要がない) */
      let differenceNoteIndices = noteIndices.filter(noteIndex => {
        const compareNotes = cachedNotes.filter(note => note.noteid === noteIndex.noteid);
        return (compareNotes.length > 0 && compareNotes[0].timestamp === noteIndex.timestamp) ? false : true;
      });
      differenceNoteIndices = lodash.orderBy(differenceNoteIndices, ['timestamp'], ['desc']); // timestampの降順で並び替える
      console.log('differenceNoteIndices: ');
      console.log(differenceNoteIndices);

      /* noteIndexに基づいてnoteを取得する。onceメソッドは非同期のため完了は順不同となる。(本当に?) */
      if (differenceNoteIndices.length > 0) {        
        differenceNoteIndices.forEach(noteIndex => {
          const notesRefPath = 'notes/' + noteIndex.noteid;
          firebase.database().ref(notesRefPath).once('value', snapshot => {
            const note: FirebaseNote = snapshot.val(); // rename
            cachedNotes.unshift(note); // cachedNotesの先頭にnoteを追加
            cachedNotes = lodash.uniqBy(cachedNotes, 'noteid'); // noteidの重複をまとめる。(先頭寄りにあるものを生かす)
            cachedNotes = lodash.orderBy(cachedNotes, ['timestamp'], ['desc']); // timestampの降順で並べ替える
            this.notes$.next(cachedNotes);
            this.store.cachedNotes = cachedNotes; // 新しいcachedNotesをStoreのcachedNotesに書き戻す
          });
        });
      } else { // differenceNoteIndices.length === 0
        this.notes$.next(cachedNotes);
      }
    }, err => {
开发者ID:ovrmrw,项目名称:jspm-angular2-sample,代码行数:31,代码来源:note-list.service.ts

示例6: getConversation

  async getConversation(userId, conversationId, botId) {
    const condition: any = { userId, botId }

    if (conversationId && conversationId !== 'null') {
      condition.id = conversationId
    }

    const conversation = await this.knex('web_conversations')
      .where(condition)
      .then()
      .get(0)

    if (!conversation) {
      return undefined
    }

    const messages = await this.getConversationMessages(conversationId)

    messages.forEach(m => {
      return Object.assign(m, {
        message_raw: this.knex.json.get(m.message_raw),
        message_data: this.knex.json.get(m.message_data)
      })
    })

    return Object.assign({}, conversation, {
      messages: _.orderBy(messages, ['sent_on'], ['asc'])
    })
  }
开发者ID:seffalabdelaziz,项目名称:botpress,代码行数:29,代码来源:db.ts

示例7: catch

    txStream.on('end', () => {
      if (broken) {
        return;
      }

      const txs = [],
        unconf = [];
      _.each(acum.split(/\r?\n/), rawTx => {
        if (!rawTx) return;

        let tx;
        try {
          tx = JSON.parse(rawTx);
        } catch (e) {
          log.error('v8 error at JSON.parse:' + e + ' Parsing:' + rawTx + ':');
          return cb(e);
        }
        // v8 field name differences
        if (tx.value) tx.amount = tx.satoshis / 1e8;

        if (tx.height >= 0) txs.push(tx);
        else unconf.push(tx);
      });
      console.timeEnd('V8 getTxs');
      // blockTime on unconf is 'seenTime';
      return cb(
        null,
        _.flatten(_.orderBy(unconf, 'blockTime', 'desc').concat(txs.reverse()))
      );
    });
开发者ID:bitpay,项目名称:bitcore,代码行数:30,代码来源:v8.ts

示例8: orderBy

export const sortByName = (data = [], options: {order: any}) => {
	return orderBy(
		data,
		({lastName, name}) => `${lastName || name}`.toLowerCase().trim(),
		options.order
	);
};
开发者ID:3drepo,项目名称:3drepo.io,代码行数:7,代码来源:sorting.ts

示例9: orderListDefaults

  @test('By default, order list is sorted ascending by ShippedDate')
  public async orderListDefaults() {
    let firstPageResult = await getCustomerOrders('ANTON', { perPage: 3 });

    let sortedById = orderBy(firstPageResult, 'shippeddate', 'asc');
    assert.deepEqual(firstPageResult, sortedById);
  }
开发者ID:qjac,项目名称:sql-fundamentals,代码行数:7,代码来源:ex03.sort-customer-orders.test.ts


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