From 142ca00a1c3039705bb742f957a4877084abf1a3 Mon Sep 17 00:00:00 2001 From: mesqueeb Date: Thu, 26 Oct 2023 13:55:21 +0900 Subject: [PATCH] fix: prettier --- src/getType.ts | 2 +- src/isAnyObject.ts | 5 ++-- src/isBlob.ts | 2 +- src/isBoolean.ts | 2 +- src/isDate.ts | 2 +- src/isEmptyArray.ts | 2 +- src/isEmptyObject.ts | 5 ++-- src/isEmptyString.ts | 2 +- src/isError.ts | 2 +- src/isFile.ts | 2 +- src/isFullArray.ts | 2 +- src/isFullString.ts | 2 +- src/isFunction.ts | 2 +- src/isInstanceOf.ts | 17 ++++++------ src/isMap.ts | 2 +- src/isNaNValue.ts | 2 +- src/isNegativeNumber.ts | 2 +- src/isNull.ts | 2 +- src/isNullOrUndefined.ts | 4 +-- src/isNumber.ts | 2 +- src/isObject.ts | 5 ++-- src/isObjectLike.ts | 4 +-- src/isOneOf.ts | 57 ++++++++++++++++++++++------------------ src/isPlainObject.ts | 5 ++-- src/isPositiveNumber.ts | 2 +- src/isPrimitive.ts | 5 ++-- src/isPromise.ts | 2 +- src/isRegExp.ts | 2 +- src/isSet.ts | 2 +- src/isString.ts | 2 +- src/isSymbol.ts | 2 +- src/isType.ts | 10 +++---- src/isUndefined.ts | 2 +- src/isWeakMap.ts | 2 +- src/isWeakSet.ts | 2 +- 35 files changed, 89 insertions(+), 78 deletions(-) diff --git a/src/getType.ts b/src/getType.ts index fe2970f..f65df87 100644 --- a/src/getType.ts +++ b/src/getType.ts @@ -1,7 +1,7 @@ /** * Returns the object type of the given payload * - * @param {*} payload + * @param {any} payload * @returns {string} */ export function getType(payload: any): string { diff --git a/src/isAnyObject.ts b/src/isAnyObject.ts index afebf79..906cbf6 100644 --- a/src/isAnyObject.ts +++ b/src/isAnyObject.ts @@ -2,9 +2,10 @@ import { getType } from './getType.js' import { PlainObject } from './isPlainObject.js' /** - * Returns whether the payload is an any kind of object (including special classes or objects with different prototypes) + * Returns whether the payload is an any kind of object (including special classes or objects with + * different prototypes) * - * @param {*} payload + * @param {any} payload * @returns {payload is PlainObject} */ export function isAnyObject(payload: any): payload is PlainObject { diff --git a/src/isBlob.ts b/src/isBlob.ts index 76c91ac..6e663b0 100644 --- a/src/isBlob.ts +++ b/src/isBlob.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is a Blob * - * @param {*} payload + * @param {any} payload * @returns {payload is Blob} */ export function isBlob(payload: any): payload is Blob { diff --git a/src/isBoolean.ts b/src/isBoolean.ts index c12d9cc..1e2af40 100644 --- a/src/isBoolean.ts +++ b/src/isBoolean.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is a boolean * - * @param {*} payload + * @param {any} payload * @returns {payload is boolean} */ export function isBoolean(payload: any): payload is boolean { diff --git a/src/isDate.ts b/src/isDate.ts index 7cf4210..e1d4e5e 100644 --- a/src/isDate.ts +++ b/src/isDate.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is a Date, and that the date is valid * - * @param {*} payload + * @param {any} payload * @returns {payload is Date} */ export function isDate(payload: any): payload is Date { diff --git a/src/isEmptyArray.ts b/src/isEmptyArray.ts index b195582..073a1ae 100644 --- a/src/isEmptyArray.ts +++ b/src/isEmptyArray.ts @@ -3,7 +3,7 @@ import { isArray } from './isArray.js' /** * Returns whether the payload is a an empty array * - * @param {*} payload + * @param {any} payload * @returns {payload is []} */ export function isEmptyArray(payload: any): payload is [] { diff --git a/src/isEmptyObject.ts b/src/isEmptyObject.ts index 6a7835b..9ffcc5d 100644 --- a/src/isEmptyObject.ts +++ b/src/isEmptyObject.ts @@ -1,9 +1,10 @@ import { isPlainObject } from './isPlainObject.js' /** - * Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes) + * Returns whether the payload is a an empty object (excluding special classes or objects with other + * prototypes) * - * @param {*} payload + * @param {any} payload * @returns {payload is { [K in any]: never }} */ export function isEmptyObject(payload: any): payload is { [K in any]: never } { diff --git a/src/isEmptyString.ts b/src/isEmptyString.ts index 6ce62f0..ee892fc 100644 --- a/src/isEmptyString.ts +++ b/src/isEmptyString.ts @@ -1,7 +1,7 @@ /** * Returns whether the payload is '' * - * @param {*} payload + * @param {any} payload * @returns {payload is string} */ export function isEmptyString(payload: any): payload is string { diff --git a/src/isError.ts b/src/isError.ts index 9cd7f9c..a3f4ca0 100644 --- a/src/isError.ts +++ b/src/isError.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is an Error * - * @param {*} payload + * @param {any} payload * @returns {payload is Error} */ export function isError(payload: any): payload is Error { diff --git a/src/isFile.ts b/src/isFile.ts index 0eed670..9ae77e4 100644 --- a/src/isFile.ts +++ b/src/isFile.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is a File * - * @param {*} payload + * @param {any} payload * @returns {payload is File} */ export function isFile(payload: any): payload is File { diff --git a/src/isFullArray.ts b/src/isFullArray.ts index 689d965..720f005 100644 --- a/src/isFullArray.ts +++ b/src/isFullArray.ts @@ -3,7 +3,7 @@ import { isArray } from './isArray.js' /** * Returns whether the payload is a an array with at least 1 item * - * @param {*} payload + * @param {any} payload * @returns {payload is any[]} */ export function isFullArray(payload: any): payload is any[] { diff --git a/src/isFullString.ts b/src/isFullString.ts index e06ed85..d1aac76 100644 --- a/src/isFullString.ts +++ b/src/isFullString.ts @@ -3,7 +3,7 @@ import { isString } from './isString.js' /** * Returns whether the payload is a string, BUT returns false for '' * - * @param {*} payload + * @param {any} payload * @returns {payload is string} */ export function isFullString(payload: any): payload is string { diff --git a/src/isFunction.ts b/src/isFunction.ts index dc6ef44..30796a2 100644 --- a/src/isFunction.ts +++ b/src/isFunction.ts @@ -3,7 +3,7 @@ export type AnyFunction = (...args: any[]) => any /** * Returns whether the payload is a function (regular or async) * - * @param {*} payload + * @param {any} payload * @returns {payload is AnyFunction} */ export function isFunction(payload: any): payload is AnyFunction { diff --git a/src/isInstanceOf.ts b/src/isInstanceOf.ts index 9e749ad..d83b611 100644 --- a/src/isInstanceOf.ts +++ b/src/isInstanceOf.ts @@ -6,17 +6,16 @@ type GlobalClassName = { }[keyof typeof globalThis] /** - * Checks if a value is an instance of a class or a class name. Useful when you - * want to check if a value is an instance of a class that may not be defined in - * the current scope. For example, if you want to check if a value is an - * `OffscreenCanvas` instance, you might not want to do the song and dance of - * using `typeof OffscreenCanvas !== 'undefined'` and then shimming - * `OffscreenCanvas` if the types aren't around. + * Checks if a value is an instance of a class or a class name. Useful when you want to check if a + * value is an instance of a class that may not be defined in the current scope. For example, if you + * want to check if a value is an `OffscreenCanvas` instance, you might not want to do the song and + * dance of using `typeof OffscreenCanvas !== 'undefined'` and then shimming `OffscreenCanvas` if + * the types aren't around. * * @example - * if (isInstanceOf(value, 'OffscreenCanvas')) { - * // value is an OffscreenCanvas - * } + * if (isInstanceOf(value, 'OffscreenCanvas')) { + * // value is an OffscreenCanvas + * } * * @param value The value to recursively check * @param class_ A string or class that the value should be an instance of diff --git a/src/isMap.ts b/src/isMap.ts index 2af06ee..535b267 100644 --- a/src/isMap.ts +++ b/src/isMap.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is a Map * - * @param {*} payload + * @param {any} payload * @returns {payload is Map} */ export function isMap(payload: any): payload is Map { diff --git a/src/isNaNValue.ts b/src/isNaNValue.ts index eb4917b..ce165fc 100644 --- a/src/isNaNValue.ts +++ b/src/isNaNValue.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is literally the value `NaN` (it's `NaN` and also a `number`) * - * @param {*} payload + * @param {any} payload * @returns {payload is typeof NaN} */ export function isNaNValue(payload: any): payload is typeof NaN { diff --git a/src/isNegativeNumber.ts b/src/isNegativeNumber.ts index 1491df8..8cad5ca 100644 --- a/src/isNegativeNumber.ts +++ b/src/isNegativeNumber.ts @@ -3,7 +3,7 @@ import { isNumber } from './isNumber.js' /** * Returns whether the payload is a negative number (but not 0) * - * @param {*} payload + * @param {any} payload * @returns {payload is number} */ export function isNegativeNumber(payload: any): payload is number { diff --git a/src/isNull.ts b/src/isNull.ts index 0e66a4b..7dec7bc 100644 --- a/src/isNull.ts +++ b/src/isNull.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is null * - * @param {*} payload + * @param {any} payload * @returns {payload is null} */ export function isNull(payload: any): payload is null { diff --git a/src/isNullOrUndefined.ts b/src/isNullOrUndefined.ts index c77c491..282ed81 100644 --- a/src/isNullOrUndefined.ts +++ b/src/isNullOrUndefined.ts @@ -1,11 +1,11 @@ import { isNull } from './isNull.js' -import { isOneOf } from './isOneOf.js' +import { /* tree-shaking no-side-effects-when-called */ isOneOf } from './isOneOf.js' import { isUndefined } from './isUndefined.js' /** * Returns true whether the payload is null or undefined * - * @param {*} payload + * @param {any} payload * @returns {(payload is null | undefined)} */ export const isNullOrUndefined = isOneOf(isNull, isUndefined) diff --git a/src/isNumber.ts b/src/isNumber.ts index 1f49829..6dec624 100644 --- a/src/isNumber.ts +++ b/src/isNumber.ts @@ -5,7 +5,7 @@ import { getType } from './getType.js' * * This will return `false` for `NaN`!! * - * @param {*} payload + * @param {any} payload * @returns {payload is number} */ export function isNumber(payload: any): payload is number { diff --git a/src/isObject.ts b/src/isObject.ts index 6f9e347..9f2f9e1 100644 --- a/src/isObject.ts +++ b/src/isObject.ts @@ -1,9 +1,10 @@ import { PlainObject, isPlainObject } from './isPlainObject.js' /** - * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes) + * Returns whether the payload is a plain JavaScript object (excluding special classes or objects + * with other prototypes) * - * @param {*} payload + * @param {any} payload * @returns {payload is PlainObject} */ export function isObject(payload: any): payload is PlainObject { diff --git a/src/isObjectLike.ts b/src/isObjectLike.ts index 8770beb..ce39555 100644 --- a/src/isObjectLike.ts +++ b/src/isObjectLike.ts @@ -6,8 +6,8 @@ import { PlainObject } from './isPlainObject.js' * * Usage: isObjectLike<{id: any}>(payload) // will make sure it's an object and has an `id` prop. * - * @template T this must be passed in < > - * @param {*} payload + * @template T This must be passed in < > + * @param {any} payload * @returns {payload is T} */ export function isObjectLike(payload: any): payload is T { diff --git a/src/isOneOf.ts b/src/isOneOf.ts index e7abb18..02365b4 100644 --- a/src/isOneOf.ts +++ b/src/isOneOf.ts @@ -1,15 +1,18 @@ +import { AnyFunction } from './isFunction' + type TypeGuard = (payload: A) => payload is B /** * A factory function that creates a function to check if the payload is one of the given types. + * * @example - * import { isOneOf, isNull, isUndefined } from 'is-what' + * import { isOneOf, isNull, isUndefined } from 'is-what' * - * const isNullOrUndefined = isOneOf(isNull, isUndefined) + * const isNullOrUndefined = isOneOf(isNull, isUndefined) * - * isNullOrUndefined(null) // true - * isNullOrUndefined(undefined) // true - * isNullOrUndefined(123) // false + * isNullOrUndefined(null) // true + * isNullOrUndefined(undefined) // true + * isNullOrUndefined(123) // false */ export function isOneOf( a: TypeGuard, @@ -17,14 +20,15 @@ export function isOneOf( ): TypeGuard /** * A factory function that creates a function to check if the payload is one of the given types. + * * @example - * import { isOneOf, isNull, isUndefined } from 'is-what' + * import { isOneOf, isNull, isUndefined } from 'is-what' * - * const isNullOrUndefined = isOneOf(isNull, isUndefined) + * const isNullOrUndefined = isOneOf(isNull, isUndefined) * - * isNullOrUndefined(null) // true - * isNullOrUndefined(undefined) // true - * isNullOrUndefined(123) // false + * isNullOrUndefined(null) // true + * isNullOrUndefined(undefined) // true + * isNullOrUndefined(123) // false */ export function isOneOf( a: TypeGuard, @@ -33,14 +37,15 @@ export function isOneOf( ): TypeGuard /** * A factory function that creates a function to check if the payload is one of the given types. + * * @example - * import { isOneOf, isNull, isUndefined } from 'is-what' + * import { isOneOf, isNull, isUndefined } from 'is-what' * - * const isNullOrUndefined = isOneOf(isNull, isUndefined) + * const isNullOrUndefined = isOneOf(isNull, isUndefined) * - * isNullOrUndefined(null) // true - * isNullOrUndefined(undefined) // true - * isNullOrUndefined(123) // false + * isNullOrUndefined(null) // true + * isNullOrUndefined(undefined) // true + * isNullOrUndefined(123) // false */ export function isOneOf( a: TypeGuard, @@ -50,14 +55,15 @@ export function isOneOf( ): TypeGuard /** * A factory function that creates a function to check if the payload is one of the given types. + * * @example - * import { isOneOf, isNull, isUndefined } from 'is-what' + * import { isOneOf, isNull, isUndefined } from 'is-what' * - * const isNullOrUndefined = isOneOf(isNull, isUndefined) + * const isNullOrUndefined = isOneOf(isNull, isUndefined) * - * isNullOrUndefined(null) // true - * isNullOrUndefined(undefined) // true - * isNullOrUndefined(123) // false + * isNullOrUndefined(null) // true + * isNullOrUndefined(undefined) // true + * isNullOrUndefined(123) // false */ export function isOneOf( a: TypeGuard, @@ -68,14 +74,15 @@ export function isOneOf /** * A factory function that creates a function to check if the payload is one of the given types. + * * @example - * import { isOneOf, isNull, isUndefined } from 'is-what' + * import { isOneOf, isNull, isUndefined } from 'is-what' * - * const isNullOrUndefined = isOneOf(isNull, isUndefined) + * const isNullOrUndefined = isOneOf(isNull, isUndefined) * - * isNullOrUndefined(null) // true - * isNullOrUndefined(undefined) // true - * isNullOrUndefined(123) // false + * isNullOrUndefined(null) // true + * isNullOrUndefined(undefined) // true + * isNullOrUndefined(123) // false */ export function isOneOf( a: AnyFunction, diff --git a/src/isPlainObject.ts b/src/isPlainObject.ts index d053c9f..13f1ddd 100644 --- a/src/isPlainObject.ts +++ b/src/isPlainObject.ts @@ -3,9 +3,10 @@ import { getType } from './getType.js' export type PlainObject = Record /** - * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes) + * Returns whether the payload is a plain JavaScript object (excluding special classes or objects + * with other prototypes) * - * @param {*} payload + * @param {any} payload * @returns {payload is PlainObject} */ export function isPlainObject(payload: any): payload is PlainObject { diff --git a/src/isPositiveNumber.ts b/src/isPositiveNumber.ts index 9594b5f..2df1d01 100644 --- a/src/isPositiveNumber.ts +++ b/src/isPositiveNumber.ts @@ -3,7 +3,7 @@ import { isNumber } from './isNumber.js' /** * Returns whether the payload is a positive number (but not 0) * - * @param {*} payload + * @param {any} payload * @returns {payload is number} */ export function isPositiveNumber(payload: any): payload is number { diff --git a/src/isPrimitive.ts b/src/isPrimitive.ts index 0f7a30b..5a3dca1 100644 --- a/src/isPrimitive.ts +++ b/src/isPrimitive.ts @@ -6,9 +6,10 @@ import { isSymbol } from './isSymbol.js' import { isUndefined } from './isUndefined.js' /** - * Returns whether the payload is a primitive type (eg. Boolean | Null | Undefined | Number | String | Symbol) + * Returns whether the payload is a primitive type (eg. Boolean | Null | Undefined | Number | String + * | Symbol) * - * @param {*} payload + * @param {any} payload * @returns {(payload is boolean | null | undefined | number | string | symbol)} */ export function isPrimitive( diff --git a/src/isPromise.ts b/src/isPromise.ts index f78aa33..ef3139d 100644 --- a/src/isPromise.ts +++ b/src/isPromise.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is a Promise * - * @param {*} payload + * @param {any} payload * @returns {payload is Promise} */ export function isPromise(payload: any): payload is Promise { diff --git a/src/isRegExp.ts b/src/isRegExp.ts index bd1aa4c..198710f 100644 --- a/src/isRegExp.ts +++ b/src/isRegExp.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is a regular expression (RegExp) * - * @param {*} payload + * @param {any} payload * @returns {payload is RegExp} */ export function isRegExp(payload: any): payload is RegExp { diff --git a/src/isSet.ts b/src/isSet.ts index d5e5899..ea85c90 100644 --- a/src/isSet.ts +++ b/src/isSet.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is a Set * - * @param {*} payload + * @param {any} payload * @returns {payload is Set} */ export function isSet(payload: any): payload is Set { diff --git a/src/isString.ts b/src/isString.ts index 5da0879..aec74c2 100644 --- a/src/isString.ts +++ b/src/isString.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is a string * - * @param {*} payload + * @param {any} payload * @returns {payload is string} */ export function isString(payload: any): payload is string { diff --git a/src/isSymbol.ts b/src/isSymbol.ts index 3f829ea..fa16675 100644 --- a/src/isSymbol.ts +++ b/src/isSymbol.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is a Symbol * - * @param {*} payload + * @param {any} payload * @returns {payload is symbol} */ export function isSymbol(payload: any): payload is symbol { diff --git a/src/isType.ts b/src/isType.ts index 7eb960d..8a95ff4 100644 --- a/src/isType.ts +++ b/src/isType.ts @@ -4,15 +4,15 @@ import { AnyFunction } from './isFunction.js' export type AnyClass = new (...args: any[]) => any /** - * Does a generic check to check that the given payload is of a given type. - * In cases like Number, it will return true for NaN as NaN is a Number (thanks javascript!); - * It will, however, differentiate between object and null + * Does a generic check to check that the given payload is of a given type. In cases like Number, it + * will return true for NaN as NaN is a Number (thanks javascript!); It will, however, differentiate + * between object and null * * @template T - * @param {*} payload + * @param {any} payload * @param {T} type - * @throws {TypeError} Will throw type error if type is an invalid type * @returns {payload is T} + * @throws {TypeError} Will throw type error if type is an invalid type */ export function isType(payload: any, type: T): payload is T { if (!(type instanceof Function)) { diff --git a/src/isUndefined.ts b/src/isUndefined.ts index 017ec2f..c0f474b 100644 --- a/src/isUndefined.ts +++ b/src/isUndefined.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is undefined * - * @param {*} payload + * @param {any} payload * @returns {payload is undefined} */ export function isUndefined(payload: any): payload is undefined { diff --git a/src/isWeakMap.ts b/src/isWeakMap.ts index ef0ed82..1eeba6d 100644 --- a/src/isWeakMap.ts +++ b/src/isWeakMap.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is a WeakMap * - * @param {*} payload + * @param {any} payload * @returns {payload is WeakMap} */ export function isWeakMap(payload: any): payload is WeakMap { diff --git a/src/isWeakSet.ts b/src/isWeakSet.ts index 940dd73..d9e585c 100644 --- a/src/isWeakSet.ts +++ b/src/isWeakSet.ts @@ -3,7 +3,7 @@ import { getType } from './getType.js' /** * Returns whether the payload is a WeakSet * - * @param {*} payload + * @param {any} payload * @returns {payload is WeakSet} */ export function isWeakSet(payload: any): payload is WeakSet {