當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。