chore(utils): typedObjectKeys

This commit is contained in:
Martin Varmuza
2025-02-19 09:46:18 +01:00
committed by martin
parent 60f76b63dc
commit 30f8f4fc59
5 changed files with 5 additions and 9 deletions

View File

@@ -19,6 +19,7 @@ import {
getSynchronize,
isNotUndefined,
resolveAfter,
typedObjectKeys,
} from '@trezor/utils';
import { ERRORS } from '../constants';
@@ -26,7 +27,6 @@ import { DEVICE, TransportError, TransportInfo } from '../events';
import { Device } from './Device';
import { getBridgeInfo } from '../data/transportInfo';
import { ConnectSettings, DeviceUniquePath, StaticSessionId } from '../types';
import { typedObjectKeys } from '../types/utils';
import { initLog } from '../utils/debug';
const createAuthPenaltyManager = (priority: number) => {

View File

@@ -18,6 +18,3 @@ export type MessageFactoryFn<Group, Event> = UnionToIntersection<
) => { event: Group; type: Event['type']; payload: undefined }
: never
>;
export const typedObjectKeys = <T extends Record<any, any>>(obj: T): Array<keyof T> =>
Object.keys(obj) as Array<keyof T>;

View File

@@ -10,7 +10,7 @@
*/
import { TimerId } from '@trezor/type-utils';
import { Deferred, TypedEmitter, createDeferred } from '@trezor/utils';
import { Deferred, TypedEmitter, createDeferred, typedObjectKeys } from '@trezor/utils';
import type {
AcquireDoneRequest,
@@ -27,10 +27,6 @@ import * as ERRORS from '../errors';
import type { Descriptor, PathInternal, Success } from '../types';
import { PathPublic, Session } from '../types';
function typedObjectKeys<T extends Record<any, any>>(obj: T): Array<keyof T> {
return Object.keys(obj) as Array<keyof T>;
}
type DescriptorsDict = Record<PathInternal, Descriptor>;
// in nodeusb, enumeration operation takes ~3 seconds

View File

@@ -51,5 +51,6 @@ export * from './throttler';
export * from './throwError';
export * from './topologicalSort';
export * from './typedEventEmitter';
export * from './typedObjectKeys';
export * from './urlToOnion';
export * from './zip';

View File

@@ -0,0 +1,2 @@
export const typedObjectKeys = <T extends Record<any, any>>(obj: T): Array<keyof T> =>
Object.keys(obj) as Array<keyof T>;