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>;
}

View file

@ -12,13 +12,13 @@ import {expectTypeOf} from 'expect-type';
import ZenObservable from 'zen-observable';
import is, {
assert,
keysOf,
type AssertionTypeDescription,
type Predicate,
type Primitive,
type TypedArray,
type TypeName,
} from '../source/index.js';
import {keysOf} from '../source/utilities.js';
class PromiseSubclassFixture<T> extends Promise<T> {}
class ErrorSubclassFixture extends Error {}