本文整理汇总了TypeScript中lodash.trimLeft函数的典型用法代码示例。如果您正苦于以下问题:TypeScript trimLeft函数的具体用法?TypeScript trimLeft怎么用?TypeScript trimLeft使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trimLeft函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getDependencyVersionsProposals
getDependencyVersionsProposals(request: IRequest): Promise<Array<IProposal>> {
const {segments, prefix} = request;
const [, packageName, ...rest] = segments;
const trimmedPrefix = trimLeft(prefix, '~^<>="');
return this.config.versions(packageName.toString()).then(versions =>
versions.filter(version => startsWith(version, trimmedPrefix))
.map(version => createVersionProposal(request, version))
);
}
示例2: containerName
function containerName(root: string, segments: Array<string>): string {
// Empty prefix or segments, search in the root folder.
if (isEmpty(segments)) {
return root;
}
// Last character is some kind of slash.
if (isEmpty(last(segments))) {
// this means, the last segment was (or should be) a directory.
const path = root + sep + trimLeft(segments.join(sep), '/\\');
if (directoryExists(path)) {
return path;
}
} else {
// Last segment is not a slash, meaning we don't need, what the user typed until the last slash.
const lastIsPartialFile = root + sep + trimLeft(segments.slice(0, segments.length - 1).join(sep), '/\\');
if (directoryExists(lastIsPartialFile)) {
return lastIsPartialFile;
}
}
// User wants completions for non existing directory.
return null;
}
示例3: createVersionProposal
function createVersionProposal(request: IRequest, version: string): IProposal {
const {isBetweenQuotes, shouldAddComma, prefix} = request;
const proposal: IProposal = {}
proposal.displayText = version;
proposal.rightLabel = 'version';
proposal.type = 'value';
proposal.replacementPrefix = trimLeft(prefix, '~^<>="');
if (isBetweenQuotes) {
proposal.text = version;
} else {
proposal.snippet = '"' + version + '"' + (shouldAddComma ? ',' : '');
}
return proposal;
}