Meta tweaks
This commit is contained in:
parent
888e145c5a
commit
65404fbd8e
3 changed files with 35 additions and 15 deletions
14
package.json
14
package.json
|
|
@ -52,18 +52,18 @@
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sindresorhus/tsconfig": "^3.0.1",
|
"@sindresorhus/tsconfig": "^3.0.1",
|
||||||
"@types/jsdom": "^20.0.0",
|
"@types/jsdom": "^21.1.1",
|
||||||
"@types/node": "^18.11.0",
|
"@types/node": "^20.2.5",
|
||||||
"@types/zen-observable": "^0.8.3",
|
"@types/zen-observable": "^0.8.3",
|
||||||
"ava": "^4.3.3",
|
"ava": "^5.3.0",
|
||||||
"del-cli": "^5.0.0",
|
"del-cli": "^5.0.0",
|
||||||
"jsdom": "^20.0.1",
|
"jsdom": "^20.0.1",
|
||||||
"rxjs": "^7.5.7",
|
"rxjs": "^7.8.1",
|
||||||
"tempy": "^3.0.0",
|
"tempy": "^3.0.0",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"typescript": "~4.8.4",
|
"typescript": "^5.0.4",
|
||||||
"xo": "^0.52.4",
|
"xo": "^0.54.2",
|
||||||
"zen-observable": "^0.8.15"
|
"zen-observable": "^0.10.0"
|
||||||
},
|
},
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"ava": {
|
"ava": {
|
||||||
|
|
|
||||||
|
|
@ -105,20 +105,34 @@ function is(value: unknown): TypeName {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (typeof value) {
|
switch (typeof value) {
|
||||||
case 'undefined':
|
case 'undefined': {
|
||||||
return 'undefined';
|
return 'undefined';
|
||||||
case 'string':
|
}
|
||||||
|
|
||||||
|
case 'string': {
|
||||||
return 'string';
|
return 'string';
|
||||||
case 'number':
|
}
|
||||||
|
|
||||||
|
case 'number': {
|
||||||
return Number.isNaN(value) ? 'NaN' : 'number';
|
return Number.isNaN(value) ? 'NaN' : 'number';
|
||||||
case 'boolean':
|
}
|
||||||
|
|
||||||
|
case 'boolean': {
|
||||||
return 'boolean';
|
return 'boolean';
|
||||||
case 'function':
|
}
|
||||||
|
|
||||||
|
case 'function': {
|
||||||
return 'Function';
|
return 'Function';
|
||||||
case 'bigint':
|
}
|
||||||
|
|
||||||
|
case 'bigint': {
|
||||||
return 'bigint';
|
return 'bigint';
|
||||||
case 'symbol':
|
}
|
||||||
|
|
||||||
|
case 'symbol': {
|
||||||
return 'symbol';
|
return 'symbol';
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,6 +193,7 @@ is.array = <T = unknown>(value: unknown, assertion?: (value: T) => value is T):
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||||
return value.every(element => assertion(element));
|
return value.every(element => assertion(element));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -251,6 +266,7 @@ is.sharedArrayBuffer = isObjectOfType<SharedArrayBuffer>('SharedArrayBuffer');
|
||||||
|
|
||||||
is.dataView = isObjectOfType<DataView>('DataView');
|
is.dataView = isObjectOfType<DataView>('DataView');
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||||
is.enumCase = <T = unknown>(value: unknown, targetEnum: T): boolean => Object.values(targetEnum as any).includes(value as string);
|
is.enumCase = <T = unknown>(value: unknown, targetEnum: T): boolean => Object.values(targetEnum as any).includes(value as string);
|
||||||
|
|
||||||
is.directInstanceOf = <T>(instance: unknown, class_: Class<T>): instance is T => Object.getPrototypeOf(instance) === class_.prototype;
|
is.directInstanceOf = <T>(instance: unknown, class_: Class<T>): instance is T => Object.getPrototypeOf(instance) === class_.prototype;
|
||||||
|
|
|
||||||
|
|
@ -603,7 +603,7 @@ const testType = (t: ExecutionContext, type: string, exclude?: string[]) => {
|
||||||
|
|
||||||
for (const fixture of fixtures) {
|
for (const fixture of fixtures) {
|
||||||
assertIs(testIs(fixture), `Value: ${inspect(fixture)}`);
|
assertIs(testIs(fixture), `Value: ${inspect(fixture)}`);
|
||||||
const valueType = typeDescription ? typeDescription : typename;
|
const valueType = typeDescription ?? typename;
|
||||||
|
|
||||||
if (isTypeUnderTest) {
|
if (isTypeUnderTest) {
|
||||||
t.notThrows(() => {
|
t.notThrows(() => {
|
||||||
|
|
@ -1611,6 +1611,7 @@ test('is.any', t => {
|
||||||
t.false(is.any([is.boolean, is.number], 'unicorns', [], new Map()));
|
t.false(is.any([is.boolean, is.number], 'unicorns', [], new Map()));
|
||||||
|
|
||||||
t.throws(() => {
|
t.throws(() => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||||
is.any(null as any, true);
|
is.any(null as any, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1635,6 +1636,7 @@ test('is.any', t => {
|
||||||
});
|
});
|
||||||
|
|
||||||
t.throws(() => {
|
t.throws(() => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||||
assert.any(null as any, true);
|
assert.any(null as any, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1673,6 +1675,7 @@ test('is.all', t => {
|
||||||
t.true(is.all(is.array, ['1'], ['2']));
|
t.true(is.all(is.array, ['1'], ['2']));
|
||||||
|
|
||||||
t.throws(() => {
|
t.throws(() => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||||
is.all(null as any, true);
|
is.all(null as any, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1697,6 +1700,7 @@ test('is.all', t => {
|
||||||
});
|
});
|
||||||
|
|
||||||
t.throws(() => {
|
t.throws(() => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||||
assert.all(null as any, true);
|
assert.all(null as any, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue