本文整理汇总了TypeScript中ramda.last函数的典型用法代码示例。如果您正苦于以下问题:TypeScript last函数的具体用法?TypeScript last怎么用?TypeScript last使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了last函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: toPath
export const match = (modifier: string, props: MatchProps = {}) => {
if (modifier === SELF_MODIFIER_NAME) {
return true
}
const modifierPath = toPath(modifier)
const linearMatch = target => {
const value = path(modifierPath, target)
if (is(Boolean, value)) {
return value
}
if (isNil(value)) {
return false
}
return !isEmpty(value)
}
const matcher =
modifierPath.length > 1
? pathEq(init(modifierPath), last(modifierPath))
: linearMatch
return matcher(props)
}
示例2: rowGenerator
export function rowGenerator(state: State, table: string, schema: RelationTree): Route[] {
let history: History = R.clone(state.history || []);
if (history.length >= state.options.relationLimit) {
return [];
}
let last = R.last(history);
let relation = schema[table].relations[last && last['table']];
let identifier = `${schema[table].model}_id`;
if (relation) {
history.push({
type: 'row',
table: table,
model: schema[table].model
});
}
else {
history[0] = {
type: 'row',
table: table,
model: schema[table].model,
identifier: identifier
};
}
let identifierString = state.options.idFormat === 'colons' ?
`:${identifier}` : `{${identifier}}`;
let newPath = relation ?
`${state.path}/${schema[table].model}` : `${state.path}/${identifierString}`;
let newState = {
options: state.options,
path: newPath,
history: history
};
let tables = R.flatten(Object.keys(schema[table].relations).map((relation) => {
if (schema[table].relations[relation] === 'one') {
return rowGenerator(newState, relation, schema);
}
else {
return tableGenerator(newState, relation, schema);
}
}));
return R.concat(
scopes.row.methods.map((method) => {
return {
path: newPath,
method: method,
history: history
};
}),
tables
);
};
示例3: 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 = [];
}
}
});
示例4: it
it(`upToWithProcessEngine '${n}' iterations`, async() => {
const fizzbuzzUpTo = processEngine.execute('fizzy-upTo');
const actual = await fizzbuzzUpTo({upTo: n + 1, i: 1});
expect(actual.length).toEqual(n);
expect(R.last(actual)).toEqual('buzz');
});
示例5: 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)));
}
示例6: setKey
function setKey(to: any, keyPath: string[], type: string, from: any): void {
let key = R.last(keyPath);
if (!from.hasOwnProperty(key)) return;
let value = from[key];
ConfigTypeError.assert(keyPath.join('.'), type, value);
to[key] = value;
}
示例7: getNextNumber
/**
* Return the next running number in an array of records
* @param {string} prop The property name
* @param data The array of records containing the property
*/
static getNextNumber(prop: string, data: Array<any>) {
if (R.isEmpty(data)) { return 1 }
const getNextNumber = R.pipe(
R.sortBy(R.prop(prop)),
R.pluck(prop),
R.last()
);
return parseInt(getNextNumber(data)) + 1;
}
示例8: it
it('submitting a correct solution after submitting a wrong solution enqueus the exercise again', () => {
group.submit(false);
group.submit(true);
const exercises = group.getRemainingExercises();
expect(exercises.length).toEqual(10);
const lastExercise = R.last(exercises);
expect(lastExercise && lastExercise.props.index).toEqual(0);
});
示例9:
(acc: Array<BookmarkTree>, bookmarkTree) => {
if (!acc.length) return [bookmarkTree]
const prevBookmarkTree = R.last(acc)
if (!prevBookmarkTree) throw new Error('prevBookmarkTree must exist')
const updatedBookmarkTree = R.set(
R.lensPath(['parent', 'parentId']),
prevBookmarkTree.parent.id,
bookmarkTree
)
return [...acc, updatedBookmarkTree]
},