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


TypeScript ramda.sortBy函數代碼示例

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


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

示例1: sort

  /**
   * Return a sorted array of records
   *
   * Example:
   *
   * ```
   * res = (res) ? Array.sort('invoiceCode', 'number', 'desc', res) : undefined;
   * ```
   */
  static sort(prop, type, order = 'asc', array) {
    const sortBy = R.sortBy(R.prop(prop));

    if ('string' === type) {
      const sortBy = R.sortBy(R.compose(R.toLower, R.prop(prop)));
    }

    if (order === 'desc') {
      return R.reverse(sortBy(array));
    }

    return sortBy(array);
  }
開發者ID:simbiosis-group,項目名稱:ion2-helper,代碼行數:22,代碼來源:array-helper.ts

示例2: sendSubscriptions

    /**
     * Sends all subscribed values to the Reactotron app.
     *
     * @param node The tree to grab the state data from
     */
    function sendSubscriptions(state: any) {
      // this is unreadable
      const changes = pipe(
        map(when(isNil, always(""))) as any,
        filter(endsWith(".*")),
        map((key: string) => {
          const keyMinusWildcard = slice(0, -2, key)
          const value = dotPath(keyMinusWildcard, state)
          if (is(Object, value) && !isNilOrEmpty(value)) {
            return pipe(keys, map(key => `${keyMinusWildcard}.${key}`))(value)
          }
          return []
        }) as any,
        concat(map(when(isNil, always("")), subscriptions)),
        flatten,
        reject(endsWith(".*")) as any,
        uniq as any,
        sortBy(identity) as any,
        map((key: string) => ({
          path: key,
          value: isNilOrEmpty(key) ? state : dotPath(key, state),
        })),
      )(subscriptions)

      reactotron.stateValuesChange(changes)
    }
開發者ID:nick121212,項目名稱:reactotron,代碼行數:31,代碼來源:reactotron-mst.ts

示例3: getMigrationStates

export function getMigrationStates(
  migrations: Migration[], journalEntries: JournalEntry[]
): MigrationState[] {
  let migrationIDSet: { [id: string]: boolean } = {};
  let states: { [id: string]: MigrationState } = {};

  R.forEach(function(migration) {
    migrationIDSet[migration.id] = true;
    states[migration.id] = {
      migrationID: migration.id,
      migrationName: migration.name,
      state: State.pending
    };
  }, migrations);

  R.forEach(function(entry) {
    if (!migrationIDSet[entry.migrationID]) {
      states[entry.migrationID] = {
        migrationID: entry.migrationID,
        migrationName: entry.migrationName,
        state: State.missing
      };
    } else if (entry.operation === Operation.apply) {
      states[entry.migrationID].state = State.applied;
    } else if (entry.operation === Operation.revert) {
      states[entry.migrationID].state = State.reverted;
    } else {
      throw new InvalidJournalOperationError(entry.operation);
    }
  }, journalEntries);

  return R.sortBy(s => s.migrationID, R.values(states));
}
開發者ID:programble,項目名稱:careen,代碼行數:33,代碼來源:status.ts

示例4: listMigrations

export function listMigrations(directory: string): Promise<Migration[]> {
  return fs.readdirAsync(directory)
    .map(R.match(MIGRATION_FILE_REGEXP))
    .filter(R.identity)
    .then(R.groupBy(R.nth<string>(1)))
    .then(R.mapObj(R.partial(matchesToMigration, directory)))
    .then(R.values)
    .then(R.sortBy((migration: Migration) => migration.id));
}
開發者ID:programble,項目名稱:careen,代碼行數:9,代碼來源:files.ts

示例5: getNextNumber

  /**
   * Return the next running number in an array of records
   * @param {string} prop The property name
   * @param data The array of records containing the property
   */
  static getNextNumber(prop: string, data: Array<any>) {
    if (R.isEmpty(data)) { return 1 }
    const getNextNumber = R.pipe(
      R.sortBy(R.prop(prop)),
      R.pluck(prop),
      R.last()
    );

    return parseInt(getNextNumber(data)) + 1;
  }
開發者ID:simbiosis-group,項目名稱:ion2-helper,代碼行數:15,代碼來源:array-helper.ts

示例6: function

const getPaymentReminders = function(priority, subject) {
  return fakeApi()
    .then(R.filter(R.propEq('priority', priority)))
    .then(R.filter(R.where({ subject: R.contains(subject)})))
    .then(R.sortBy(R.prop('from')));
}
開發者ID:marley-js,項目名稱:Mastering-TypeScript-Programming-Techniques,代碼行數:6,代碼來源:api-ramda.ts

示例7: curry

  for (let key of Object.keys(rackCount)) {
    if (wordCount[key] > rackCount[key]) {
      return false;
    }
  }

  return true;
});

const filterValid = curry((rack: string, words: string[]) =>
  filter(isValid(rack), words),
);

const clean = pipe(
  sortBy(prop('numChars')) as any,
  reverse,
) as any;

const wordGraph = new MinimalWordGraph();
let loaded = false;

export const load = async () => {
  if (loaded) return;

  let words = await store.getItem<string[]>('words');

  if (!words) {
    const res = await fetch(url);
    const text = await res.text();
    words = text.split('\n');
開發者ID:kerlends,項目名稱:word-solver,代碼行數:30,代碼來源:solver.worker.ts

示例8:

			.map(res => R.sortBy(R.prop('name'))(res));
開發者ID:simbiosis-group,項目名稱:ion2-claim,代碼行數:1,代碼來源:receipt-form.ts

示例9:

			.map((res: any) => R.sortBy(R.prop('name'))(res));
開發者ID:simbiosis-group,項目名稱:ion2-member,代碼行數:1,代碼來源:application-form.ts

示例10: getAnswerMapFromRows

    const answerRows = candidateAndAnswerRows[1];
    const oneRow = answerRows[0];
    return {
      answers: getAnswerMapFromRows(answerRows),
      id: candidateName,
      name: candidateName,
      party: oneRow[AnswerFileCols.PARTY],
      reasons: getReasonsMapFromRows(answerRows),
      regions: oneRow[AnswerFileCols.REGION].split(/,\s+/)
    };
  });
}

function parseRegions(fileContent: string): RegionMap {
  const questionRows: Row[] = parse(fileContent);
  const regions = questionRows.slice(1).map(row => ({
    id: row[0],
    name: row[1]
  }));
  return R.indexBy(r => r.id, regions) as RegionMap;
}


const questions = parseQuestions(fs.readFileSync('data/questions.csv', 'utf8'));
const candidates = R.sortBy(c => c.region, parseCandidateAnswers(fs.readFileSync('data/answers.csv', 'utf8')));
const regions = parseRegions(fs.readFileSync('data/regions.csv', 'utf8'));

const initialData: InitialData = { questions, candidates, regions };
console.log(JSON.stringify(initialData, null, 2));

開發者ID:shybyte,項目名稱:wahlomat,代碼行數:29,代碼來源:convert.ts


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