本文整理汇总了TypeScript中ramda.always函数的典型用法代码示例。如果您正苦于以下问题:TypeScript always函数的具体用法?TypeScript always怎么用?TypeScript always使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了always函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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)
}
示例2: cond
const swaggerToJoiType = (type: string): string =>
cond([
[equals('token'), always('string')],
[equals('integer'), always('number')],
[equals('int64'), always('integer')],
[T, _type => '' + _type]
])(type);
示例3: cond
export const getProblemFromStatus = status => {
return cond([
[isNil, always(UNKNOWN_ERROR)],
[in200s, always(NONE)],
[in400s, always(CLIENT_ERROR)],
[in500s, always(SERVER_ERROR)],
[T, always(UNKNOWN_ERROR)],
])(status)
}
示例4: upToConditional
static upToConditional(n) {
const isModuloOf = mod => i => i % mod === 0;
const fb = R.cond([
[isModuloOf(15), R.always('fizzbuzz')],
[isModuloOf(5), R.always('buzz')],
[isModuloOf(3), R.always('fizz')],
[R.T, i => '' + i]
]);
return R.map(fb, R.range(1, R.inc(n)));
}
示例5: compose
getIdOrNullFor = type => compose(
ifElse(isNil, always(null), compose(
ifElse(
contains(type),
compose<string, string[], string, number, Record<string, number>>(
objOf(`${type}_id`), Number, last, split('-'),
),
always(null),
),
)),
);
示例6: upToLookUp
static upToLookUp(n) {
const s = R.toString
const f = R.always('fizz');
const b = R.always('buzz');
const fb = R.always(f() + b());
const funs = [s, s, f, s, b, f, s, s, f, b, s, f, s, s, fb];
const selectFun: any = (n) => R.nth(R.modulo(R.dec(n), 15), funs);
const fizzBuzzify = (n) => R.call(selectFun(n), n);
return R.map(fizzBuzzify, R.range(1, R.inc(n)));
}
示例7: initialize
public async initialize(): Promise<void> {
const container = new InvocationContainer({
defaults: {
conventionCalls: ['initialize'],
},
});
const fileNames = ['fizzy.bpmn', 'fizzy_upto.bpmn'];
for (const name of fileNames) {
const processFilePath = './src/process_engine/' + name;
const bpmn = fs.readFileSync(processFilePath, 'utf8');
await container.registerObject('boilerplate', bpmn)
.setTag('bpmn_process', 'internal')
.setTag('path', processFilePath);
}
for (const iocModule of iocModules) {
iocModule.registerInContainer(container);
}
container.validateDependencies();
try {
const bootstrapper: any = await container.resolveAsync('AppBootstrapper');
await bootstrapper.start();
const iamService: any = await container.resolveAsync('IamService');
iamService.authService.getIdentity = R.always({});
iamService.hasClaim = R.always(true);
this.processEngineService = await container.resolveAsync('ProcessEngineService');
this.context = await iamService.createInternalContext('lizard');
}
catch (error) {
// nothing to be done
console.error(error);
}
}
示例8: buildJoiSpec
(acc, [method, spec]) =>
Maybe.of(concat)
.ap(parseSecuritySpec(spec))
.ap(parseRouteSpec(spec, routeHandlers))
.map(handler => [
{
method,
path,
handler,
validate: buildJoiSpec(Joi, spec),
meta: pick(['summary', 'description'], spec)
}
])
.fold(always(acc), concat(acc)),
示例9: it
it('0 pin games score is 0', () => {
const rolls = times(always(0), 20);
expect(score(rolls)).toEqual(0)
});