本文整理汇总了TypeScript中lodash.endsWith函数的典型用法代码示例。如果您正苦于以下问题:TypeScript endsWith函数的具体用法?TypeScript endsWith怎么用?TypeScript endsWith使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了endsWith函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: isValid
private isValid(file) {
return (
_.endsWith(file.name, '.yaml') ||
_.endsWith(file.name, '.yml') ||
_.endsWith(file.name, '.json')
);
}
示例2: getProperName
function getProperName(name: string) {
if (_.endsWith(name, 'ies')) {
return name.replace(/ies$/, 'y');
} else if (_.endsWith(name, 's')) {
return name.replace(/s$/, '');
}
return name;
}
示例3: isValidFile
export function isValidFile(e: DragEvent) {
if (!e.dataTransfer || !e.dataTransfer.files || !e.dataTransfer.files.length) {
return false;
}
const file = e.dataTransfer.files[0];
return _.endsWith(file.name, '.product') || _.endsWith(file.name, '.prodx');
}
示例4: processImage
private processImage(key: string, value: any, options: Record<string, any>) {
if (
_.isEqual(key, 'icon') ||
_.isEqual(key, 'image') ||
_.endsWith(key, 'Icon') ||
_.endsWith(key, 'Image')
) {
options[key] = this.assetService.resolveFromRequire(value);
}
}
示例5: loadSwaggerDocument
private static loadSwaggerDocument(options: SwaggerOptions) {
let swaggerDocument: any;
if (_.endsWith(options.filePath, '.yml') || _.endsWith(options.filePath, '.yaml')) {
swaggerDocument = YAML.load(options.filePath);
}
else {
swaggerDocument = fs.readJSONSync(options.filePath);
}
return swaggerDocument;
}
示例6: compile
export async function compile(
schema: JSONSchema4,
name: string,
options: Partial<Options> = {}
): Promise<string> {
const _options = merge({}, DEFAULT_OPTIONS, options)
const errors = validate(schema, name)
if (errors.length) {
errors.forEach(_ => error(_))
throw new ValidationError
}
// normalize options
if (!endsWith(_options.cwd, '/')) {
_options.cwd += '/'
}
return format(generate(
optimize(
parse(await dereference(normalize(schema, name), _options), _options)
),
_options
), _options)
}
示例7:
return observable.catch((err, source) => {
if (err.status === 401 && !_.endsWith(err.url, '/login')) {
this._router.navigate(['login']);
return Observable.empty(null);
} else {
return Observable.throw(err);
}
});
示例8: isPathToPackageFile
export function isPathToPackageFile(path) {
for (const fileName of DETECTABLE_FILES) {
if (_.endsWith(path, fileName)) {
return true;
}
}
return false;
}
示例9:
_.forEach(arr, (s) => {
if (_.startsWith(s, '{') && _.endsWith(s, '}')) {
let str: string = s;
str = str.slice(1);
str = str.substring(0, str.length - 1);
keys.push(str);
}
});