本文整理汇总了TypeScript中ramda.head函数的典型用法代码示例。如果您正苦于以下问题:TypeScript head函数的具体用法?TypeScript head怎么用?TypeScript head使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了head函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: if
tokens.forEach((token) => {
const { image } = token;
if (bracketsCount === 0 && image !== '(' && image !== ')') {
output.push(token);
return;
}
temp.push(token);
if (image === '(') {
bracketsCount += 1;
} else if (image === ')') {
bracketsCount -= 1;
if (bracketsCount === 0) {
// recursive clean within parenthesis, unnests one layer
const cleaned = cleanOperators(temp.slice(1, -1));
if (cleaned.length) {
// Length check means this is fine
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
output.push(R.head(temp)!, ...cleaned, R.last(temp)!);
}
temp = [];
}
}
});
开发者ID:nusmodifications,项目名称:nusmods,代码行数:26,代码来源:parseString.ts
示例2:
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
示例3: wrap
wrap(text: string, columns: number): string {
const wrap = s => this.wrap(s, columns);
const splitAtColumns = R.splitAt(columns);
if (R.length(text) <= columns) {
return text;
}
if (R.not(containsSpaces(text))) {
return R.head(splitAtColumns(text)) + NEW_LINE + wrap(R.last(splitAtColumns(text)));
}
if (SPACE === text[columns]) {
return R.head(splitAtColumns(text)) + NEW_LINE + wrap(R.trim(splitAtColumns(text)[1]));
}
return replaceLastSpace(R.head(splitAtColumns(text))) + wrap(R.last(splitAtColumns(text)));
}
开发者ID:paucls,项目名称:katas,代码行数:18,代码来源:wrapper.ts
示例4: Error
.then(([travels, reservations]: [Travel[], Reservation[]]) => {
if (R.isArrayLike(travels) && R.isArrayLike(reservations) && !R.isEmpty(travels)) {
const travel = R.head(travels);
if ((reservation.travelType === "OUT" && canOut(reservations)) || (reservation.travelType === "IN" && canIn(reservations, travel.placeLimit))) {
return Promise.resolve(this.respository.save(reservation));
}
return Promise.reject(getError(new Error("Place limit")));
}
return Promise.reject(getError(new Error("Travel not exist")));
}, rejected => {
开发者ID:dominikus1993,项目名称:TravelAssistantNode,代码行数:10,代码来源:service.ts
示例5: buildParameter
const buildJoiSpec = (joi: Joi, { parameters = [], consumes = [] }) => {
const spec = parameters.reduce(
(acc, paramConf: swaggerParam) =>
R.assocPath(R.props(['in', 'name'], paramConf), buildParameter(joi, paramConf), acc),
{ continueOnError: true }
);
if (R.prop('body', spec) && consumes.length > 0) {
spec.type = R.head(consumes).split('/')[1];
}
return spec;
};
开发者ID:benjambles,项目名称:my-own-world,代码行数:13,代码来源:build-joi-spec.ts
示例6: sort
public static sort(unsorted: number [] = []): number[] {
if (unsorted.length !== 0) {
const sorted = [];
const m = R.head(unsorted);
const {l, h} = R.groupBy(curr => R.gte(curr, m) ? 'h' : 'l', R.drop(1, unsorted))
sorted.push(...QuickSort.sort(l));
sorted.push(m);
sorted.push(...QuickSort.sort(h));
return sorted;
} else
return unsorted;
}
开发者ID:sprengerjo,项目名称:katas_js,代码行数:15,代码来源:quick_sort.ts
示例7:
fields.forEach(field => {
if (!toFilter) {
if (R.is(Object, field)) {
const key = R.head(R.keys(field));
const value = R.values(field);
if (key === 'eq') {
toFilter = (obj[value] === query);
}
} else {
if (!R.isNil(obj[field])) {
toFilter = obj[field].toString()
.toLowerCase().indexOf(query) > -1
}
}
}
});
开发者ID:simbiosis-group,项目名称:ion2-helper,代码行数:16,代码来源:array-helper.ts
示例8: head
export const pinNumbers = (observed: string): Array<String> => {
const lookUp = ['08', '124', '1235', '236', '1457', '24568', '3569', '478', '57890', '689'];
let obsHead: string = head(observed);
const heads = lookUp[obsHead];
if (observed.length <= 1)
return split('', heads);
const result = [];
for (const h of heads) {
for (const t of pinNumbers(drop(1, observed))) {
result.push(h + t)
}
}
return result
};
开发者ID:sprengerjo,项目名称:katas_js,代码行数:18,代码来源:pin_numbers.ts
示例9: getCurrentExercise
/* tslint:disable-next-line:no-any */
public getCurrentExercise(): Maybe<AbstractExercise<any, any, any>> {
return head(this.exercises);
}
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:4,代码来源:abstract-exercise-group.interface.ts
注:本文中的ramda.head函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论