本文整理汇总了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);
};
示例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,
});
}
示例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,
}
}
示例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;
}, {});
}
示例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);
}),
示例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));
}
示例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>`
};
示例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;
};
示例9: isWeightMap
function isWeightMap(weights: WeightMap) {
if (!isObject(weights)) {
return false;
}
return R.values(weights).every(a =>
typeof a === 'number' && R.contains(a, possibleWeights)
);
}
示例10:
(error: Asuna.Error.Validate): FormError => ({
[error.property]: {
errors: [
{
field: error.property,
message: R.values(error.constraints).join('; '),
},
],
},
}),