Structure fixtures so they can be easily tested for exclusivity (#215)
This commit is contained in:
parent
882a91c54f
commit
ef35cc350a
3 changed files with 425 additions and 733 deletions
|
|
@ -11,6 +11,7 @@ import type {
|
|||
WeakRef,
|
||||
Whitespace,
|
||||
} from './types.js';
|
||||
import {keysOf} from './utilities.js';
|
||||
|
||||
// From type-fest.
|
||||
type ExtractFromGlobalConstructors<Name extends string> =
|
||||
|
|
@ -209,10 +210,14 @@ function detect(value: unknown): TypeName {
|
|||
}
|
||||
|
||||
const tagType = getObjectType(value);
|
||||
if (tagType) {
|
||||
if (tagType && tagType !== 'Object') {
|
||||
return tagType;
|
||||
}
|
||||
|
||||
if (hasPromiseApi(value)) {
|
||||
return 'Promise';
|
||||
}
|
||||
|
||||
if (value instanceof String || value instanceof Boolean || value instanceof Number) {
|
||||
throw new TypeError('Please don\'t use object wrappers for primitive types');
|
||||
}
|
||||
|
|
@ -1120,10 +1125,6 @@ const methodTypeMap = {
|
|||
isWhitespaceString: 'whitespace string',
|
||||
} as const;
|
||||
|
||||
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
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>;
|
||||
}
|
||||
1144
test/test.ts
1144
test/test.ts
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue