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