move keysOf into a new utilities file
This commit is contained in:
parent
266d23f7bb
commit
c1b22998a1
3 changed files with 5 additions and 5 deletions
|
|
@ -11,6 +11,7 @@ import type {
|
||||||
WeakRef,
|
WeakRef,
|
||||||
Whitespace,
|
Whitespace,
|
||||||
} from './types.js';
|
} from './types.js';
|
||||||
|
import {keysOf} from './utilities.js';
|
||||||
|
|
||||||
// From type-fest.
|
// From type-fest.
|
||||||
type ExtractFromGlobalConstructors<Name extends string> =
|
type ExtractFromGlobalConstructors<Name extends string> =
|
||||||
|
|
@ -1124,10 +1125,6 @@ const methodTypeMap = {
|
||||||
isWhitespaceString: 'whitespace string',
|
isWhitespaceString: 'whitespace string',
|
||||||
} as const;
|
} 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;
|
type IsMethodName = keyof typeof methodTypeMap;
|
||||||
const isMethodNames: IsMethodName[] = keysOf(methodTypeMap);
|
const isMethodNames: IsMethodName[] = keysOf(methodTypeMap);
|
||||||
|
|
||||||
|
|
|
||||||
3
source/utilities.ts
Normal file
3
source/utilities.ts
Normal 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>;
|
||||||
|
}
|
||||||
|
|
@ -12,13 +12,13 @@ import {expectTypeOf} from 'expect-type';
|
||||||
import ZenObservable from 'zen-observable';
|
import ZenObservable from 'zen-observable';
|
||||||
import is, {
|
import is, {
|
||||||
assert,
|
assert,
|
||||||
keysOf,
|
|
||||||
type AssertionTypeDescription,
|
type AssertionTypeDescription,
|
||||||
type Predicate,
|
type Predicate,
|
||||||
type Primitive,
|
type Primitive,
|
||||||
type TypedArray,
|
type TypedArray,
|
||||||
type TypeName,
|
type TypeName,
|
||||||
} from '../source/index.js';
|
} from '../source/index.js';
|
||||||
|
import {keysOf} from '../source/utilities.js';
|
||||||
|
|
||||||
class PromiseSubclassFixture<T> extends Promise<T> {}
|
class PromiseSubclassFixture<T> extends Promise<T> {}
|
||||||
class ErrorSubclassFixture extends Error {}
|
class ErrorSubclassFixture extends Error {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue