mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-17 21:10:43 +00:00
### Description optimize eslint config to: - set parserOptions.project to `true` to allow @typescript-eslint/parser to find the nearest tsconfig.json file to that source file. This helps to avoid parsing extra files, may helps with: - reduce the possibility of seeing OOM or stackoverflow with "npm run lint" - faster processing - enforce rule "no-underscore-dangle" with a list of exceptions.
24 lines
752 B
TypeScript
24 lines
752 B
TypeScript
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
class AttributeWithCacheKeyImpl {
|
|
constructor(attribute: Record<string, unknown>) {
|
|
Object.assign(this, attribute);
|
|
}
|
|
|
|
private key: string;
|
|
public get cacheKey(): string {
|
|
if (!this.key) {
|
|
this.key =
|
|
Object.getOwnPropertyNames(this).sort().map(name => `${(this as Record<string, unknown>)[name]}`).join(';');
|
|
}
|
|
return this.key;
|
|
}
|
|
}
|
|
|
|
export interface AttributeWithCacheKey {
|
|
readonly cacheKey: string;
|
|
}
|
|
|
|
export const createAttributeWithCacheKey = <T extends Record<string, unknown>>(attribute: T): T&AttributeWithCacheKey =>
|
|
new AttributeWithCacheKeyImpl(attribute) as unknown as T & AttributeWithCacheKey;
|