move keysOf into a new utilities file

This commit is contained in:
Bjorn Stromberg 2025-06-06 08:53:13 +08:00
parent 266d23f7bb
commit c1b22998a1
3 changed files with 5 additions and 5 deletions

View file

@ -11,6 +11,7 @@ import type {
WeakRef,
Whitespace,
} from './types.js';
import {keysOf} from './utilities.js';
// From type-fest.
type ExtractFromGlobalConstructors<Name extends string> =
@ -1124,10 +1125,6 @@ const methodTypeMap = {
isWhitespaceString: 'whitespace string',
} as const;
export function keysOf<T extends Record<PropertyKey, unknown>>(value: T): Array<keyof T> {
return Object.keys(value) as Array<keyof T>;
}
type IsMethodName = keyof typeof methodTypeMap;
const isMethodNames: IsMethodName[] = keysOf(methodTypeMap);

3
source/utilities.ts Normal file
View file

@ -0,0 +1,3 @@
export function keysOf<T extends Record<PropertyKey, unknown>>(value: T): Array<keyof T> {
return Object.keys(value) as Array<keyof T>;
}