本文整理匯總了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)
});