forked from orbit-oss/is
Minor tweaks
This commit is contained in:
parent
238e8c80c7
commit
6f2b24d822
1 changed files with 5 additions and 6 deletions
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
import {Class, TypedArray, ObservableLike, Primitive} from './types';
|
||||
|
||||
export {Class, TypedArray, ObservableLike, Primitive};
|
||||
|
||||
const typedArrayTypeNames = [
|
||||
'Int8Array',
|
||||
'Uint8Array',
|
||||
|
|
@ -260,8 +258,7 @@ is.primitive = (value: unknown): value is Primitive => is.null_(value) || isPrim
|
|||
is.integer = (value: unknown): value is number => Number.isInteger(value as number);
|
||||
is.safeInteger = (value: unknown): value is number => Number.isSafeInteger(value as number);
|
||||
|
||||
type ObjectKey = string | number | symbol;
|
||||
is.plainObject = <Value = unknown>(value: unknown): value is Record<ObjectKey, Value> => {
|
||||
is.plainObject = <Value = unknown>(value: unknown): value is Record<PropertyKey, Value> => {
|
||||
// From: https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
|
||||
if (toString.call(value) !== '[object Object]') {
|
||||
return false;
|
||||
|
|
@ -504,7 +501,7 @@ interface Assert {
|
|||
primitive: (value: unknown) => asserts value is Primitive;
|
||||
integer: (value: unknown) => asserts value is number;
|
||||
safeInteger: (value: unknown) => asserts value is number;
|
||||
plainObject: <Value = unknown>(value: unknown) => asserts value is Record<ObjectKey, Value>;
|
||||
plainObject: <Value = unknown>(value: unknown) => asserts value is Record<PropertyKey, Value>;
|
||||
typedArray: (value: unknown) => asserts value is TypedArray;
|
||||
arrayLike: <T = unknown>(value: unknown) => asserts value is ArrayLike<T>;
|
||||
domElement: (value: unknown) => asserts value is HTMLElement;
|
||||
|
|
@ -601,7 +598,7 @@ export const assert: Assert = {
|
|||
primitive: (value: unknown): asserts value is Primitive => assertType(is.primitive(value), AssertionTypeDescription.primitive, value),
|
||||
integer: (value: unknown): asserts value is number => assertType(is.integer(value), AssertionTypeDescription.integer, value),
|
||||
safeInteger: (value: unknown): asserts value is number => assertType(is.safeInteger(value), AssertionTypeDescription.safeInteger, value),
|
||||
plainObject: <Value = unknown>(value: unknown): asserts value is Record<ObjectKey, Value> => assertType(is.plainObject(value), AssertionTypeDescription.plainObject, value),
|
||||
plainObject: <Value = unknown>(value: unknown): asserts value is Record<PropertyKey, Value> => assertType(is.plainObject(value), AssertionTypeDescription.plainObject, value),
|
||||
typedArray: (value: unknown): asserts value is TypedArray => assertType(is.typedArray(value), AssertionTypeDescription.typedArray, value),
|
||||
arrayLike: <T = unknown>(value: unknown): asserts value is ArrayLike<T> => assertType(is.arrayLike(value), AssertionTypeDescription.arrayLike, value),
|
||||
domElement: (value: unknown): asserts value is HTMLElement => assertType(is.domElement(value), AssertionTypeDescription.domElement, value),
|
||||
|
|
@ -662,6 +659,8 @@ Object.defineProperties(assert, {
|
|||
|
||||
export default is;
|
||||
|
||||
export {Class, TypedArray, ObservableLike, Primitive} from './types';
|
||||
|
||||
// For CommonJS default export support
|
||||
module.exports = is;
|
||||
module.exports.default = is;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue