本文整理汇总了TypeScript中lodash.trim函数的典型用法代码示例。如果您正苦于以下问题:TypeScript trim函数的具体用法?TypeScript trim怎么用?TypeScript trim使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trim函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getImportBindingName
function getImportBindingName(node: ImportOrExportDeclaration) {
if (isImportRequireStatement(node)) {
return _.trim(node.moduleReference.getText(), '\'"');
} else if (isExportStatement(node)) {
return _.trim(node.moduleSpecifier.getText(), '\'"');
} else {
return _.trim(node.moduleSpecifier.getText(), '\'"');
}
}
示例2: equalsIgnoreCase
public static equalsIgnoreCase(val1: string, val2:string): boolean {
if(isString(val1) && isString(val2) && trim(val1).length > 0 && trim(val2).length > 0){
if(val1.toUpperCase() === val2.toUpperCase()){
return true;
}else{
return false;
}
}
return false;
}
示例3: getSortKey
function getSortKey(statement: ImportOrExportDeclaration) {
try {
if (isImportStatement(statement) && !isImportRequireStatement(statement)) {
return _.trim(statement.moduleSpecifier.getText(), '\'"');
} else if (isExportStatement(statement) && !isImportRequireStatement(statement)) {
return _.trim(statement.moduleSpecifier.getText(), '\'"');
} else {
return _.trim(statement.moduleReference.getText(), '\'"');
}
} catch (e) {
return null;
}
}
示例4: customSortKey
function customSortKey(key: string) {
try {
let result = key;
if (key[0] === '@') {
result = _.trim(key, '@').toLowerCase();
} else if (_.startsWith(key, 'lodash')) {
result = `0${key}`;
} else if (_.startsWith(key, `rxjs`)) {
result = `0${key}`;
} else if (_.startsWith(key, './') || _.startsWith(key, '../')) {
const split = key.split('/');
let prefix: string;
result = _.last(split);
if (result === 'index') {
result = _.nth(split, -2);
}
if (result.match(/^[A-Z]/)) {
prefix = 'z';
} else {
prefix = 'y';
}
result = `${prefix}${result}`.toLowerCase();
}
return result.replace(/\//g, '');
} catch (e) {
return null;
}
}
示例5: getTraits
async function getTraits(dispatch: (action: any) => any, payload: FetchTraitInterface) {
const config: RequestConfig = () => ({
url: payload.apiHost,
headers: {
Authorization: `${client.ACCESS_TOKEN_PREFIX} ${patcher.getAccessToken()}`,
},
});
const res = await webAPI.TraitsAPI.GetTraitsV1(config, client.shardID);
if (res.ok) {
const data = JSON.parse(res.data);
dispatch(onInitializeTraits({
playerClass: _.trim(payload.playerClass),
race: payload.race,
faction: payload.faction,
banesAndBoons: data,
initType: payload.initType,
}));
} else {
toastr.error(
'We are having technical difficulties. You will not be able to create a character until they have been fixed.',
'Oh No!!',
{ timeOut: 5000 },
);
}
}
示例6: safeTrim
static safeTrim(s: string): string {
if (!s) {
return null;
}
return _.trim(s);
}
示例7: substringBefore
public static substringBefore(val:string, delimiter:string):string {
var str :string;
if(isString(val) && trim(val).length > 0){
str = val.split(delimiter)[0];
}
return str;
}
示例8: isNotBlank
public static isNotBlank(val: string): boolean {
if(isString(val) && trim(val).length > 0 && undefined != val && "null" != val && null != val){
return true;
}
return false;
}
示例9: transformPackageVersions
transformPackageVersions(packageVersions: Array<string>, request: IRequest): Array<IProposal> {
const {token} = request;
const trimmedToken = trim(token, '"');
return packageVersions
.filter(version => isStableVersion(version))
.filter(version => startsWith(version, trimmedToken))
.map(version => createVersionProposal(version, request));
}
开发者ID:GabrielNicolasAvellaneda,项目名称:autocomplete-json,代码行数:8,代码来源:composer-json-dependency-proposal-provider.ts
示例10:
keys.forEach((key) => {
const value = object[key];
if (!value) delete object[key];
if (typeof value === 'string' && nullStrings.has(trim(value, trimChars).toLowerCase())) {
delete object[key];
}
});