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


TypeScript ramda.values函数代码示例

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


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

示例1: MockAssetResolver

const runTests = <S, F>(
  assert: (
    fixture: ExerciseFixture<S, F>,
    /* tslint:disable-next-line:no-any */
    exercise: AbstractExercise<any, S, F>
  ) => void
) => {
  const resolver = new MockAssetResolver();
  const factory = new EntityFactory(resolver);

  const cases = values(
    mapObjIndexed(
      (
        E: {
          fixtures: Array<ExerciseFixture<S, F>>;
          /* tslint:disable-next-line:no-any */
          new (p: any): AbstractExercise<any, S, F>;
        },
        type
      ) => () => {
        forEach(fixture => {
          try {
            const exercise = factory.createExercise(
              type as ExerciseTypes,
              fixture.props
            );

            // Catch test failures so that we can pass a custom message
            assert(fixture, exercise);
          } catch (e) {
            throw new Error(`${type} › ${fixture.name}:\n${e.message}`);
          }
        }, E.fixtures);
      },
      Exercises
    )
  );

  // Execute the test runners
  forEach(runTestCases => runTestCases(), cases);

  // Check that each test case was run
  const numberOfAssertions = sum(
    values(
      map<
        { [type: string]: { fixtures: Array<ExerciseFixture<S, F>> } },
        { [type: string]: number }
      >(
        (E: { fixtures: Array<ExerciseFixture<S, F>> }) => E.fixtures.length,
        Exercises
      )
    )
  );
  expect.assertions(numberOfAssertions);
};
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:55,代码来源:exercises.ts

示例2:

const process = (contact: Contact): Contact => {
	const $emails = R.values(contact.emails)
		.map((n, i) => ({ index: i, value: n}));
	const $phones = R.values(contact.phones)
		.map((n, i) => ({ index: i, value: n}));
	return Object.assign({ }, contact, {
		$company: contact.company,
		$emails,
		$phones,
	});
}
开发者ID:simbiosis-group,项目名称:ion2-contact,代码行数:11,代码来源:contact.reducer.ts

示例3: httpAgentStats

export function httpAgentStats () {
  const socketsPerOrigin = countPerOrigin(httpAgent.sockets)
  const sockets = sum(values(socketsPerOrigin))
  const pendingRequestsPerOrigin = countPerOrigin(httpAgent.requests)
  const pendingRequests = sum(values(pendingRequestsPerOrigin))

  return {
    pendingRequests,
    pendingRequestsPerOrigin,
    sockets,
    socketsPerOrigin,
  }
}
开发者ID:vtex,项目名称:apps-client-node,代码行数:13,代码来源:request.ts

示例4: makeActionRequestCollection

export function makeActionRequestCollection() {
  return values(ACTIONS).reduce((result: any, actionFactor: any) => {
    result[actionFactor.name + '_REQUEST'] = actionFactor.request;
    result[actionFactor.name + '_FINISH'] = actionFactor.finish;
    return result;
  }, {});
}
开发者ID:A-Horse,项目名称:bblist,代码行数:7,代码来源:actions.ts

示例5:

 R.filter(role => {
   // 判断返回的是否是 ids
   if (user.roles && _.isObjectLike(user.roles[0])) {
     return R.contains(role.id)(R.values(R.pluck('id', user.roles)));
   }
   return R.contains(role.id)(user.roles);
 }),
开发者ID:danielwii,项目名称:asuna-admin,代码行数:7,代码来源:menu.redux.ts

示例6: 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

示例7: map

const arrayToTable:(x:Array<OutlineFeed>) => string = x => {
    const colHeadings = {
        htmlUrl: 'Page',
        text: 'Desc',
        title: 'Title',
        type: 'Type',
        version: 'Version',
        xmlUrl: 'URL',
        sortableUrl: 'sortable',
    };

    const cells = x => map(
        key => `<td>${ prop(key, x) }</td>`,
        keys(colHeadings)
    );

    const toRow = x => `<tr>${ cells(x).join('\n') }</tr>`;

    const rows = x.map(toRow).join('\n');

    return `<table>
  <thead>
  <tr>
    ${ map(x => `<td>${ x }</td>\n`, values(colHeadings)).join('\n') }
  </tr>
  </thead>
  <tbody>
    ${ rows }
  </tbody>
</table>`
};
开发者ID:r-k-b,项目名称:newsblur-feed-info,代码行数:31,代码来源:index.ts

示例8:

export const getAttachmentImg = (res): string => {
	if (res) {
		const attachment: any = R.head(R.values(res['_attachments']));
		return `data:${attachment.content_type};base64,${attachment.data}`
	}

	return undefined;
};
开发者ID:simbiosis-group,项目名称:ion2-claim,代码行数:8,代码来源:index.ts

示例9: isWeightMap

function isWeightMap(weights: WeightMap) {
  if (!isObject(weights)) {
    return false;
  }
  return R.values(weights).every(a =>
    typeof a === 'number' && R.contains(a, possibleWeights)
  );
}
开发者ID:shybyte,项目名称:wahlomat,代码行数:8,代码来源:validate-vote.ts

示例10:

 (error: Asuna.Error.Validate): FormError => ({
   [error.property]: {
     errors: [
       {
         field: error.property,
         message: R.values(error.constraints).join('; '),
       },
     ],
   },
 }),
开发者ID:danielwii,项目名称:asuna-admin,代码行数:10,代码来源:error.ts


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