onnxruntime

Форк
0
/
attribute-with-cache-key.ts 
27 строк · 774.0 Байт
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
// Licensed under the MIT License.
3

4
class AttributeWithCacheKeyImpl {
5
  constructor(attribute: Record<string, unknown>) {
6
    Object.assign(this, attribute);
7
  }
8

9
  private key: string;
10
  public get cacheKey(): string {
11
    if (!this.key) {
12
      this.key = Object.getOwnPropertyNames(this)
13
        .sort()
14
        .map((name) => `${(this as Record<string, unknown>)[name]}`)
15
        .join(';');
16
    }
17
    return this.key;
18
  }
19
}
20

21
export interface AttributeWithCacheKey {
22
  readonly cacheKey: string;
23
}
24

25
export const createAttributeWithCacheKey = <T extends Record<string, unknown>>(
26
  attribute: T,
27
): T & AttributeWithCacheKey => new AttributeWithCacheKeyImpl(attribute) as unknown as T & AttributeWithCacheKey;
28

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.